diff options
author | Jakob Unterwurzacher | 2017-08-06 23:12:27 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-08-06 23:14:39 +0200 |
commit | 75ec94a87a52a7230c9b7d9b3e150a0da2725e58 (patch) | |
tree | 94b24b433b0ec42ae6b9d61c8e7b541000dedebb /internal/nametransform | |
parent | 5190cc09bbc8afca75986dbb14f09e62eda33b61 (diff) |
nametransform: add Dir() function
Dir is like filepath.Dir but returns "" instead of ".".
This was already implemented in fusefrontend_reverse as saneDir().
We will need it in nametransform for the improved diriv caching.
Diffstat (limited to 'internal/nametransform')
-rw-r--r-- | internal/nametransform/diriv.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/nametransform/diriv.go b/internal/nametransform/diriv.go index 6746f04..87e7887 100644 --- a/internal/nametransform/diriv.go +++ b/internal/nametransform/diriv.go @@ -162,3 +162,12 @@ func (be *NameTransform) EncryptPathDirIV(plainPath string, rootDir string) (cip be.DirIVCache.Store(parentDir, iv, cParentDir) return cipherPath, nil } + +// Dir is like filepath.Dir but returns "" instead of ".". +func Dir(path string) string { + d := filepath.Dir(path) + if d == "." { + return "" + } + return d +} |