diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-11-10 15:01:09 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-11-10 15:01:09 -0500 |
| commit | 6bf1547148caf0c63605a42c8cdea608cf3d4eca (patch) | |
| tree | 518cb47a9dab91cfb7e7d9491cfe97ed59895d87 /std/os | |
| parent | 336d81894da2c34a77cffd1bf903ad9e4dcaa7aa (diff) | |
| parent | 029d37d6a7dc96f71dded5d5a9c8e7477aaa4146 (diff) | |
| download | zig-6bf1547148caf0c63605a42c8cdea608cf3d4eca.tar.gz zig-6bf1547148caf0c63605a42c8cdea608cf3d4eca.zip | |
Merge branch 'darwin-stat'
closes #606
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/darwin.zig | 2 | ||||
| -rw-r--r-- | std/os/index.zig | 7 | ||||
| -rw-r--r-- | std/os/path.zig | 32 | ||||
| -rw-r--r-- | std/os/windows/index.zig | 3 |
4 files changed, 23 insertions, 21 deletions
diff --git a/std/os/darwin.zig b/std/os/darwin.zig index 04c72f71c4..9d80c64006 100644 --- a/std/os/darwin.zig +++ b/std/os/darwin.zig @@ -129,7 +129,7 @@ pub fn isatty(fd: i32) -> bool { } pub fn fstat(fd: i32, buf: &c.Stat) -> usize { - errnoWrap(c.fstat(fd, buf)) + errnoWrap(c.@"fstat$INODE64"(fd, buf)) } pub fn lseek(fd: i32, offset: isize, whence: c_int) -> usize { diff --git a/std/os/index.zig b/std/os/index.zig index 58bfe611cc..c3f33c4ccd 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -562,7 +562,7 @@ pub fn getCwd(allocator: &Allocator) -> %[]u8 { test "os.getCwd" { // at least call it so it gets compiled - _ = getCwd(&debug.global_allocator); + _ = getCwd(debug.global_allocator); } pub fn symLink(allocator: &Allocator, existing_path: []const u8, new_path: []const u8) -> %void { @@ -1432,10 +1432,10 @@ test "windows arg parsing" { fn testWindowsCmdLine(input_cmd_line: &const u8, expected_args: []const []const u8) { var it = ArgIteratorWindows.initWithCmdLine(input_cmd_line); for (expected_args) |expected_arg| { - const arg = %%??it.next(&debug.global_allocator); + const arg = %%??it.next(debug.global_allocator); assert(mem.eql(u8, arg, expected_arg)); } - assert(it.next(&debug.global_allocator) == null); + assert(it.next(debug.global_allocator) == null); } test "std.os" { @@ -1500,4 +1500,3 @@ pub fn isTty(handle: FileHandle) -> bool { } } } - diff --git a/std/os/path.zig b/std/os/path.zig index 9a7b6b139e..a372b5b077 100644 --- a/std/os/path.zig +++ b/std/os/path.zig @@ -41,23 +41,23 @@ pub fn joinPosix(allocator: &Allocator, paths: ...) -> %[]u8 { } test "os.path.join" { - assert(mem.eql(u8, %%joinWindows(&debug.global_allocator, "c:\\a\\b", "c"), "c:\\a\\b\\c")); - assert(mem.eql(u8, %%joinWindows(&debug.global_allocator, "c:\\a\\b\\", "c"), "c:\\a\\b\\c")); + assert(mem.eql(u8, %%joinWindows(debug.global_allocator, "c:\\a\\b", "c"), "c:\\a\\b\\c")); + assert(mem.eql(u8, %%joinWindows(debug.global_allocator, "c:\\a\\b\\", "c"), "c:\\a\\b\\c")); - assert(mem.eql(u8, %%joinWindows(&debug.global_allocator, "c:\\", "a", "b\\", "c"), "c:\\a\\b\\c")); - assert(mem.eql(u8, %%joinWindows(&debug.global_allocator, "c:\\a\\", "b\\", "c"), "c:\\a\\b\\c")); + assert(mem.eql(u8, %%joinWindows(debug.global_allocator, "c:\\", "a", "b\\", "c"), "c:\\a\\b\\c")); + assert(mem.eql(u8, %%joinWindows(debug.global_allocator, "c:\\a\\", "b\\", "c"), "c:\\a\\b\\c")); - assert(mem.eql(u8, %%joinWindows(&debug.global_allocator, + assert(mem.eql(u8, %%joinWindows(debug.global_allocator, "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig"), "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig")); - assert(mem.eql(u8, %%joinPosix(&debug.global_allocator, "/a/b", "c"), "/a/b/c")); - assert(mem.eql(u8, %%joinPosix(&debug.global_allocator, "/a/b/", "c"), "/a/b/c")); + assert(mem.eql(u8, %%joinPosix(debug.global_allocator, "/a/b", "c"), "/a/b/c")); + assert(mem.eql(u8, %%joinPosix(debug.global_allocator, "/a/b/", "c"), "/a/b/c")); - assert(mem.eql(u8, %%joinPosix(&debug.global_allocator, "/", "a", "b/", "c"), "/a/b/c")); - assert(mem.eql(u8, %%joinPosix(&debug.global_allocator, "/a/", "b/", "c"), "/a/b/c")); + assert(mem.eql(u8, %%joinPosix(debug.global_allocator, "/", "a", "b/", "c"), "/a/b/c")); + assert(mem.eql(u8, %%joinPosix(debug.global_allocator, "/a/", "b/", "c"), "/a/b/c")); - assert(mem.eql(u8, %%joinPosix(&debug.global_allocator, "/home/andy/dev/zig/build/lib/zig/std", "io.zig"), + assert(mem.eql(u8, %%joinPosix(debug.global_allocator, "/home/andy/dev/zig/build/lib/zig/std", "io.zig"), "/home/andy/dev/zig/build/lib/zig/std/io.zig")); } @@ -453,7 +453,7 @@ pub fn resolvePosix(allocator: &Allocator, paths: []const []const u8) -> %[]u8 { } test "os.path.resolve" { - const cwd = %%os.getCwd(&debug.global_allocator); + const cwd = %%os.getCwd(debug.global_allocator); if (is_windows) { assert(mem.eql(u8, testResolveWindows([][]const u8{"."}), cwd)); } else { @@ -492,11 +492,11 @@ test "os.path.resolvePosix" { } fn testResolveWindows(paths: []const []const u8) -> []u8 { - return %%resolveWindows(&debug.global_allocator, paths); + return %%resolveWindows(debug.global_allocator, paths); } fn testResolvePosix(paths: []const []const u8) -> []u8 { - return %%resolvePosix(&debug.global_allocator, paths); + return %%resolvePosix(debug.global_allocator, paths); } pub fn dirname(path: []const u8) -> []const u8 { @@ -899,12 +899,12 @@ test "os.path.relative" { } fn testRelativePosix(from: []const u8, to: []const u8, expected_output: []const u8) { - const result = %%relativePosix(&debug.global_allocator, from, to); + const result = %%relativePosix(debug.global_allocator, from, to); assert(mem.eql(u8, result, expected_output)); } fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []const u8) { - const result = %%relativeWindows(&debug.global_allocator, from, to); + const result = %%relativeWindows(debug.global_allocator, from, to); assert(mem.eql(u8, result, expected_output)); } @@ -1022,5 +1022,5 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { test "os.path.real" { // at least call it so it gets compiled - _ = real(&debug.global_allocator, "some_path"); + _ = real(debug.global_allocator, "some_path"); } diff --git a/std/os/windows/index.zig b/std/os/windows/index.zig index a398deb0b3..913cc79801 100644 --- a/std/os/windows/index.zig +++ b/std/os/windows/index.zig @@ -46,6 +46,8 @@ pub extern "kernel32" stdcallcc fn GetEnvironmentVariableA(lpName: LPCSTR, lpBuf pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: &DWORD) -> BOOL; +pub extern "kernel32" stdcallcc fn GetFileSizeEx(hFile: HANDLE, lpFileSize: &LARGE_INTEGER) -> BOOL; + pub extern "kernel32" stdcallcc fn GetLastError() -> DWORD; pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(in_hFile: HANDLE, @@ -115,6 +117,7 @@ pub const ULONG_PTR = usize; pub const UNICODE = false; pub const WCHAR = u16; pub const WORD = u16; +pub const LARGE_INTEGER = i64; pub const TRUE = 1; pub const FALSE = 0; |
