@@ -4,90 +4,86 @@ import qualified Node.FS.Async as A
44import qualified Node.FS.Sync as S
55import Node.FS.Stats
66import Control.Apply ((*>))
7+ import Control.Monad.Eff.Exception
78import Data.Either
89import Debug.Trace
910import Node.Encoding
1011
11- trace' x = trace x *> return unit
12-
1312main = do
1413
1514 file <- S .readTextFile UTF8 " examples\\ Test.purs"
16- trace' " \n\n readTextFile sync result:"
17- case file of
18- Right file' -> trace' $ file'
15+ trace " \n\n readTextFile sync result:"
16+ trace $ file
1917
20- err <- S .readTextFile UTF8 " examples \\ does not exist "
21- case err of
22- Left err' -> trace' $ " Caught readTextFile error: \n " ++ show err'
18+ catchException (\ err -> do
19+ trace $ " Caught readTextFile error: \n " ++ show err
20+ return " " ) $ S . readTextFile UTF8 " examples \\ does not exist "
2321
2422 S .rename " tmp\\ Test.js" " tmp\\ Test1.js"
2523
2624 S .truncate " tmp\\ Test1.js" 1000
2725
2826 stats <- S .stat " tmp\\ Test1.js"
29- case stats of
30- Right stats' -> do
31- trace " \n\n S.stat:"
32- trace' " isFile:"
33- trace' $ show $ isFile stats'
34- trace' " isDirectory:"
35- trace' $ show $ isDirectory stats'
36- trace' " isBlockDevice:"
37- trace' $ show $ isBlockDevice stats'
38- trace' " isCharacterDevice:"
39- trace' $ show $ isCharacterDevice stats'
40- trace' " isFIFO:"
41- trace' $ show $ isFIFO stats'
42- trace' " isSocket:"
43- trace' $ show $ isSocket stats'
44- trace' " isSymbolicLink:"
45- trace' $ show $ isSymbolicLink stats'
46- trace' " modifiedTime:"
47- trace' $ show $ modifiedTime stats'
48- trace' " accessedTime:"
49- trace' $ show $ accessedTime stats'
50- trace' " statusChangedTime:"
51- trace' $ show $ statusChangedTime stats'
27+ trace " \n\n S.stat:"
28+ trace " isFile:"
29+ trace $ show $ isFile stats
30+ trace " isDirectory:"
31+ trace $ show $ isDirectory stats
32+ trace " isBlockDevice:"
33+ trace $ show $ isBlockDevice stats
34+ trace " isCharacterDevice:"
35+ trace $ show $ isCharacterDevice stats
36+ trace " isFIFO:"
37+ trace $ show $ isFIFO stats
38+ trace " isSocket:"
39+ trace $ show $ isSocket stats
40+ trace " isSymbolicLink:"
41+ trace $ show $ isSymbolicLink stats
42+ trace " modifiedTime:"
43+ trace $ show $ modifiedTime stats
44+ trace " accessedTime:"
45+ trace $ show $ accessedTime stats
46+ trace " statusChangedTime:"
47+ trace $ show $ statusChangedTime stats
5248
5349 A .rename " tmp\\ Test1.js" " tmp\\ Test.js" $ \x -> do
5450 trace " \n\n rename result:"
55- either (trace' <<< show) (trace' <<< show) x
51+ either (trace <<< show) (trace <<< show) x
5652
5753 A .truncate " tmp\\ Test.js" 10 $ \x -> do
5854 trace " \n\n truncate result:"
59- either (trace' <<< show) (trace' <<< show) x
55+ either (trace <<< show) (trace <<< show) x
6056
6157 A .readFile " examples\\ Test.purs" $ \x -> do
6258 trace " \n\n readFile result:"
63- either (trace' <<< show) (trace' <<< show) x
59+ either (trace <<< show) (trace <<< show) x
6460
6561 A .readTextFile UTF8 " examples\\ Test.purs" $ \x -> do
6662 trace " \n\n readTextFile result:"
67- either (trace' <<< show) trace' x
63+ either (trace <<< show) trace x
6864
6965 A .stat " examples\\ Test.purs" $ \x -> do
7066 trace " \n\n stat:"
7167 case x of
72- Left err -> trace' $ " Error:" ++ show err
68+ Left err -> trace $ " Error:" ++ show err
7369 Right x' -> do
74- trace' " isFile:"
75- trace' $ show $ isFile x'
76- trace' " isDirectory:"
77- trace' $ show $ isDirectory x'
78- trace' " isBlockDevice:"
79- trace' $ show $ isBlockDevice x'
80- trace' " isCharacterDevice:"
81- trace' $ show $ isCharacterDevice x'
82- trace' " isFIFO:"
83- trace' $ show $ isFIFO x'
84- trace' " isSocket:"
85- trace' $ show $ isSocket x'
86- trace' " isSymbolicLink:"
87- trace' $ show $ isSymbolicLink x'
88- trace' " modifiedTime:"
89- trace' $ show $ modifiedTime x'
90- trace' " accessedTime:"
91- trace' $ show $ accessedTime x'
92- trace' " statusChangedTime:"
93- trace' $ show $ statusChangedTime x'
70+ trace " isFile:"
71+ trace $ show $ isFile x'
72+ trace " isDirectory:"
73+ trace $ show $ isDirectory x'
74+ trace " isBlockDevice:"
75+ trace $ show $ isBlockDevice x'
76+ trace " isCharacterDevice:"
77+ trace $ show $ isCharacterDevice x'
78+ trace " isFIFO:"
79+ trace $ show $ isFIFO x'
80+ trace " isSocket:"
81+ trace $ show $ isSocket x'
82+ trace " isSymbolicLink:"
83+ trace $ show $ isSymbolicLink x'
84+ trace " modifiedTime:"
85+ trace $ show $ modifiedTime x'
86+ trace " accessedTime:"
87+ trace $ show $ accessedTime x'
88+ trace " statusChangedTime:"
89+ trace $ show $ statusChangedTime x'
0 commit comments