ImportFolder and OpenFiles
This commit is contained in:
@@ -113,4 +113,6 @@
|
|||||||
(haxe.Json.stringify e null "\t"))
|
(haxe.Json.stringify e null "\t"))
|
||||||
|
|
||||||
(method :String filePath [file]
|
(method :String filePath [file]
|
||||||
|
// TODO don't fix absolute paths
|
||||||
|
|
||||||
(joinPath archiveDir "files" file))
|
(joinPath archiveDir "files" file))
|
@@ -12,6 +12,7 @@ import nat.systems.*;
|
|||||||
import nat.components.*;
|
import nat.components.*;
|
||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
using StringTools;
|
using StringTools;
|
||||||
|
using haxe.io.Path;
|
||||||
|
|
||||||
enum CommandArgType {
|
enum CommandArgType {
|
||||||
// When called interactively, automatically pass the currently selected Entry(s) to the function
|
// When called interactively, automatically pass the currently selected Entry(s) to the function
|
||||||
|
@@ -200,6 +200,7 @@
|
|||||||
(cond
|
(cond
|
||||||
((= selectedPaths.length max) (continuation selectedPaths))
|
((= selectedPaths.length max) (continuation selectedPaths))
|
||||||
(true (collectFSArgs name dummyStream folder min max continuation cwd selectedPaths))))))
|
(true (collectFSArgs name dummyStream folder min max continuation cwd selectedPaths))))))
|
||||||
|
// TODO allow de-selecting selected items (they start with "* ")
|
||||||
((unless (path.endsWith "/") path)
|
((unless (path.endsWith "/") path)
|
||||||
(cond
|
(cond
|
||||||
(justOne
|
(justOne
|
||||||
@@ -647,4 +648,25 @@
|
|||||||
(defCommand TestFoldersPick [f (Folders 1 3)]
|
(defCommand TestFoldersPick [f (Folders 1 3)]
|
||||||
(ui.displayMessage "$f")
|
(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)))
|
||||||
|
[])
|
||||||
|
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user