summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/dump.zig b/src/dump.zig
index 6bdfb7d4..a35a9fab 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -54,7 +54,6 @@ fn uniqueIn(buf: *[1024:0]u8, dir: []const u8, base: []const u8) ?[:0]const u8 {
std.fmt.bufPrintSentinel(buf, "{s}/{s}.dump", .{ dir, base }, 0)
else
std.fmt.bufPrintSentinel(buf, "{s}/{s}-{d}.dump", .{ dir, base, n }, 0)) catch return null;
- if (comptime !pardes.hosted) return path;
if (std.c.access(path.ptr, std.c.F_OK) != 0) return path;
}
return null;
@@ -72,10 +71,8 @@ test "two dumps in one second get names of their own" {
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pardes-x.dump", .data = "" });
try std.testing.expect(std.mem.endsWith(u8, uniqueIn(&buf, dir, "pardes-x").?, "/pardes-x-2.dump"));
}
-/// The host's environment; a freestanding core (the web's) has none
-/// and no libc to ask, so only a DumpDir with no `~/` names a directory there.
+/// The host's environment.
fn hostEnv(name: [*:0]const u8) ?[*:0]u8 {
- if (builtin.os.tag == .freestanding) return null;
return std.c.getenv(name);
}
@@ -90,8 +87,7 @@ pub fn directory(buf: []u8, dir_setting: []const u8) ?[]const u8 {
var fba_buf: [4096]u8 = undefined;
var fba = std.heap.FixedBufferAllocator.init(&fba_buf);
var cwd_buf: [1024]u8 = undefined;
- // No libc on the web: there a relative one is from `/`.
- const cwd: []const u8 = if (comptime !pardes.hosted) "/" else if (std.fs.path.isAbsolute(raw)) "/" else if (std.c.getcwd(&cwd_buf, cwd_buf.len)) |c| std.mem.span(@as([*:0]const u8, @ptrCast(c))) else "/";
+ const cwd: []const u8 = if (std.fs.path.isAbsolute(raw)) "/" else if (std.c.getcwd(&cwd_buf, cwd_buf.len)) |c| std.mem.span(@as([*:0]const u8, @ptrCast(c))) else "/";
const resolved = std.fs.path.resolvePosix(fba.allocator(), &.{ cwd, raw }) catch return null;
return std.fmt.bufPrint(buf, "{s}", .{resolved}) catch null;
}
@@ -157,7 +153,6 @@ const SessionLoad = walk.Load(&.{ Pardes, []const filesystem.Mount, OnDisk, []co
const OnDisk = [MAX_PANES]bool;
fn onDisk(pane: *const pardes.panes.Pane) bool {
- if (comptime !pardes.hosted) return false;
const f = pane.file orelse return false;
if (f.output != null) return false;
const local = filesystem.localPath(f.path) orelse return false;
@@ -464,13 +459,13 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool
if (pane.terminal != null) {
// A command pane comes back finished, showing what it said: its
// command is not run again. A host that runs shells starts one
- // under the history in the old one's directory; the web shell and
- // an isolated build only show it.
+ // under the history in the old one's directory; an isolated build
+ // only shows it.
if (pane.command != null) {
pane.command_done = true;
return;
}
- if (comptime platform == .web or isolated) return;
+ if (comptime isolated) return;
if (pane.cwdSlice().len > effect_path_cap) return;
pardes.panes.terminal.reviveShell(pane);
p.emitSpawn(id, pane.serial, pane.cwdSlice());
@@ -489,8 +484,7 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool
// Its file gone from disk since the dump: its text is nowhere else, so
// it is said deleted, and Del, Exit and Restore ask first. One never on
// disk (a name not yet saved) comes back as it was.
- // (A host with no disk of its own, the web's, asks nothing.)
- if (comptime pardes.hosted) if (was_on_disk and !onDisk(pane)) pardes.panes.File.deleted(p, @intCast(id));
+ if (was_on_disk and !onDisk(pane)) pardes.panes.File.deleted(p, @intCast(id));
}
// ---- one pane to and from a dump: the store's, a handover's ----