ImportFolder and OpenFiles

This commit is contained in:
2023-12-28 19:20:42 -07:00
parent 775a6ab325
commit c570c362f3
3 changed files with 25 additions and 0 deletions

View File

@@ -113,4 +113,6 @@
(haxe.Json.stringify e null "\t"))
(method :String filePath [file]
// TODO don't fix absolute paths
(joinPath archiveDir "files" file))

View File

@@ -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

View File

@@ -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)))
[])
)