mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
accept unix style paths on windows-gnu
This commit is contained in:
parent
f15ec9a59b
commit
102d3f30c4
@ -1130,7 +1130,7 @@ Error os_get_cwd(Buf *out_cwd) {
|
||||
bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) {
|
||||
#if defined(ZIG_OS_WINDOWS)
|
||||
HANDLE handle = (HANDLE)_get_osfhandle(fd);
|
||||
|
||||
|
||||
// Cygwin/msys's pty is a pipe.
|
||||
if (handle == INVALID_HANDLE_VALUE || GetFileType(handle) != FILE_TYPE_PIPE) {
|
||||
return false;
|
||||
@ -1138,7 +1138,7 @@ bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) {
|
||||
|
||||
int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * MAX_PATH;
|
||||
WCHAR *p = NULL;
|
||||
|
||||
|
||||
FILE_NAME_INFO *nameinfo = (FILE_NAME_INFO *)allocate<char>(size);
|
||||
if (nameinfo == NULL) {
|
||||
return false;
|
||||
@ -1179,13 +1179,13 @@ bool ATTRIBUTE_MUST_USE os_is_cygwin_pty(int fd) {
|
||||
free(nameinfo);
|
||||
return (p != NULL);
|
||||
#else
|
||||
return false
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool os_stderr_tty(void) {
|
||||
#if defined(ZIG_OS_WINDOWS)
|
||||
return _isatty(_fileno(stderr)) != 0 || os_is_cygwin_pty(_fileno(stderr));
|
||||
return _isatty(fileno(stderr)) != 0 || os_is_cygwin_pty(fileno(stderr));
|
||||
#elif defined(ZIG_OS_POSIX)
|
||||
return isatty(STDERR_FILENO) != 0;
|
||||
#else
|
||||
|
||||
@ -89,6 +89,11 @@ struct Termination {
|
||||
#define OsFile int
|
||||
#endif
|
||||
|
||||
#if defined(ZIG_OS_WINDOWS)
|
||||
#undef fileno
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
|
||||
struct OsTimeStamp {
|
||||
uint64_t sec;
|
||||
uint64_t nsec;
|
||||
|
||||
@ -1507,7 +1507,7 @@ bool target_is_single_threaded(const ZigTarget *target) {
|
||||
static ZigLLVM_EnvironmentType target_get_win32_abi() {
|
||||
FILE* files[] = { stdin, stdout, stderr, nullptr };
|
||||
for (int i = 0; files[i] != nullptr; i++) {
|
||||
if (os_is_cygwin_pty(_fileno(files[i]))) {
|
||||
if (os_is_cygwin_pty(fileno(files[i]))) {
|
||||
return ZigLLVM_GNU;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ pub const CreateFileError = error{
|
||||
InvalidUtf8,
|
||||
|
||||
/// On Windows, file paths cannot contain these characters:
|
||||
/// '/', '*', '?', '"', '<', '>', '|'
|
||||
/// '*', '?', '"', '<', '>', '|', and '/' (when the ABI is not GNU)
|
||||
BadPathName,
|
||||
|
||||
Unexpected,
|
||||
@ -831,8 +831,8 @@ pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16)
|
||||
// disallow forward slashes in zig std lib file functions on Windows.
|
||||
for (s) |byte| {
|
||||
switch (byte) {
|
||||
'/', '*', '?', '"', '<', '>', '|' => return error.BadPathName,
|
||||
else => {},
|
||||
'*', '?', '"', '<', '>', '|' => return error.BadPathName,
|
||||
else => if (builtin.abi == .msvc and byte == '/') return error.BadPathName,
|
||||
}
|
||||
}
|
||||
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 {
|
||||
return error.Unexpected;
|
||||
}
|
||||
|
||||
|
||||
/// Call this when you made a windows NtDll call
|
||||
/// and you get an unexpected status.
|
||||
pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user