diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-02 08:35:15 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-02 08:35:15 -0400 |
commit | 9517fbb9488aac6750b9599db358da8d72a2343e (patch) | |
tree | 0584473638da9c38f7bc2164c17cad4aab048cdc /Fields.hs | |
parent | bab6dc48d3ee09036fa555fa5ddc1475c9ce87d4 (diff) |
cleanup
Diffstat (limited to 'Fields.hs')
-rw-r--r-- | Fields.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Fields.hs b/Fields.hs new file mode 100644 index 000000000..08189cbdf --- /dev/null +++ b/Fields.hs @@ -0,0 +1,32 @@ +{- git-annex fields + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Fields where + +import Common.Annex +import qualified Annex + +import Data.Char + +{- A field, stored in Annex state, with a value sanity checker. -} +data Field = Field + { fieldName :: String + , fieldCheck :: String -> IO Bool + } + +remoteUUID :: Field +remoteUUID = Field "remoteuuid" $ + -- does it look like a UUID? + return . all (\c -> isAlphaNum c || c == '-') + +associatedFile :: Field +associatedFile = Field "associatedfile" $ \value -> + -- is the file located within the current directory? + dirContains <$> getCurrentDirectory <*> pure value + +getField :: Field -> Annex (Maybe String) +getField = Annex.getField . fieldName |