Portability | portable |
---|---|
Stability | experimental |
Maintainer | Stefan Schmidt (stefanschmidt@web.de) |
Version : 0.1
This Module contains the typeclass of a storage and the associated datatypes.
- type FileId = String
- type FileContent = ByteString
- getContentLength :: FileContent -> Integer
- data FileData = MkFileData {}
- createFileData :: FileId -> FileContent -> IO FileData
- updateFileData :: FileData -> FileData -> FileData
- class Storage s where
- openStorage :: s -> IO s
- closeStorage :: s -> IO s
- createFile :: s -> FileId -> FileContent -> IO s
- createFiles :: s -> [(FileId, FileContent)] -> IO s
- deleteFile :: s -> FileId -> IO s
- appendFile :: s -> FileId -> FileContent -> IO s
- containsFile :: s -> FileId -> IO Bool
- getFileContent :: s -> FileId -> IO (Maybe FileContent)
- getFileData :: s -> FileId -> IO (Maybe FileData)
- getFileIds :: s -> IO [FileId]
file datatypes
The file-identifier, should be unique in the whole system and be an instance of the classes show, eq, ord and binary
type FileContent = ByteStringSource
file operation
metadata
metadata of a file, known by the storage.
MkFileData | |
|
createFileData :: FileId -> FileContent -> IO FileDataSource
Create a new file data item.
updateFileData :: FileData -> FileData -> FileDataSource
Updates a new file data item with the date, size and hash value of an old one. First parameter is the new item, second the old one.
storage typeclass
The interface of a storage.
openStorage :: s -> IO sSource
Initialize the storage.
closeStorage :: s -> IO sSource
Deinitialize the storage.
createFile :: s -> FileId -> FileContent -> IO sSource
Create a new file in the storage. Overwrite the file if it already exists.
createFiles :: s -> [(FileId, FileContent)] -> IO sSource
deleteFile :: s -> FileId -> IO sSource
Delete a file in the storage. Nothing happens if the file doesn't exist
appendFile :: s -> FileId -> FileContent -> IO sSource
Append the content of the file. Create a new file, if it doesn't already exist
containsFile :: s -> FileId -> IO BoolSource
Check if the file is already in the storage
getFileContent :: s -> FileId -> IO (Maybe FileContent)Source
Get the content of a file. Return Nothing, if the file doesn't exist
getFileData :: s -> FileId -> IO (Maybe FileData)Source
Get the metadata of a file. Return Nothing, if the file doesn't exist
getFileIds :: s -> IO [FileId]Source
List the files in the storage
Storage FileStorage | deriving FileStorage from the class Storage |