diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-11-17 02:18:56 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-11-17 02:18:56 -0500 |
| commit | c21884e1d64e4193e03be4f3064917a26b34b142 (patch) | |
| tree | 91e09e1df556e260ea2f1b171eaa05bd30646e1f /src/os.cpp | |
| parent | 2928b01afc5f0d84669ac6a70eedab4117d805f3 (diff) | |
| parent | 704374e51294e14285b0b54030c1cb6154868098 (diff) | |
| download | zig-c21884e1d64e4193e03be4f3064917a26b34b142.tar.gz zig-c21884e1d64e4193e03be4f3064917a26b34b142.zip | |
Merge remote-tracking branch 'origin/master' into llvm8
Diffstat (limited to 'src/os.cpp')
| -rw-r--r-- | src/os.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/os.cpp b/src/os.cpp index f01a99fc23..5d43e73d8a 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -793,7 +793,7 @@ Error os_file_exists(Buf *full_path, bool *result) { } #if defined(ZIG_OS_POSIX) -static int os_exec_process_posix(const char *exe, ZigList<const char *> &args, +static Error os_exec_process_posix(const char *exe, ZigList<const char *> &args, Termination *term, Buf *out_stderr, Buf *out_stdout) { int stdin_pipe[2]; @@ -872,7 +872,7 @@ static int os_exec_process_posix(const char *exe, ZigList<const char *> &args, // LocalFree(messageBuffer); //} -static int os_exec_process_windows(const char *exe, ZigList<const char *> &args, +static Error os_exec_process_windows(const char *exe, ZigList<const char *> &args, Termination *term, Buf *out_stderr, Buf *out_stdout) { Buf command_line = BUF_INIT; @@ -983,7 +983,7 @@ static int os_exec_process_windows(const char *exe, ZigList<const char *> &args, CloseHandle(piProcInfo.hProcess); CloseHandle(piProcInfo.hThread); - return 0; + return ErrorNone; } #endif @@ -1003,7 +1003,7 @@ Error os_execv(const char *exe, const char **argv) { #endif } -int os_exec_process(const char *exe, ZigList<const char *> &args, +Error os_exec_process(const char *exe, ZigList<const char *> &args, Termination *term, Buf *out_stderr, Buf *out_stdout) { #if defined(ZIG_OS_WINDOWS) @@ -1027,7 +1027,7 @@ void os_write_file(Buf *full_path, Buf *contents) { zig_panic("close failed"); } -int os_copy_file(Buf *src_path, Buf *dest_path) { +Error os_copy_file(Buf *src_path, Buf *dest_path) { FILE *src_f = fopen(buf_ptr(src_path), "rb"); if (!src_f) { int err = errno; @@ -1074,7 +1074,7 @@ int os_copy_file(Buf *src_path, Buf *dest_path) { if (feof(src_f)) { fclose(src_f); fclose(dest_f); - return 0; + return ErrorNone; } } } @@ -1128,9 +1128,6 @@ Error os_get_cwd(Buf *out_cwd) { #define is_wprefix(s, prefix) \ (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0) static bool is_stderr_cyg_pty(void) { -#if defined(__MINGW32__) - return false; -#else HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE); if (stderr_handle == INVALID_HANDLE_VALUE) return false; @@ -1182,7 +1179,6 @@ static bool is_stderr_cyg_pty(void) { } free(nameinfo); return (p != NULL); -#endif } #endif @@ -1197,7 +1193,7 @@ bool os_stderr_tty(void) { } #if defined(ZIG_OS_POSIX) -static int os_buf_to_tmp_file_posix(Buf *contents, Buf *suffix, Buf *out_tmp_path) { +static Error os_buf_to_tmp_file_posix(Buf *contents, Buf *suffix, Buf *out_tmp_path) { const char *tmp_dir = getenv("TMPDIR"); if (!tmp_dir) { tmp_dir = P_tmpdir; @@ -1221,12 +1217,12 @@ static int os_buf_to_tmp_file_posix(Buf *contents, Buf *suffix, Buf *out_tmp_pat if (fclose(f)) zig_panic("close failed"); - return 0; + return ErrorNone; } #endif #if defined(ZIG_OS_WINDOWS) -static int os_buf_to_tmp_file_windows(Buf *contents, Buf *suffix, Buf *out_tmp_path) { +static Error os_buf_to_tmp_file_windows(Buf *contents, Buf *suffix, Buf *out_tmp_path) { char tmp_dir[MAX_PATH + 1]; if (GetTempPath(MAX_PATH, tmp_dir) == 0) { zig_panic("GetTempPath failed"); @@ -1255,11 +1251,11 @@ static int os_buf_to_tmp_file_windows(Buf *contents, Buf *suffix, Buf *out_tmp_p if (fclose(f)) { zig_panic("fclose failed"); } - return 0; + return ErrorNone; } #endif -int os_buf_to_tmp_file(Buf *contents, Buf *suffix, Buf *out_tmp_path) { +Error os_buf_to_tmp_file(Buf *contents, Buf *suffix, Buf *out_tmp_path) { #if defined(ZIG_OS_WINDOWS) return os_buf_to_tmp_file_windows(contents, suffix, out_tmp_path); #elif defined(ZIG_OS_POSIX) @@ -1269,17 +1265,17 @@ int os_buf_to_tmp_file(Buf *contents, Buf *suffix, Buf *out_tmp_path) { #endif } -int os_delete_file(Buf *path) { +Error os_delete_file(Buf *path) { if (remove(buf_ptr(path))) { return ErrorFileSystem; } else { - return 0; + return ErrorNone; } } -int os_rename(Buf *src_path, Buf *dest_path) { +Error os_rename(Buf *src_path, Buf *dest_path) { if (buf_eql_buf(src_path, dest_path)) { - return 0; + return ErrorNone; } #if defined(ZIG_OS_WINDOWS) if (!MoveFileExA(buf_ptr(src_path), buf_ptr(dest_path), MOVEFILE_REPLACE_EXISTING)) { @@ -1290,7 +1286,7 @@ int os_rename(Buf *src_path, Buf *dest_path) { return ErrorFileSystem; } #endif - return 0; + return ErrorNone; } double os_get_time(void) { @@ -1540,7 +1536,7 @@ int os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_Arch buf_append_str(output_buf, "arm\\"); break; default: - zig_panic("Attemped to use vcruntime for non-supported platform."); + zig_panic("Attempted to use vcruntime for non-supported platform."); } Buf* tmp_buf = buf_alloc(); buf_init_from_buf(tmp_buf, output_buf); @@ -1589,7 +1585,7 @@ int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchTy buf_append_str(output_buf, "arm\\"); break; default: - zig_panic("Attemped to use vcruntime for non-supported platform."); + zig_panic("Attempted to use vcruntime for non-supported platform."); } Buf* tmp_buf = buf_alloc(); buf_init_from_buf(tmp_buf, output_buf); @@ -1612,7 +1608,7 @@ int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchTy buf_append_str(output_buf, "arm\\"); break; default: - zig_panic("Attemped to use vcruntime for non-supported platform."); + zig_panic("Attempted to use vcruntime for non-supported platform."); } Buf* tmp_buf = buf_alloc(); buf_init_from_buf(tmp_buf, output_buf); |
