Safe Haskell | None |
---|
- overFilesIn :: FilePath -> StateMod -> IO [(FilePath, Maybe String)]
- getRtorrentFiles :: FilePath -> IO [FilePath]
- withRtorrentState :: FilePath -> StateMod -> IO (Maybe String)
- keepValid :: Map FilePath (Result StateFile) -> Map FilePath StateFile
- keepInvalid :: Map FilePath (Result StateFile) -> Map FilePath String
- parseFiles :: FilePath -> IO (Map FilePath (Result StateFile))
- parseFile :: FilePath -> IO (Result StateFile)
- parseFile' :: FilePath -> IO (FilePath, Result StateFile)
- startTorrent :: StateMod
- stopTorrent :: StateMod
- setTiedFile :: FilePath -> StateMod
- getLoadedFile :: StateFile -> FilePath
- decodeState :: ByteString -> Result StateFile
- encodeState :: StateFile -> ByteString
- encodeState' :: StateFile -> ByteString
Documentation
overFilesIn :: FilePath -> StateMod -> IO [(FilePath, Maybe String)]Source
Takes a directory, StateFile
modification function and does an
‘in-place’ modifications to all .rtorrent files it can find and
parse in that directory. Returns the list of all file paths and any
potential errors that with each.
See getRtorrentFiles
for the type of exception this function can throw.
getRtorrentFiles :: FilePath -> IO [FilePath]Source
Gets a list of all .rtorrent
files in the specified directory.
This function uses getDirectoryContents
which can throw various
IOExceptions. It's up to the user to catch these if they wish to do
so.
withRtorrentState :: FilePath -> StateMod -> IO (Maybe String)Source
Attempts to read in the file at specified file path, change it with the user-supplied function and saved the file with changes.
In case the parsing fails, the result will be Just errMsg
.
keepValid :: Map FilePath (Result StateFile) -> Map FilePath StateFileSource
Only keeps properly parsing results. Useful with parseFiles
.
keepInvalid :: Map FilePath (Result StateFile) -> Map FilePath StringSource
Similar to keepValid
but instead only keeps results that failed
to parse and the reason.
parseFiles :: FilePath -> IO (Map FilePath (Result StateFile))Source
Given a directory path, produces a Map
of file paths from
individual files to their parsing results.
This function uses getRtorrentFiles
which can throw an
IOException in case there is a problem reading the directory.
parseFile :: FilePath -> IO (Result StateFile)Source
Like parseFile'
but throws away the FilePath
: useful if we
only play with single files.
parseFile' :: FilePath -> IO (FilePath, Result StateFile)Source
Parses a file and returns a pair of of its path and the parsing result. The path is useful if we're processing whole directories.
startTorrent :: StateModSource
Sets the torrent to started state.
Sets the torrent to stopped stated.
setTiedFile :: FilePath -> StateModSource
Changes the file the torrent is tied to.
getLoadedFile :: StateFile -> FilePathSource
Gets a path of the loaded file.
encodeState :: StateFile -> ByteStringSource
Wrapper for encode
which works for StateFile
s.
See encodeState'
for strict ByteString
version.
encodeState' :: StateFile -> ByteStringSource
Encodes a StateFile
to a strict ByteString
.