mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
os: work towards being able to again use -autofree
while recompiling the V compiler several times
This commit is contained in:
parent
2831b61a0b
commit
df51e840f9
2 changed files with 6 additions and 2 deletions
|
@ -1016,6 +1016,7 @@ pub fn write_file_array(path string, buffer array) ! {
|
|||
f.close()
|
||||
}
|
||||
|
||||
@[manualfree]
|
||||
pub fn glob(patterns ...string) ![]string {
|
||||
mut matches := []string{}
|
||||
for pattern in patterns {
|
||||
|
@ -1025,6 +1026,8 @@ pub fn glob(patterns ...string) ![]string {
|
|||
return matches
|
||||
}
|
||||
|
||||
// last_error returns a V error, formed by the last libc error (from GetLastError() on windows and from `errno` on !windows)
|
||||
@[manualfree]
|
||||
pub fn last_error() IError {
|
||||
$if windows {
|
||||
code := int(C.GetLastError())
|
||||
|
@ -1050,7 +1053,7 @@ pub:
|
|||
// Return a POSIX error:
|
||||
// Code defaults to last error (from C.errno)
|
||||
// Message defaults to POSIX error message for the error code
|
||||
@[inline]
|
||||
@[inline; manualfree]
|
||||
pub fn error_posix(e SystemError) IError {
|
||||
code := if e.code == error_code_not_set { C.errno } else { e.code }
|
||||
message := if e.msg == '' { posix_get_error_msg(code) } else { e.msg }
|
||||
|
@ -1060,7 +1063,7 @@ pub fn error_posix(e SystemError) IError {
|
|||
// Return a Win32 API error:
|
||||
// Code defaults to last error (calling C.GetLastError())
|
||||
// Message defaults to Win 32 API error message for the error code
|
||||
@[inline]
|
||||
@[inline; manualfree]
|
||||
pub fn error_win32(e SystemError) IError {
|
||||
$if windows {
|
||||
code := if e.code == error_code_not_set { int(C.GetLastError()) } else { e.code }
|
||||
|
|
|
@ -295,6 +295,7 @@ fn init_os_args(argc int, argv &&u8) []string {
|
|||
// }
|
||||
// }
|
||||
// ```
|
||||
@[manualfree]
|
||||
pub fn ls(path string) ![]string {
|
||||
if path == '' {
|
||||
return error('ls() expects a folder, not an empty string')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue