diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.kiss b/projects/nat-archive-tool/src/nat/ArchiveController.kiss index 0216abbe..095d0c9b 100644 --- a/projects/nat-archive-tool/src/nat/ArchiveController.kiss +++ b/projects/nat-archive-tool/src/nat/ArchiveController.kiss @@ -165,20 +165,13 @@ (defCommand AddTags [entries (SelectedEntries 1 null) tagsToAdd (VarText null)] (doFor e entries - (withWritableEntry archive e - (if (hasComponent e Tags) - (withWritableComponents archive e [tags Tags] - (doFor tag tagsToAdd (dictSet tags tag 1))) - (addComponent archive e Tags (for tag tagsToAdd =>tag 1))))) + (addTags archive e tagsToAdd)) entries) // TODO this includes entries that already had the tag in the changeset (defCommand RemoveTags [entries (SelectedEntries 1 null) tagsToRemove (VarText null)] (doFor e entries - (withWritableEntry archive e - (when (hasComponent e Tags) - (withWritableComponents archive e [tags Tags] - (doFor tag tagsToRemove (tags.remove tag)))))) + (removeTags archive e tagsToRemove)) entries) // TODO this includes entries that didn't have the tag in the changeset (defCommand SelectByTags [tagsBoolExp (Text null)] diff --git a/projects/nat-archive-tool/src/nat/Lib.kiss b/projects/nat-archive-tool/src/nat/Lib.kiss index 819025fc..01f71def 100644 --- a/projects/nat-archive-tool/src/nat/Lib.kiss +++ b/projects/nat-archive-tool/src/nat/Lib.kiss @@ -51,13 +51,6 @@ ,@saveList ,retValSymbol))) -(function addFile [:nat.Archive archive :nat.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] (let [retValSymbol (symbol)] @@ -83,3 +76,23 @@ (function componentsMatch [:nat.Entry e componentsBoolExp] (BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType))) + +(function addFile [:nat.Archive archive :nat.Entry e :String file &opt leaveOriginalCopy] + (withWritableEntry archive e + (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))))) + +(function addTags [:nat.Archive archive :nat.Entry e :Array tagsToAdd] + (if (hasComponent e Tags) + (withWritableComponents archive e [tags Tags] + (doFor tag tagsToAdd (dictSet tags tag 1))) + (addComponent archive e Tags (for tag tagsToAdd =>tag 1)))) + +(function removeTags [:nat.Archive archive :nat.Entry e :Array tagsToRemove] + (when (hasComponent e Tags) + (withWritableComponents archive e [tags Tags] + (doFor tag tagsToRemove (tags.remove tag))))) +