summaryrefslogtreecommitdiff
path: root/src/Buffer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Buffer.zig')
-rw-r--r--src/Buffer.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Buffer.zig b/src/Buffer.zig
index d0546c0..8917772 100644
--- a/src/Buffer.zig
+++ b/src/Buffer.zig
@@ -462,6 +462,30 @@ pub fn save(self: *Buffer, editor: *Editor) !void {
462 462
463 const file_path = self.file_path.?; 463 const file_path = self.file_path.?;
464 464
465 if (std.fs.path.dirname(file_path)) |dirname| {
466 if (std.fs.openDirAbsolute(dirname, .{})) |*dir| {
467 dir.close();
468 } else |_| {
469 const prompt = try std.fmt.allocPrint(
470 self.allocator,
471 "Create parent directory '{s}'?",
472 .{dirname},
473 );
474 defer self.allocator.free(prompt);
475
476 if (try editor.promptYN(prompt)) {
477 std.fs.cwd().makePath(dirname) catch |err| {
478 try editor.setStatusMessage(
479 "Cannot create parent directory '{s}': {}",
480 .{ dirname, err },
481 );
482 };
483 } else {
484 return;
485 }
486 }
487 }
488
465 const tmp_path = try std.fmt.allocPrint( 489 const tmp_path = try std.fmt.allocPrint(
466 self.allocator, 490 self.allocator,
467 "{s}~{}", 491 "{s}~{}",