Skip to content

Commit

Permalink
zig fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jun 12, 2018
1 parent 3dd9af9 commit 7580e39
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion std/os/file.zig
Expand Up @@ -96,7 +96,7 @@ pub const File = struct {
return File{ .handle = handle };
}

pub const AccessError = error {
pub const AccessError = error{
PermissionDenied,
NotFound,
NameTooLong,
Expand Down
22 changes: 13 additions & 9 deletions std/os/index.zig
Expand Up @@ -734,7 +734,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path:
}
}

pub const DeleteFileError = error {
pub const DeleteFileError = error{
FileNotFound,
AccessDenied,
FileBusy,
Expand Down Expand Up @@ -1035,7 +1035,7 @@ pub fn makePath(allocator: *Allocator, full_path: []const u8) !void {
}
}

pub const DeleteDirError = error {
pub const DeleteDirError = error{
AccessDenied,
FileBusy,
SymLinkLoop,
Expand Down Expand Up @@ -1090,7 +1090,6 @@ pub fn deleteDir(allocator: *Allocator, dir_path: []const u8) DeleteDirError!voi
},
else => @compileError("unimplemented"),
}

}

/// Whether ::full_path describes a symlink, file, or directory, this function
Expand Down Expand Up @@ -1227,7 +1226,7 @@ pub const Dir = struct {
};
};

pub const OpenError = error {
pub const OpenError = error{
PathNotFound,
NotDir,
AccessDenied,
Expand All @@ -1253,13 +1252,13 @@ pub const Dir = struct {
Os.windows => blk: {
var find_file_data: windows.WIN32_FIND_DATAA = undefined;
const handle = try windows_util.windowsFindFirstFile(allocator, dir_path, &find_file_data);
break :blk Handle {
break :blk Handle{
.handle = handle,
.find_file_data = find_file_data, // TODO guaranteed copy elision
.first = true,
};
},
Os.macosx, Os.ios => Handle {
Os.macosx, Os.ios => Handle{
.fd = try posixOpen(
allocator,
dir_path,
Expand All @@ -1271,8 +1270,13 @@ pub const Dir = struct {
.end_index = 0,
.buf = []u8{},
},
Os.linux => Handle {
.fd = try posixOpen(allocator, dir_path, posix.O_RDONLY | posix.O_DIRECTORY | posix.O_CLOEXEC, 0,),
Os.linux => Handle{
.fd = try posixOpen(
allocator,
dir_path,
posix.O_RDONLY | posix.O_DIRECTORY | posix.O_CLOEXEC,
0,
),
.index = 0,
.end_index = 0,
.buf = []u8{},
Expand Down Expand Up @@ -1378,7 +1382,7 @@ pub const Dir = struct {
if (attrs & windows.FILE_ATTRIBUTE_NORMAL != 0) break :blk Entry.Kind.File;
break :blk Entry.Kind.Unknown;
};
return Entry {
return Entry{
.name = name,
.kind = kind,
};
Expand Down
2 changes: 1 addition & 1 deletion std/os/time.zig
Expand Up @@ -74,7 +74,7 @@ fn milliTimestampWindows() u64 {
const epoch_adj = epoch.windows * ms_per_s;

const ft64 = (u64(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
return @divFloor(ft64, hns_per_ms) - - epoch_adj;
return @divFloor(ft64, hns_per_ms) - -epoch_adj;
}

fn milliTimestampDarwin() u64 {
Expand Down
15 changes: 8 additions & 7 deletions std/os/windows/util.zig
Expand Up @@ -171,11 +171,12 @@ test "InvalidDll" {
};
}


pub fn windowsFindFirstFile(allocator: *mem.Allocator, dir_path: []const u8,
find_file_data: *windows.WIN32_FIND_DATAA) !windows.HANDLE
{
const wild_and_null = []u8{'\\', '*', 0};
pub fn windowsFindFirstFile(
allocator: *mem.Allocator,
dir_path: []const u8,
find_file_data: *windows.WIN32_FIND_DATAA,
) !windows.HANDLE {
const wild_and_null = []u8{ '\\', '*', 0 };
const path_with_wild_and_null = try allocator.alloc(u8, dir_path.len + wild_and_null.len);
defer allocator.free(path_with_wild_and_null);

Expand All @@ -195,7 +196,7 @@ pub fn windowsFindFirstFile(allocator: *mem.Allocator, dir_path: []const u8,
}

return handle;
}
}

/// Returns `true` if there was another file, `false` otherwise.
pub fn windowsFindNextFile(handle: windows.HANDLE, find_file_data: *windows.WIN32_FIND_DATAA) !bool {
Expand All @@ -207,4 +208,4 @@ pub fn windowsFindNextFile(handle: windows.HANDLE, find_file_data: *windows.WIN3
};
}
return true;
}
}

0 comments on commit 7580e39

Please sign in to comment.