multiple fixes for latest zig

This commit is contained in:
Luna 2020-03-26 16:35:58 -03:00
parent fe7e347762
commit 8261d202bd
4 changed files with 16 additions and 12 deletions

View File

@ -94,7 +94,8 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 {
}
// if we fail to access it, we assume it doesn't exist and return it.
std.fs.File.access(nam) catch |err| {
_ = std.fs.cwd().openFile(nam, .{ .read = true, .write = false }) catch |err| {
if (err == error.FileNotFound) {
return nam;
}
@ -266,7 +267,7 @@ pub const Image = struct {
}
pub fn checkValid(self: *Image) !void {
var file = try std.fs.File.openRead(self.path);
var file = try std.fs.cwd().openFile(self.path, .{ .read = true });
defer file.close();
// main bmp header:
@ -413,7 +414,7 @@ pub const Image = struct {
pub fn saveTo(self: *Image, out_path: []const u8) !void {
std.debug.warn("\timg: copy from '{}' to '{}'\n", .{ self.curpath, out_path });
try std.fs.copyFile(self.curpath, out_path);
try std.fs.copyFileAbsolute(self.curpath, out_path, .{});
}
pub fn runCustomPlugin(

View File

@ -24,10 +24,10 @@ fn wrapInCmdList(allocator: *std.mem.Allocator, cmd: langs.Command) !langs.Comma
pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
var stdout_file = std.io.getStdOut();
const stdout = &stdout_file.outStream().stream;
const stdout = &stdout_file.outStream();
const scri_path = try (args_it.next(allocator) orelse @panic("expected scri path"));
var file_read_opt: ?std.fs.File = std.fs.File.openRead(scri_path) catch |err| blk: {
var file_read_opt: ?std.fs.File = std.fs.cwd().openFile(scri_path, .{}) catch |err| blk: {
if (err == error.FileNotFound) break :blk null;
return err;
};
@ -70,11 +70,14 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
file_read.close();
}
var file = try std.fs.File.openWrite(scri_path);
var file = try std.fs.cwd().openFile(scri_path, .{
.write = true,
.read = false,
});
defer file.close();
var out = file.outStream();
var stream = &out.stream;
var stream = &out;
// since we opened the file for writing, it becomes empty, so, to ensure
// we don't fuck up later on, we print cmds before starting the repl
@ -115,7 +118,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
readline.add_history(rd_line);
//defer std.heap.c_allocator.destroy(rd_line);
var line = rd_line[0..std.mem.len(u8, rd_line)];
var line = rd_line[0..std.mem.len(rd_line)];
if (std.mem.eql(u8, line, "push")) {
try cmds.append(current);
@ -161,7 +164,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
});
try runner_clone.runCommands(cmds_parsed, true);
try stdout.write("\n");
_ = try stdout.write("\n");
}
}
@ -185,7 +188,7 @@ pub fn main() !void {
return try doRepl(allocator, &args_it);
}
var file = try std.fs.File.openRead(scri_path);
var file = try std.fs.cwd().openFile(scri_path, .{});
defer file.close();
// sadly, we read it all into memory. such is life

View File

@ -51,6 +51,6 @@ pub fn printList(list: langs.CommandList, stream: var) !void {
try stream.print(" {}", .{arg});
}
try stream.write(";\n");
_ = try stream.write(";\n");
}
}

View File

@ -117,7 +117,7 @@ pub const Runner = struct {
const basename = std.fs.path.basename(image.path);
const dirname = std.fs.path.dirname(image.path).?;
var dir = try std.fs.Dir.open(dirname);
var dir = try std.fs.cwd().openDir(dirname, .{ .iterate = true });
defer dir.close();
const period_idx = std.mem.lastIndexOf(u8, basename, ".").?;