AttachmentSystem for NAT file processing
This commit is contained in:
@@ -152,6 +152,9 @@
|
||||
// Add systems!
|
||||
(archive.addSystem nameSystem)
|
||||
(archive.addSystem (new WikipediaImageSystem))
|
||||
// Just for testing:
|
||||
(archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
||||
|
||||
(archive.processSystems)
|
||||
|
||||
(defCommand Help []
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package nat.systems;
|
||||
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
import nat.System;
|
||||
import haxe.Json;
|
||||
|
||||
using haxe.io.Path;
|
||||
|
||||
typedef AttachmentProcessor = (Archive, Entry, Array<String>) -> Dynamic;
|
||||
|
||||
/**
|
||||
* Base System that processes Entries based on whether they have file attachments
|
||||
* which match a given set of extensions
|
||||
*/
|
||||
@:build(kiss.Kiss.build())
|
||||
class AttachmentSystem extends System {}
|
@@ -0,0 +1,14 @@
|
||||
(load "../Lib.kiss")
|
||||
|
||||
(defNew [&prop :Array<String> extensions
|
||||
:AttachmentProcessor processor]
|
||||
(super
|
||||
->[archive e]
|
||||
{
|
||||
(doFor file e.files
|
||||
(when !(= -1 (extensions.indexOf (file.extension)))
|
||||
(return true)))
|
||||
false
|
||||
}
|
||||
->[archive e]
|
||||
(processor archive e (filter e.files ->file !(= -1 (extensions.indexOf (file.extension)))))))
|
Reference in New Issue
Block a user