From 75ec94a87a52a7230c9b7d9b3e150a0da2725e58 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 6 Aug 2017 23:12:27 +0200 Subject: 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. --- internal/nametransform/diriv.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/nametransform') 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 +} -- cgit v1.2.3