authorgravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2019-08-01 18:27:39-05:00
committergravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2019-08-02 19:39:33-05:00
log102d3f30c406e2818c6320a48f2405fa7e1e4237
tree975dd34f14528cff0bd57fa2fc8e08479a11ccff
parentf15ec9a59b777a2b7998518858f11f5da0dfcb2d

accept unix style paths on windows-gnu


4 files changed, 13 insertions(+), 9 deletions(-)

src/os.cpp+4-4
......@@ -1130,7 +1130,7 @@ Error os_get_cwd(Buf *out_cwd) {
11301130bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) {
11311131#if defined(ZIG_OS_WINDOWS)
11321132 HANDLE handle = (HANDLE)_get_osfhandle(fd);
1133
1133
11341134 // Cygwin/msys's pty is a pipe.
11351135 if (handle == INVALID_HANDLE_VALUE || GetFileType(handle) != FILE_TYPE_PIPE) {
11361136 return false;
......@@ -1138,7 +1138,7 @@ bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) {
11381138
11391139 int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * MAX_PATH;
11401140 WCHAR *p = NULL;
1141
1141
11421142 FILE_NAME_INFO *nameinfo = (FILE_NAME_INFO *)allocate<char>(size);
11431143 if (nameinfo == NULL) {
11441144 return false;
......@@ -1179,13 +1179,13 @@ bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) {
11791179 free(nameinfo);
11801180 return (p != NULL);
11811181#else
1182 return false
1182 return false;
11831183#endif
11841184}
11851185
11861186bool os_stderr_tty(void) {
11871187#if defined(ZIG_OS_WINDOWS)
1188 return _isatty(_fileno(stderr)) != 0 || os_is_cygwin_pty(_fileno(stderr));
1188 return _isatty(fileno(stderr)) != 0 || os_is_cygwin_pty(fileno(stderr));
11891189#elif defined(ZIG_OS_POSIX)
11901190 return isatty(STDERR_FILENO) != 0;
11911191#else
src/os.hpp+5
......@@ -89,6 +89,11 @@ struct Termination {
8989#define OsFile int
9090#endif
9191
92#if defined(ZIG_OS_WINDOWS)
93#undef fileno
94#define fileno _fileno
95#endif
96
9297struct OsTimeStamp {
9398 uint64_t sec;
9499 uint64_t nsec;
src/target.cpp+1-1
......@@ -1507,7 +1507,7 @@ bool target_is_single_threaded(const ZigTarget *target) {
15071507static ZigLLVM_EnvironmentType target_get_win32_abi() {
15081508 FILE* files[] = { stdin, stdout, stderr, nullptr };
15091509 for (int i = 0; files[i] != nullptr; i++) {
1510 if (os_is_cygwin_pty(_fileno(files[i]))) {
1510 if (os_is_cygwin_pty(fileno(files[i]))) {
15111511 return ZigLLVM_GNU;
15121512 }
15131513 }
std/os/windows.zig+3-4
......@@ -65,7 +65,7 @@ pub const CreateFileError = error{
6565 InvalidUtf8,
6666
6767 /// On Windows, file paths cannot contain these characters:
68 /// '/', '*', '?', '"', '<', '>', '|'
68 /// '*', '?', '"', '<', '>', '|', and '/' (when the ABI is not GNU)
6969 BadPathName,
7070
7171 Unexpected,
......@@ -831,8 +831,8 @@ pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16)
831831 // disallow forward slashes in zig std lib file functions on Windows.
832832 for (s) |byte| {
833833 switch (byte) {
834 '/', '*', '?', '"', '<', '>', '|' => return error.BadPathName,
835 else => {},
834 '*', '?', '"', '<', '>', '|' => return error.BadPathName,
835 else => if (builtin.abi == .msvc and byte == '/') return error.BadPathName,
836836 }
837837 }
838838 const start_index = if (mem.startsWith(u8, s, "\\\\") or !std.fs.path.isAbsolute(s)) 0 else blk: {
......@@ -866,7 +866,6 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError {
866866 return error.Unexpected;
867867}
868868
869
870869/// Call this when you made a windows NtDll call
871870/// and you get an unexpected status.
872871pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError {