Created
December 9, 2014 20:29
-
-
Save m15k/7190b78d63e88b0bc01d to your computer and use it in GitHub Desktop.
Assist with possible pipes safe issue on Win32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Info = Info { | |
infoPath :: FilePath | |
, infoPerms :: Permissions | |
, infoSize :: Maybe Integer | |
, infoModTime :: UTCTime | |
, infoVariance :: Double | |
} deriving (Eq, Show, Ord) | |
-- | main executable function | |
-- will recurse through directories and unlock all the goodies | |
scanFileSystemPrototype :: FilePath -> ListT (SafeT IO) Info | |
scanFileSystemPrototype root = do | |
file <- recursiveContents (FP.decodeString root) | |
guard (filterData (FP.encodeString file)) | |
perms <- liftIO (getPermissions (FP.encodeString file)) | |
guard (readable perms) -- assert that file can be manipulated by executing account | |
liftIO (checkFile perms (FP.encodeString file)) | |
where | |
checkFile fnAttr filename = do | |
size <- getFileSize filename | |
modified <- getModificationTime filename | |
vari <- computeVariance filename | |
fn <- absolutize filename | |
return $ Info fn fnAttr size modified vari | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment