Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.name = .spacecap,
.version = "0.5.0",
.version = "0.6.0",
.fingerprint = 0xdc2511c12abe6e80,
.minimum_zig_version = "0.17.0",
.dependencies = .{
Expand Down
17 changes: 5 additions & 12 deletions src/util.zig
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,10 @@ pub const OutputDirectoryType = enum {
videos,
};

// Falls back to the current working directory when
// the home-based output directory cannot be resolved or created.
// Caller owns the memory.
/// Caller owns memory and must free.
/// Falls back to the current working directory when the home output directory
/// cannot be resolved.
/// NOTE: this does not create the directory or ensure it exists.
pub fn get_default_output_dir(
allocator: std.mem.Allocator,
io: std.Io,
Expand Down Expand Up @@ -356,15 +357,7 @@ pub fn get_default_output_dir(
.pictures => "Pictures",
.videos => "Videos",
};
const output_dir = try std.fs.path.join(allocator, &.{ _home_dir, home_subdirectory, "spacecap" });
errdefer allocator.free(output_dir);

if (std.Io.Dir.cwd().createDirPath(io, output_dir)) {
return output_dir;
} else |err| {
log.err("[get_default_output_dir] failed to create output directory {s}: {}", .{ output_dir, err });
allocator.free(output_dir);
}
return std.fs.path.join(allocator, &.{ _home_dir, home_subdirectory, "spacecap" });
}

log.warn("[get_default_output_dir] falling back to current working directory", .{});
Expand Down
Loading