summaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse_v1api/excluder.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-10-15 23:18:21 +0200
committerJakob Unterwurzacher2020-10-15 23:18:21 +0200
commitfcb28e4ff35e6bc262bfda23f3779ef3a8e7708a (patch)
treea32dd8e693f50f8f1b47e6b768bc441935253ad1 /internal/fusefrontend_reverse_v1api/excluder.go
parentf03f56844bc4e88895f167399d30e9be99629f68 (diff)
v2pai: delete fusefrontend_reverse_v1api
Served its mission a copy-paste source but can now be deleted.
Diffstat (limited to 'internal/fusefrontend_reverse_v1api/excluder.go')
-rw-r--r--internal/fusefrontend_reverse_v1api/excluder.go66
1 files changed, 0 insertions, 66 deletions
diff --git a/internal/fusefrontend_reverse_v1api/excluder.go b/internal/fusefrontend_reverse_v1api/excluder.go
deleted file mode 100644
index c44816c..0000000
--- a/internal/fusefrontend_reverse_v1api/excluder.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package fusefrontend_reverse
-
-import (
- "io/ioutil"
- "os"
- "strings"
-
- "github.com/rfjakob/gocryptfs/internal/exitcodes"
- "github.com/rfjakob/gocryptfs/internal/fusefrontend"
- "github.com/rfjakob/gocryptfs/internal/tlog"
-
- "github.com/sabhiram/go-gitignore"
-)
-
-// prepareExcluder creates an object to check if paths are excluded
-// based on the patterns specified in the command line.
-func (rfs *ReverseFS) prepareExcluder(args fusefrontend.Args) {
- if len(args.Exclude) > 0 || len(args.ExcludeWildcard) > 0 || len(args.ExcludeFrom) > 0 {
- excluder, err := ignore.CompileIgnoreLines(getExclusionPatterns(args)...)
- if err != nil {
- tlog.Fatal.Printf("Error compiling exclusion rules: %q", err)
- os.Exit(exitcodes.ExcludeError)
- }
- rfs.excluder = excluder
- }
-}
-
-// getExclusionPatters prepares a list of patterns to be excluded.
-// Patterns passed in the -exclude command line option are prefixed
-// with a leading '/' to preserve backwards compatibility (before
-// wildcard matching was implemented, exclusions always were matched
-// against the full path).
-func getExclusionPatterns(args fusefrontend.Args) []string {
- patterns := make([]string, len(args.Exclude)+len(args.ExcludeWildcard))
- // add -exclude
- for i, p := range args.Exclude {
- patterns[i] = "/" + p
- }
- // add -exclude-wildcard
- copy(patterns[len(args.Exclude):], args.ExcludeWildcard)
- // add -exclude-from
- for _, file := range args.ExcludeFrom {
- lines, err := getLines(file)
- if err != nil {
- tlog.Fatal.Printf("Error reading exclusion patterns: %q", err)
- os.Exit(exitcodes.ExcludeError)
- }
- patterns = append(patterns, lines...)
- }
- return patterns
-}
-
-// getLines reads a file and splits it into lines
-func getLines(file string) ([]string, error) {
- buffer, err := ioutil.ReadFile(file)
- if err != nil {
- return nil, err
- }
- return strings.Split(string(buffer), "\n"), nil
-}
-
-// isExcludedPlain finds out if the plaintext path "pPath" is
-// excluded (used when -exclude is passed by the user).
-func (rfs *ReverseFS) isExcludedPlain(pPath string) bool {
- return rfs.excluder != nil && rfs.excluder.MatchesPath(pPath)
-}