authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-12 02:18:11-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-12 02:18:11-04:00
log7580e39b388525237a84aabfb41c462376eac28e
tree32ed7e22da2c9cabddcf6abf312f0357f652deab
parent3dd9af9948db696362aa5f41481dc4cb034bc6c2

zig fmt


4 files changed, 23 insertions(+), 18 deletions(-)

std/os/file.zig+1-1
...@@ -96,7 +96,7 @@ pub const File = struct {...@@ -96,7 +96,7 @@ pub const File = struct {
96 return File{ .handle = handle };96 return File{ .handle = handle };
97 }97 }
9898
99 pub const AccessError = error {99 pub const AccessError = error{
100 PermissionDenied,100 PermissionDenied,
101 NotFound,101 NotFound,
102 NameTooLong,102 NameTooLong,
std/os/index.zig+13-9
...@@ -734,7 +734,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path:...@@ -734,7 +734,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path:
734 }734 }
735}735}
736736
737pub const DeleteFileError = error {737pub const DeleteFileError = error{
738 FileNotFound,738 FileNotFound,
739 AccessDenied,739 AccessDenied,
740 FileBusy,740 FileBusy,
...@@ -1035,7 +1035,7 @@ pub fn makePath(allocator: *Allocator, full_path: []const u8) !void {...@@ -1035,7 +1035,7 @@ pub fn makePath(allocator: *Allocator, full_path: []const u8) !void {
1035 }1035 }
1036}1036}
10371037
1038pub const DeleteDirError = error {1038pub const DeleteDirError = error{
1039 AccessDenied,1039 AccessDenied,
1040 FileBusy,1040 FileBusy,
1041 SymLinkLoop,1041 SymLinkLoop,
...@@ -1090,7 +1090,6 @@ pub fn deleteDir(allocator: *Allocator, dir_path: []const u8) DeleteDirError!voi...@@ -1090,7 +1090,6 @@ pub fn deleteDir(allocator: *Allocator, dir_path: []const u8) DeleteDirError!voi
1090 },1090 },
1091 else => @compileError("unimplemented"),1091 else => @compileError("unimplemented"),
1092 }1092 }
1093
1094}1093}
10951094
1096/// Whether ::full_path describes a symlink, file, or directory, this function1095/// Whether ::full_path describes a symlink, file, or directory, this function
...@@ -1227,7 +1226,7 @@ pub const Dir = struct {...@@ -1227,7 +1226,7 @@ pub const Dir = struct {
1227 };1226 };
1228 };1227 };
12291228
1230 pub const OpenError = error {1229 pub const OpenError = error{
1231 PathNotFound,1230 PathNotFound,
1232 NotDir,1231 NotDir,
1233 AccessDenied,1232 AccessDenied,
...@@ -1253,13 +1252,13 @@ pub const Dir = struct {...@@ -1253,13 +1252,13 @@ pub const Dir = struct {
1253 Os.windows => blk: {1252 Os.windows => blk: {
1254 var find_file_data: windows.WIN32_FIND_DATAA = undefined;1253 var find_file_data: windows.WIN32_FIND_DATAA = undefined;
1255 const handle = try windows_util.windowsFindFirstFile(allocator, dir_path, &find_file_data);1254 const handle = try windows_util.windowsFindFirstFile(allocator, dir_path, &find_file_data);
1256 break :blk Handle {1255 break :blk Handle{
1257 .handle = handle,1256 .handle = handle,
1258 .find_file_data = find_file_data, // TODO guaranteed copy elision1257 .find_file_data = find_file_data, // TODO guaranteed copy elision
1259 .first = true,1258 .first = true,
1260 };1259 };
1261 },1260 },
1262 Os.macosx, Os.ios => Handle {1261 Os.macosx, Os.ios => Handle{
1263 .fd = try posixOpen(1262 .fd = try posixOpen(
1264 allocator,1263 allocator,
1265 dir_path,1264 dir_path,
...@@ -1271,8 +1270,13 @@ pub const Dir = struct {...@@ -1271,8 +1270,13 @@ pub const Dir = struct {
1271 .end_index = 0,1270 .end_index = 0,
1272 .buf = []u8{},1271 .buf = []u8{},
1273 },1272 },
1274 Os.linux => Handle {1273 Os.linux => Handle{
1275 .fd = try posixOpen(allocator, dir_path, posix.O_RDONLY | posix.O_DIRECTORY | posix.O_CLOEXEC, 0,),1274 .fd = try posixOpen(
1275 allocator,
1276 dir_path,
1277 posix.O_RDONLY | posix.O_DIRECTORY | posix.O_CLOEXEC,
1278 0,
1279 ),
1276 .index = 0,1280 .index = 0,
1277 .end_index = 0,1281 .end_index = 0,
1278 .buf = []u8{},1282 .buf = []u8{},
...@@ -1378,7 +1382,7 @@ pub const Dir = struct {...@@ -1378,7 +1382,7 @@ pub const Dir = struct {
1378 if (attrs & windows.FILE_ATTRIBUTE_NORMAL != 0) break :blk Entry.Kind.File;1382 if (attrs & windows.FILE_ATTRIBUTE_NORMAL != 0) break :blk Entry.Kind.File;
1379 break :blk Entry.Kind.Unknown;1383 break :blk Entry.Kind.Unknown;
1380 };1384 };
1381 return Entry {1385 return Entry{
1382 .name = name,1386 .name = name,
1383 .kind = kind,1387 .kind = kind,
1384 };1388 };
std/os/time.zig+1-1
...@@ -74,7 +74,7 @@ fn milliTimestampWindows() u64 {...@@ -74,7 +74,7 @@ fn milliTimestampWindows() u64 {
74 const epoch_adj = epoch.windows * ms_per_s;74 const epoch_adj = epoch.windows * ms_per_s;
7575
76 const ft64 = (u64(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;76 const ft64 = (u64(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
77 return @divFloor(ft64, hns_per_ms) - - epoch_adj;77 return @divFloor(ft64, hns_per_ms) - -epoch_adj;
78}78}
7979
80fn milliTimestampDarwin() u64 {80fn milliTimestampDarwin() u64 {
std/os/windows/util.zig+8-7
...@@ -171,11 +171,12 @@ test "InvalidDll" {...@@ -171,11 +171,12 @@ test "InvalidDll" {
171 };171 };
172}172}
173173
174174pub fn windowsFindFirstFile(
175pub fn windowsFindFirstFile(allocator: *mem.Allocator, dir_path: []const u8,175 allocator: *mem.Allocator,
176 find_file_data: *windows.WIN32_FIND_DATAA) !windows.HANDLE176 dir_path: []const u8,
177{177 find_file_data: *windows.WIN32_FIND_DATAA,
178 const wild_and_null = []u8{'\\', '*', 0};178) !windows.HANDLE {
179 const wild_and_null = []u8{ '\\', '*', 0 };
179 const path_with_wild_and_null = try allocator.alloc(u8, dir_path.len + wild_and_null.len);180 const path_with_wild_and_null = try allocator.alloc(u8, dir_path.len + wild_and_null.len);
180 defer allocator.free(path_with_wild_and_null);181 defer allocator.free(path_with_wild_and_null);
181182
...@@ -195,7 +196,7 @@ pub fn windowsFindFirstFile(allocator: *mem.Allocator, dir_path: []const u8,...@@ -195,7 +196,7 @@ pub fn windowsFindFirstFile(allocator: *mem.Allocator, dir_path: []const u8,
195 }196 }
196197
197 return handle;198 return handle;
198} 199}
199200
200/// Returns `true` if there was another file, `false` otherwise.201/// Returns `true` if there was another file, `false` otherwise.
201pub fn windowsFindNextFile(handle: windows.HANDLE, find_file_data: *windows.WIN32_FIND_DATAA) !bool {202pub fn windowsFindNextFile(handle: windows.HANDLE, find_file_data: *windows.WIN32_FIND_DATAA) !bool {
...@@ -207,4 +208,4 @@ pub fn windowsFindNextFile(handle: windows.HANDLE, find_file_data: *windows.WIN3...@@ -207,4 +208,4 @@ pub fn windowsFindNextFile(handle: windows.HANDLE, find_file_data: *windows.WIN3
207 };208 };
208 }209 }
209 return true;210 return true;
210} 211}