-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileOps.hs
32 lines (22 loc) · 1014 Bytes
/
FileOps.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- File operations for the satellite record creator
module FileOps where
import System.Directory
import Dates
import Control.Monad (liftM)
years = map show [2013..]
months = map textNorm [1..12]
days = map textNorm [1..]
path prefix suffix (Date d m y i) =
prefix ++ "/" ++ show y ++ "/" ++ textNorm m ++ "/" ++ textNorm d ++ suffix
checkGot from = mapM_ (\x -> doesFileExist x >>= print) $ map (path "image-directory" ".jpg") $ take 366 $ iterate inc (startIn from)
data Satellite = Terra | Aqua
deriving Eq
suffix Terra = ".jpg"
suffix Aqua = "a.jpg"
checkYear year satellite = mapM doesFileExist paths >>=
print.and
where paths = map (path "image-directory" (suffix satellite)) $ theYear year
-- prepare year needs createDirectory and doesDirectoryExist. or just createDirectoryIfMissing
-- also, really should be catching errors!
-- also want to check for null files.
check satellite date = doesFileExist $ path "image-directory" (suffix satellite) date