multiple fixes for latest zig
This commit is contained in:
parent
fe7e347762
commit
8261d202bd
4 changed files with 16 additions and 12 deletions
|
@ -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.
|
// 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) {
|
if (err == error.FileNotFound) {
|
||||||
return nam;
|
return nam;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +267,7 @@ pub const Image = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checkValid(self: *Image) !void {
|
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();
|
defer file.close();
|
||||||
|
|
||||||
// main bmp header:
|
// main bmp header:
|
||||||
|
@ -413,7 +414,7 @@ pub const Image = struct {
|
||||||
|
|
||||||
pub fn saveTo(self: *Image, out_path: []const u8) !void {
|
pub fn saveTo(self: *Image, out_path: []const u8) !void {
|
||||||
std.debug.warn("\timg: copy from '{}' to '{}'\n", .{ self.curpath, out_path });
|
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(
|
pub fn runCustomPlugin(
|
||||||
|
|
17
src/main.zig
17
src/main.zig
|
@ -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 {
|
pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
var stdout_file = std.io.getStdOut();
|
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"));
|
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;
|
if (err == error.FileNotFound) break :blk null;
|
||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
|
@ -70,11 +70,14 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
file_read.close();
|
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();
|
defer file.close();
|
||||||
|
|
||||||
var out = file.outStream();
|
var out = file.outStream();
|
||||||
var stream = &out.stream;
|
var stream = &out;
|
||||||
|
|
||||||
// since we opened the file for writing, it becomes empty, so, to ensure
|
// 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
|
// 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);
|
readline.add_history(rd_line);
|
||||||
//defer std.heap.c_allocator.destroy(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")) {
|
if (std.mem.eql(u8, line, "push")) {
|
||||||
try cmds.append(current);
|
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 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);
|
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();
|
defer file.close();
|
||||||
|
|
||||||
// sadly, we read it all into memory. such is life
|
// sadly, we read it all into memory. such is life
|
||||||
|
|
|
@ -51,6 +51,6 @@ pub fn printList(list: langs.CommandList, stream: var) !void {
|
||||||
try stream.print(" {}", .{arg});
|
try stream.print(" {}", .{arg});
|
||||||
}
|
}
|
||||||
|
|
||||||
try stream.write(";\n");
|
_ = try stream.write(";\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ pub const Runner = struct {
|
||||||
const basename = std.fs.path.basename(image.path);
|
const basename = std.fs.path.basename(image.path);
|
||||||
const dirname = std.fs.path.dirname(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();
|
defer dir.close();
|
||||||
|
|
||||||
const period_idx = std.mem.lastIndexOf(u8, basename, ".").?;
|
const period_idx = std.mem.lastIndexOf(u8, basename, ".").?;
|
||||||
|
|
Loading…
Reference in a new issue