From c570c362f375525ceed136fc2dcdba7e5e612597 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 28 Dec 2023 19:20:42 -0700 Subject: [PATCH] ImportFolder and OpenFiles --- src/nat/Archive.kiss | 2 ++ src/nat/ArchiveController.hx | 1 + src/nat/ArchiveController.kiss | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/nat/Archive.kiss b/src/nat/Archive.kiss index 99030bd..fc8a155 100644 --- a/src/nat/Archive.kiss +++ b/src/nat/Archive.kiss @@ -113,4 +113,6 @@ (haxe.Json.stringify e null "\t")) (method :String filePath [file] + // TODO don't fix absolute paths + (joinPath archiveDir "files" file)) \ No newline at end of file diff --git a/src/nat/ArchiveController.hx b/src/nat/ArchiveController.hx index 700b0c4..51e04d6 100644 --- a/src/nat/ArchiveController.hx +++ b/src/nat/ArchiveController.hx @@ -12,6 +12,7 @@ import nat.systems.*; import nat.components.*; import sys.FileSystem; using StringTools; +using haxe.io.Path; enum CommandArgType { // When called interactively, automatically pass the currently selected Entry(s) to the function diff --git a/src/nat/ArchiveController.kiss b/src/nat/ArchiveController.kiss index 78accb4..5fa4a7d 100644 --- a/src/nat/ArchiveController.kiss +++ b/src/nat/ArchiveController.kiss @@ -200,6 +200,7 @@ (cond ((= selectedPaths.length max) (continuation selectedPaths)) (true (collectFSArgs name dummyStream folder min max continuation cwd selectedPaths)))))) + // TODO allow de-selecting selected items (they start with "* ") ((unless (path.endsWith "/") path) (cond (justOne @@ -647,4 +648,25 @@ (defCommand TestFoldersPick [f (Folders 1 3)] (ui.displayMessage "$f") []) + + (defCommand ImportFolder [folder Folder] + (localVar newEntries []) + (walkDirectory "" folder + ->file (archive.createEntry ->e { + (addComponent archive e Name (file.withoutDirectory)) + (addFiles archive e [file] true) + (newEntries.push e) + })) + newEntries) + + (defCommand OpenFiles [es (SelectedEntries 1 null)] + (doFor e es + (doFor file e.files + (localVar args [(archive.filePath file)]) + (when (= (Sys.systemName) "Windows") (args.unshift "")) + (Sys.command + (case (Sys.systemName) ("Windows" "start") ("Linux" "xdg-open") ("Mac" "open") (never otherwise)) + args))) + []) + )