mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Add a -resources flag to cmd/ractool
This commit is contained in:
1 parent
08798669eb
commit
6e7c88f42f
2 files changed
+16
No files matched your search
@@ -81,4 +81,6 @@ Encode-Related Flags:
|
||||
the chunk size (in DSpace)
|
||||
-indexlocation
|
||||
the index location, "start" or "end" (default "start")
|
||||
-resources
|
||||
comma-separated list of resource files, such as shared dictionaries
|
||||
`
|
||||
@@ -87,6 +87,8 @@ Encode-Related Flags:
|
||||
the chunk size (in DSpace)
|
||||
-indexlocation
|
||||
the index location, "start" or "end" (default "start")
|
||||
-resources
|
||||
comma-separated list of resource files, such as shared dictionaries
|
||||
*/
|
||||
package main
|
||||
|
||||
@@ -122,6 +124,8 @@ var (
|
||||
dchunksizeFlag = flag.String("dchunksize", "0", "the chunk size (in DSpace)")
|
||||
indexlocationFlag = flag.String("indexlocation", "start",
|
||||
"the index location, \"start\" or \"end\"")
|
||||
resourcesFlag = flag.String("resources", "",
|
||||
"comma-separated list of resource files, such as shared dictionaries")
|
||||
)
|
||||
|
||||
func usage() {
|
||||
@@ -323,6 +327,16 @@ func encode(r io.Reader) error {
|
||||
return errors.New("unsupported -codec")
|
||||
}
|
||||
|
||||
if *resourcesFlag != "" {
|
||||
for _, filename := range strings.Split(*resourcesFlag, ",") {
|
||||
resource, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.ResourcesData = append(w.ResourcesData, resource)
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := io.Copy(w, r); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user