2019-08-05 16:05:39 +00:00
|
|
|
// Code generated by fileb0x at "2019-08-05 10:04:21.752835 -0600 MDT m=+0.004628888" from config file "b0x.toml" DO NOT EDIT.
|
|
|
|
// modification hash(e0dad2aef9534d24be436f8d9dd5e9cc.acdb557394f98d3c09c0bb4d4b9142f8)
|
2019-07-01 08:44:48 +00:00
|
|
|
|
|
|
|
package static
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"golang.org/x/net/webdav"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// CTX is a context for webdav vfs
|
|
|
|
CTX = context.Background()
|
|
|
|
|
|
|
|
// FS is a virtual memory file system
|
|
|
|
FS = webdav.NewMemFS()
|
|
|
|
|
|
|
|
// Handler is used to server files through a http handler
|
|
|
|
Handler *webdav.Handler
|
|
|
|
|
|
|
|
// HTTP is the http file system
|
|
|
|
HTTP http.FileSystem = new(HTTPFS)
|
|
|
|
)
|
|
|
|
|
|
|
|
// HTTPFS implements http.FileSystem
|
|
|
|
type HTTPFS struct {
|
|
|
|
// Prefix allows to limit the path of all requests. F.e. a prefix "css" would allow only calls to /css/*
|
|
|
|
Prefix string
|
|
|
|
}
|
|
|
|
|
|
|
|
// FileDistLibraryLaunchDaemonsRdnsPlistTmpl is "dist/Library/LaunchDaemons/_rdns_.plist.tmpl"
|
2019-08-05 16:05:39 +00:00
|
|
|
var FileDistLibraryLaunchDaemonsRdnsPlistTmpl = []byte("\x3c\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\x2d\x38\x22\x3f\x3e\x0a\x3c\x21\x2d\x2d\x20\x47\x65\x6e\x65\x72\x61\x74\x65\x64\x20\x66\x6f\x72\x20\x73\x65\x72\x76\x69\x63\x65\x6d\x61\x6e\x2e\x20\x45\x64\x69\x74\x20\x61\x73\x20\x79\x6f\x75\x20\x77\x69\x73\x68\x2c\x20\x62\x75\x74\x20\x6c\x65\x61\x76\x65\x20\x74\x68\x69\x73\x20\x6c\x69\x6e\x65\x2e\x20\x2d\x2d\x3e\x0a\x3c\x21\x44\x4f\x43\x54\x59\x50\x45\x20\x70\x6c\x69\x73\x74\x20\x50\x55\x42\x4c\x49\x43\x20\x22\x2d\x2f\x2f\x41\x70\x70\x6c\x65\x2f\x2f\x44\x54\x44\x20\x50\x4c\x49\x53\x54\x20\x31\x2e\x30\x2f\x2f\x45\x4e\x22\x20\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x61\x70\x70\x6c\x65\x2e\x63\x6f\x6d\x2f\x44\x54\x44\x73\x2f\x50\x72\x6f\x70\x65\x72\x74\x79\x4c\x69\x73\x74\x2d\x31\x2e\x30\x2e\x64\x74\x64\x22\x3e\x0a\x3c\x70\x6c\x69\x73\x74\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\x30\x22\x3e\x0a\x3c\x64\x69\x63\x74\x3e\x0a\x09\x3c\x6b\x65\x79\x3e\x4c\x61\x62\x65\x6c\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x2e\x52\x65\x76\x65\x72\x73\x65\x44\x4e\x53\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x3c\x6b\x65\x79\x3e\x50\x72\x6f\x67\x72\x61\x6d\x41\x72\x67\x75\x6d\x65\x6e\x74\x73\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x61\x72\x72\x61\x79\x3e\x0a\x09\x09\x7b\x7b\x2d\x20\x69\x66\x20\x2e\x49\x6e\x74\x65\x72\x70\x72\x65\x74\x65\x72\x20\x7d\x7d\x0a\x09\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x2e\x49\x6e\x74\x65\x72\x70\x72\x65\x74\x65\x72\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x09\x7b\x7b\x2d\x20\x65\x6e\x64\x20\x7d\x7d\x0a\x09\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x2e\x45\x78\x65\x63\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x09\x7b\x7b\x2d\x20\x72\x61\x6e\x67\x65\x20\x24\x61\x72\x67\x20\x3a\x3d\x20\x2e\x41\x72\x67\x76\x20\x7d\x7d\x0a\x09\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x24\x61\x72\x67\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x20\x20\x7b\x7b\x2d\x20\x65\x6e\x64\x20\x7d\x7d\x0a\x09\x3c\x2f\x61\x72\x72\x61\x79\x3e\x0a\x09\x7b\x7b\x2d\x20\x69\x66\x20\x2e\x45\x6e\x76\x73\x20\x7d\x7d\x0a\x09\x3c\x6b\x65\x79\x3e\x45\x6e\x76\x69\x72\x6f\x6e\x6d\x65\x6e\x74\x56\x61\x72\x69\x61\x62\x6c\x65\x73\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x64\x69\x63\x74\x3e\x0a\x09\x09\x7b\x7b\x2d\x20\x72\x61\x6e\x67\x65\x20\x24\x6b\x65\x79\x2c\x20\x24\x76\x61\x6c\x75\x65\x20\x3a\x3d\x20\x2e\x45\x6e\x76\x73\x20\x7d\x7d\x0a\x09\x09\x3c\x6b\x65\x79\x3e\x7b\x7b\x20\x24\x6b\x65\x79\x20\x7d\x7d\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x24\x76\x61\x6c\x75\x65\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x09\x7b\x7b\x2d\x20\x65\x6e\x64\x20\x7d\x7d\x0a\x09\x3c\x2f\x64\x69\x63\x74\x3e\x0a\x09\x7b\x7b\x2d\x20\x65\x6e\x64\x20\x7d\x7d\x0a\x0a\x09\x7b\x7b\x69\x66\x20\x2e\x55\x73\x65\x72\x20\x2d\x7d\x7d\x0a\x09\x3c\x6b\x65\x79\x3e\x55\x73\x65\x72\x4e\x61\x6d\x65\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x2e\x55\x73\x65\x72\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x7b\x7b\x65\x6e\x64\x20\x2d\x7d\x7d\x0a\x09\x7b\x7b\x69\x66\x20\x2e\x47\x72\x6f\x75\x70\x20\x2d\x7d\x7d\x0a\x09\x3c\x6b\x65\x79\x3e\x47\x72\x6f\x75\x70\x4e\x61\x6d\x65\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x73\x74\x72\x69\x6e\x67\x3e\x7b\x7b\x20\x2e\x47\x72\x6f\x75\x70\x20\x7d\x7d\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e\x0a\x09\x3c\x6b\x65\x79\x3e\x49\x6e\x69\x74\x47\x72\x6f\x75\x70\x73\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x74\x72\x75\x65\x2f\x3e\x0a\x0a\x09\x7b\x7b\x65\x6e\x64\x20\x2d\x7d\x7d\x0a\x09\x3c\x6b\x65\x79\x3e\x52\x75\x6e\x41\x74\x4c\x6f\x61\x64\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x74\x72\x75\x65\x2f\x3e\x0a\x09\x7b\x7b\x20\x69\x66\x20\x2e\x52\x65\x73\x74\x61\x72\x74\x20\x2d\x7d\x7d\x0a\x09\x3c\x6b\x65\x79\x3e\x4b\x65\x65\x70\x41\x6c\x69\x76\x65\x3c\x2f\x6b\x65\x79\x3e\x0a\x09\x3c\x74\x72\x75\x65\x2f\x3e\x0a\x09\x3c\x21\x2d\x2d\x64\x69\x63\x74\x3e\x0a\x09\x09\x3c\x6b\x65\x79\x3e\x43\x72\x61\x73\x6
|
2019-07-01 08:44:48 +00:00
|
|
|
|
|
|
|
// FileDistEtcSystemdSystemNameServiceTmpl is "dist/etc/systemd/system/_name_.service.tmpl"
|
2019-08-05 16:05:39 +00:00
|
|
|
var FileDistEtcSystemdSystemNameServiceTmpl = []byte("\x23\x20\x47\x65\x6e\x65\x72\x61\x74\x65\x64\x20\x66\x6f\x72\x20\x73\x65\x72\x76\x69\x63\x65\x6d\x61\x6e\x2e\x20\x45\x64\x69\x74\x20\x61\x73\x20\x79\x6f\x75\x20\x77\x69\x73\x68\x2c\x20\x62\x75\x74\x20\x6c\x65\x61\x76\x65\x20\x74\x68\x69\x73\x20\x6c\x69\x6e\x65\x2e\x0a\x23\x20\x50\x72\x65\x2d\x72\x65\x71\x0a\x23\x20\x73\x75\x64\x6f\x20\x6d\x6b\x64\x69\x72\x20\x2d\x70\x20\x7b\x7b\x20\x2e\x4c\x6f\x63\x61\x6c\x20\x7d\x7d\x2f\x6f\x70\x74\x2f\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x2f\x20\x7b\x7b\x20\x2e\x4c\x6f\x63\x61\x6c\x20\x7d\x7d\x2f\x76\x61\x72\x2f\x6c\x6f\x67\x2f\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x0a\x7b\x7b\x20\x69\x66\x20\x2e\x53\x79\x73\x74\x65\x6d\x20\x2d\x7d\x7d\x0a\x7b\x7b\x2d\x20\x69\x66\x20\x61\x6e\x64\x20\x2e\x55\x73\x65\x72\x20\x28\x20\x6e\x65\x20\x22\x72\x6f\x6f\x74\x22\x20\x2e\x55\x73\x65\x72\x20\x29\x20\x2d\x7d\x7d\x0a\x23\x20\x73\x75\x64\x6f\x20\x61\x64\x64\x75\x73\x65\x72\x20\x7b\x7b\x20\x2e\x55\x73\x65\x72\x20\x7d\x7d\x20\x2d\x2d\x68\x6f\x6d\x65\x20\x2f\x6f\x70\x74\x2f\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x0a\x23\x20\x73\x75\x64\x6f\x20\x63\x68\x6f\x77\x6e\x20\x2d\x52\x20\x7b\x7b\x20\x2e\x55\x73\x65\x72\x20\x7d\x7d\x3a\x7b\x7b\x20\x2e\x47\x72\x6f\x75\x70\x20\x7d\x7d\x20\x2f\x6f\x70\x74\x2f\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x2f\x20\x2f\x76\x61\x72\x2f\x6c\x6f\x67\x2f\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x0a\x7b\x7b\x2d\x20\x65\x6e\x64\x20\x7d\x7d\x0a\x7b\x7b\x20\x65\x6e\x64\x20\x2d\x7d\x7d\x0a\x23\x20\x50\x6f\x73\x74\x2d\x69\x6e\x73\x74\x61\x6c\x6c\x0a\x23\x20\x73\x75\x64\x6f\x20\x73\x79\x73\x74\x65\x6d\x63\x74\x6c\x20\x7b\x7b\x20\x69\x66\x20\x6e\x6f\x74\x20\x2e\x53\x79\x73\x74\x65\x6d\x20\x2d\x7d\x7d\x20\x2d\x2d\x75\x73\x65\x72\x20\x7b\x7b\x20\x65\x6e\x64\x20\x2d\x7d\x7d\x20\x64\x61\x65\x6d\x6f\x6e\x2d\x72\x65\x6c\x6f\x61\x64\x0a\x23\x20\x73\x75\x64\x6f\x20\x73\x79\x73\x74\x65\x6d\x63\x74\x6c\x20\x7b\x7b\x20\x69\x66\x20\x6e\x6f\x74\x20\x2e\x53\x79\x73\x74\x65\x6d\x20\x2d\x7d\x7d\x20\x2d\x2d\x75\x73\x65\x72\x20\x7b\x7b\x20\x65\x6e\x64\x20\x2d\x7d\x7d\x20\x72\x65\x73\x74\x61\x72\x74\x20\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x2e\x73\x65\x72\x76\x69\x63\x65\x0a\x23\x20\x73\x75\x64\x6f\x20\x6a\x6f\x75\x72\x6e\x61\x6c\x63\x74\x6c\x20\x7b\x7b\x20\x69\x66\x20\x6e\x6f\x74\x20\x2e\x53\x79\x73\x74\x65\x6d\x20\x2d\x7d\x7d\x20\x2d\x2d\x75\x73\x65\x72\x20\x7b\x7b\x20\x65\x6e\x64\x20\x2d\x7d\x7d\x20\x2d\x78\x65\x66\x75\x20\x7b\x7b\x20\x2e\x4e\x61\x6d\x65\x20\x7d\x7d\x0a\x0a\x5b\x55\x6e\x69\x74\x5d\x0a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x3d\x7b\x7b\x20\x2e\x54\x69\x74\x6c\x65\x20\x7d\x7d\x20\x7b\x7b\x20\x69\x66\x20\x2e\x44\x65\x73\x63\x20\x7d\x7d\x2d\x20\x7b\x7b\x20\x2e\x44\x65\x73\x63\x20\x7d\x7d\x7b\x7b\x20\x65\x6e\x64\x20\x7d\x7d\x0a\x7b\x7b\x20\x69\x66\x20\x2e\x55\x52\x4c\x20\x2d\x7d\x7d\x0a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x61\x74\x69\x6f\x6e\x3d\x7b\x7b\x20\x2e\x55\x52\x4c\x20\x7d\x7d\x0a\x7b\x7b\x20\x65\x6e\x64\x20\x2d\x7d\x7d\x0a\x7b\x7b\x20\x69\x66\x20\x2e\x53\x79\x73\x74\x65\x6d\x20\x2d\x7d\x7d\x0a\x41\x66\x74\x65\x72\x3d\x6e\x65\x74\x77\x6f\x72\x6b\x2d\x6f\x6e\x6c\x69\x6e\x65\x2e\x74\x61\x72\x67\x65\x74\x0a\x57\x61\x6e\x74\x73\x3d\x6e\x65\x74\x77\x6f\x72\x6b\x2d\x6f\x6e\x6c\x69\x6e\x65\x2e\x74\x61\x72\x67\x65\x74\x20\x73\x79\x73\x74\x65\x6d\x64\x2d\x6e\x65\x74\x77\x6f\x72\x6b\x64\x2d\x77\x61\x69\x74\x2d\x6f\x6e\x6c\x69\x6e\x65\x2e\x73\x65\x72\x76\x69\x63\x65\x0a\x0a\x7b\x7b\x20\x65\x6e\x64\x20\x2d\x7d\x7d\x0a\x5b\x53\x65\x72\x76\x69\x63\x65\x5d\x0a\x23\x20\x52\x65\x73\x74\x61\x72\x74\x20\x6f\x6e\x20\x63\x72\x61\x73\x68\x20\x28\x62\x61\x64\x20\x73\x69\x67\x6e\x61\x6c\x29\x2c\x20\x62\x75\x74\x20\x6e\x6f\x74\x20\x6f\x6e\x20\x27\x63\x6c\x65\x61\x6e\x27\x20\x66\x61\x69\x6c\x75\x72\x65\x20\x28\x65\x72\x72\x6f\x72\x20\x65\x78\x69\x74\x20\x63\x6f\x64\x65\x29\x0a\x23\x20\x41\x6c\x6c\x6f\x77\x20\x75\x70\x20\x74\x6f\x20\x33\x20\x72\x65\x73\x74\x61\x72\x74\x73\x20\x77\x69\x74\x68\x69\x6e\x20\x31\x30\x20\x73\x65\x63\x6f\x6e\x64\x73\x0a\x23\x20\x28\x69\x74\x27\x73\x20\x75\x6e\x6c\x69\x6b\x65\x6c\x79\x20\x74\x68\x61\
|
2019-07-01 08:44:48 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
err := CTX.Err()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FS.Mkdir(CTX, "dist/", 0777)
|
|
|
|
if err != nil && err != os.ErrExist {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FS.Mkdir(CTX, "dist/etc/", 0777)
|
|
|
|
if err != nil && err != os.ErrExist {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FS.Mkdir(CTX, "dist/etc/systemd/", 0777)
|
|
|
|
if err != nil && err != os.ErrExist {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FS.Mkdir(CTX, "dist/etc/systemd/system/", 0777)
|
|
|
|
if err != nil && err != os.ErrExist {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FS.Mkdir(CTX, "dist/Library/", 0777)
|
|
|
|
if err != nil && err != os.ErrExist {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FS.Mkdir(CTX, "dist/Library/LaunchDaemons/", 0777)
|
|
|
|
if err != nil && err != os.ErrExist {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var f webdav.File
|
|
|
|
|
|
|
|
f, err = FS.OpenFile(CTX, "dist/Library/LaunchDaemons/_rdns_.plist.tmpl", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = f.Write(FileDistLibraryLaunchDaemonsRdnsPlistTmpl)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = f.Close()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err = FS.OpenFile(CTX, "dist/etc/systemd/system/_name_.service.tmpl", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = f.Write(FileDistEtcSystemdSystemNameServiceTmpl)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = f.Close()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
Handler = &webdav.Handler{
|
|
|
|
FileSystem: FS,
|
|
|
|
LockSystem: webdav.NewMemLS(),
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open a file
|
|
|
|
func (hfs *HTTPFS) Open(path string) (http.File, error) {
|
|
|
|
path = hfs.Prefix + path
|
|
|
|
|
|
|
|
f, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return f, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadFile is adapTed from ioutil
|
|
|
|
func ReadFile(path string) ([]byte, error) {
|
|
|
|
f, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
buf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))
|
|
|
|
|
|
|
|
// If the buffer overflows, we will get bytes.ErrTooLarge.
|
|
|
|
// Return that as an error. Any other panic remains.
|
|
|
|
defer func() {
|
|
|
|
e := recover()
|
|
|
|
if e == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {
|
|
|
|
err = panicErr
|
|
|
|
} else {
|
|
|
|
panic(e)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
_, err = buf.ReadFrom(f)
|
|
|
|
return buf.Bytes(), err
|
|
|
|
}
|
|
|
|
|
|
|
|
// WriteFile is adapTed from ioutil
|
|
|
|
func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
|
|
|
f, err := FS.OpenFile(CTX, filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
n, err := f.Write(data)
|
|
|
|
if err == nil && n < len(data) {
|
|
|
|
err = io.ErrShortWrite
|
|
|
|
}
|
|
|
|
if err1 := f.Close(); err == nil {
|
|
|
|
err = err1
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// WalkDirs looks for files in the given dir and returns a list of files in it
|
|
|
|
// usage for all files in the b0x: WalkDirs("", false)
|
|
|
|
func WalkDirs(name string, includeDirsInList bool, files ...string) ([]string, error) {
|
|
|
|
f, err := FS.OpenFile(CTX, name, os.O_RDONLY, 0)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
fileInfos, err := f.Readdir(0)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = f.Close()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, info := range fileInfos {
|
|
|
|
filename := path.Join(name, info.Name())
|
|
|
|
|
|
|
|
if includeDirsInList || !info.IsDir() {
|
|
|
|
files = append(files, filename)
|
|
|
|
}
|
|
|
|
|
|
|
|
if info.IsDir() {
|
|
|
|
files, err = WalkDirs(filename, includeDirsInList, files...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return files, nil
|
|
|
|
}
|