diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-09-28 13:43:29 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:27:53 -0500 |
commit | 11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (patch) | |
tree | 5716463275c2d3e902889db619908ded2a73971c /bittorrent/examples/FS.hs | |
parent | add2c76bced51fde5e9917e7449ef52be70faf87 (diff) |
Factor out some new libraries
word64-map:
Data.Word64Map
network-addr:
Network.Address
tox-crypto:
Crypto.Tox
lifted-concurrent:
Control.Concurrent.Lifted.Instrument
Control.Concurrent.Async.Lifted.Instrument
psq-wrap:
Data.Wrapper.PSQInt
Data.Wrapper.PSQ
minmax-psq:
Data.MinMaxPSQ
tasks:
Control.Concurrent.Tasks
kad:
Network.Kademlia
Network.Kademlia.Bootstrap
Network.Kademlia.Routing
Network.Kademlia.CommonAPI
Network.Kademlia.Persistence
Network.Kademlia.Search
Diffstat (limited to 'bittorrent/examples/FS.hs')
-rw-r--r-- | bittorrent/examples/FS.hs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/bittorrent/examples/FS.hs b/bittorrent/examples/FS.hs deleted file mode 100644 index 550d85a7..00000000 --- a/bittorrent/examples/FS.hs +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | {-# LANGUAGE RecordWildCards #-} | ||
2 | module Main (main) where | ||
3 | |||
4 | import Control.Arrow | ||
5 | import Data.ByteString.Char8 as BC | ||
6 | import Data.List as L | ||
7 | import Data.Map as M | ||
8 | import Data.Torrent as T | ||
9 | import Data.Torrent.Tree as T | ||
10 | import System.Environment | ||
11 | import System.Fuse | ||
12 | import System.FilePath | ||
13 | import System.Posix.Files | ||
14 | |||
15 | |||
16 | defStat :: FileStat | ||
17 | defStat = FileStat | ||
18 | { statEntryType = Unknown | ||
19 | , statFileMode = ownerReadMode | ||
20 | , statLinkCount = 2 | ||
21 | |||
22 | , statFileOwner = 0 | ||
23 | , statFileGroup = 0 | ||
24 | |||
25 | , statSpecialDeviceID = 0 | ||
26 | |||
27 | , statFileSize = 0 | ||
28 | , statBlocks = 0 | ||
29 | |||
30 | , statAccessTime = 0 | ||
31 | , statModificationTime = 0 | ||
32 | , statStatusChangeTime = 0 | ||
33 | } | ||
34 | |||
35 | dirStat :: FileStat | ||
36 | dirStat = defStat { | ||
37 | statEntryType = Directory | ||
38 | } | ||
39 | |||
40 | type Result a = IO (Either Errno a) | ||
41 | type Result' = IO Errno | ||
42 | |||
43 | fsGetFileStat :: Torrent -> FilePath -> Result FileStat | ||
44 | fsGetFileStat _ path = return $ Right dirStat | ||
45 | |||
46 | fsOpenDirectory :: Torrent -> FilePath -> Result' | ||
47 | fsOpenDirectory _ _ = return eOK | ||
48 | |||
49 | fsReadDirectory :: Torrent -> FilePath -> Result [(FilePath, FileStat)] | ||
50 | fsReadDirectory Torrent {tInfoDict = InfoDict {..}} path | ||
51 | | Just cs <- T.lookupDir (L.tail (splitDirectories path)) tree = | ||
52 | return $ Right $ L.map (BC.unpack *** const defStat) cs | ||
53 | | otherwise = return $ Left eNOENT | ||
54 | where | ||
55 | tree = build $ idLayoutInfo | ||
56 | |||
57 | fsReleaseDirectory :: Torrent -> FilePath -> Result' | ||
58 | fsReleaseDirectory _ _ = return eOK | ||
59 | |||
60 | exfsOps :: Torrent -> FuseOperations () | ||
61 | exfsOps t = defaultFuseOps | ||
62 | { fuseGetFileStat = fsGetFileStat t | ||
63 | |||
64 | , fuseOpenDirectory = fsOpenDirectory t | ||
65 | , fuseReadDirectory = fsReadDirectory t | ||
66 | , fuseReleaseDirectory = fsReleaseDirectory t | ||
67 | } | ||
68 | |||
69 | main :: IO () | ||
70 | main = do | ||
71 | x : xs <- getArgs | ||
72 | t <- fromFile x | ||
73 | withArgs xs $ do | ||
74 | fuseMain (exfsOps t) defaultExceptionHandler \ No newline at end of file | ||