archive addFile and attachFiles
This commit is contained in:
@@ -4,9 +4,11 @@
|
|||||||
[]
|
[]
|
||||||
:Map<String,Entry> entries
|
:Map<String,Entry> entries
|
||||||
(let [entryDir (joinPath archiveDir "entries")
|
(let [entryDir (joinPath archiveDir "entries")
|
||||||
componentDir (joinPath archiveDir "components")]
|
componentDir (joinPath archiveDir "components")
|
||||||
|
filesDir (joinPath archiveDir "files")]
|
||||||
(FileSystem.createDirectory entryDir)
|
(FileSystem.createDirectory entryDir)
|
||||||
(FileSystem.createDirectory componentDir)
|
(FileSystem.createDirectory componentDir)
|
||||||
|
(FileSystem.createDirectory filesDir)
|
||||||
(let [entryFiles (FileSystem.readDirectory entryDir)]
|
(let [entryFiles (FileSystem.readDirectory entryDir)]
|
||||||
(for file entryFiles =>(file.withoutExtension) (the Entry (Json.parse (File.getContent (joinPath archiveDir "entries" file)))))))])
|
(for file entryFiles =>(file.withoutExtension) (the Entry (Json.parse (File.getContent (joinPath archiveDir "entries" file)))))))])
|
||||||
|
|
||||||
|
@@ -184,4 +184,13 @@
|
|||||||
(selectEntries (filter archive.entries ->e (tagsMatch archive e tagsBoolExp))))
|
(selectEntries (filter archive.entries ->e (tagsMatch archive e tagsBoolExp))))
|
||||||
|
|
||||||
(defCommand selectByComponents [componentsBoolExp (Text null)]
|
(defCommand selectByComponents [componentsBoolExp (Text null)]
|
||||||
(selectEntries (filter archive.entries ->e (componentsMatch e componentsBoolExp)))))
|
(selectEntries (filter archive.entries ->e (componentsMatch e componentsBoolExp))))
|
||||||
|
|
||||||
|
(defCommand attachFiles [entries (SelectedEntries 1 null)
|
||||||
|
// TODO add File and Files as an argument type for commands, ArchiveUI
|
||||||
|
// TODO make tkinter file browser externs and use tkinter as the file picking mechanism for CLI
|
||||||
|
files (VarText null)]
|
||||||
|
(doFor e entries
|
||||||
|
(doFor file files
|
||||||
|
(withWritableEntry archive e (addFile archive e file))))
|
||||||
|
entries))
|
||||||
|
@@ -51,6 +51,13 @@
|
|||||||
,@saveList
|
,@saveList
|
||||||
,retValSymbol)))
|
,retValSymbol)))
|
||||||
|
|
||||||
|
(function addFile [:Archive archive :Entry e :String file &opt leaveOriginalCopy]
|
||||||
|
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
|
||||||
|
(unless !(= -1 (e.files.indexOf pathWithoutDir))
|
||||||
|
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
|
||||||
|
file (joinPath archive.archiveDir "files" pathWithoutDir))
|
||||||
|
(e.files.push pathWithoutDir))))
|
||||||
|
|
||||||
(defMacro withWritableEntry [archive e &body body]
|
(defMacro withWritableEntry [archive e &body body]
|
||||||
(let [retValSymbol
|
(let [retValSymbol
|
||||||
(symbol)]
|
(symbol)]
|
||||||
|
Reference in New Issue
Block a user