diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-09-18 13:57:25 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-09-18 13:59:59 -0400 |
commit | a5e968bb8d4c608c33463160ea2b583a3e34b8fc (patch) | |
tree | ffd59e071fadf718ed4f270d2cf2b67fda9b6315 /Types | |
parent | 9d2ac4d87dc98bd2ab60da38a7e98f0964fd1595 (diff) |
add ExportTree table to export db
New table needed to look up what filenames are used in the currently
exported tree, for reasons explained in export.mdwn.
Also, added smart constructors for ExportLocation and ExportDirectory to
make sure they contain filepaths with the right direction slashes.
And some code refactoring.
This commit was sponsored by Francois Marier on Patreon.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/Export.hs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Types/Export.hs b/Types/Export.hs index cc1b8debf..0e86f9684 100644 --- a/Types/Export.hs +++ b/Types/Export.hs @@ -5,19 +5,41 @@ - Licensed under the GNU GPL version 3 or higher. -} -module Types.Export where +module Types.Export ( + ExportLocation, + mkExportLocation, + fromExportLocation, + ExportDirectory, + mkExportDirectory, + fromExportDirectory, + exportDirectories, +) where + +import Git.FilePath import qualified System.FilePath.Posix as Posix -- A location on a remote that a key can be exported to. -- The FilePath will be relative to the top of the export, --- and may contain unix-style path separators. +-- and uses unix-style path separators. newtype ExportLocation = ExportLocation FilePath deriving (Show, Eq) +mkExportLocation :: FilePath -> ExportLocation +mkExportLocation = ExportLocation . toInternalGitPath + +fromExportLocation :: ExportLocation -> FilePath +fromExportLocation (ExportLocation f) = f + newtype ExportDirectory = ExportDirectory FilePath deriving (Show, Eq) +mkExportDirectory :: FilePath -> ExportDirectory +mkExportDirectory = ExportDirectory . toInternalGitPath + +fromExportDirectory :: ExportDirectory -> FilePath +fromExportDirectory (ExportDirectory f) = f + -- | All subdirectories down to the ExportLocation, with the deepest ones -- last. Does not include the top of the export. exportDirectories :: ExportLocation -> [ExportDirectory] |