aboutsummaryrefslogtreecommitdiff
path: root/Types
diff options
context:
space:
mode:
Diffstat (limited to 'Types')
-rw-r--r--Types/Remote.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Types/Remote.hs b/Types/Remote.hs
index 798bf1af5..671d90b79 100644
--- a/Types/Remote.hs
+++ b/Types/Remote.hs
@@ -22,11 +22,13 @@ module Types.Remote
, ExportDirectory(..)
, isExportSupported
, ExportActions(..)
+ , exportedDirectories
)
where
-import Data.Map as M
+import qualified Data.Map as M
import Data.Ord
+import qualified System.FilePath.Posix as Posix
import qualified Git
import Types.Key
@@ -198,3 +200,14 @@ data ExportActions a = ExportActions
-- support renames.
, renameExport :: Key -> ExportLocation -> ExportLocation -> a Bool
}
+
+-- | All directories down to the ExportLocation, with the deepest ones
+-- last.
+exportedDirectories :: ExportLocation -> [ExportDirectory]
+exportedDirectories (ExportLocation f) =
+ map (ExportDirectory . Posix.joinPath . reverse) $
+ subs [] $ map Posix.dropTrailingPathSeparator $
+ Posix.splitPath $ Posix.takeDirectory f
+ where
+ subs _ [] = []
+ subs ps (d:ds) = (d:ps) : subs (d:ps) ds