Function createFileW [src]

Same as createFile but Windows-only and the path parameter is WTF-16 encoded.

Prototype

pub fn createFileW(self: Dir, sub_path_w: []const u16, flags: File.CreateFlags) File.OpenError!File

Parameters

self: Dirsub_path_w: []const u16flags: File.CreateFlags

Source

pub fn createFileW(self: Dir, sub_path_w: []const u16, flags: File.CreateFlags) File.OpenError!File { const w = windows; const read_flag = if (flags.read) @as(u32, w.GENERIC_READ) else 0; const file: File = .{ .handle = try w.OpenFile(sub_path_w, .{ .dir = self.fd, .access_mask = w.SYNCHRONIZE | w.GENERIC_WRITE | read_flag, .creation = if (flags.exclusive) @as(u32, w.FILE_CREATE) else if (flags.truncate) @as(u32, w.FILE_OVERWRITE_IF) else @as(u32, w.FILE_OPEN_IF), }), }; errdefer file.close(); var io: w.IO_STATUS_BLOCK = undefined; const range_off: w.LARGE_INTEGER = 0; const range_len: w.LARGE_INTEGER = 1; const exclusive = switch (flags.lock) { .none => return file, .shared => false, .exclusive => true, }; try w.LockFile( file.handle, null, null, null, &io, &range_off, &range_len, null, @intFromBool(flags.lock_nonblocking), @intFromBool(exclusive), ); return file; }