|
| 1 | +-- | |
| 2 | +-- Module : Streamly.FileSystem.FileIO |
| 3 | +-- Copyright : (c) 2019 Composewell Technologies |
| 4 | +-- |
| 5 | +-- License : BSD3 |
| 6 | +-- Maintainer : streamly@composewell.com |
| 7 | +-- Stability : pre-release |
| 8 | +-- Portability : GHC |
| 9 | +-- |
| 10 | +-- Read and write streams and arrays to and from files specified by their paths |
| 11 | +-- in the file system. Unlike the handle based APIs which can have a read/write |
| 12 | +-- session consisting of multiple reads and writes to the handle, these APIs |
| 13 | +-- are one shot read or write APIs. These APIs open the file handle, perform |
| 14 | +-- the requested operation and close the handle. These are safer compared to |
| 15 | +-- the handle based APIs as there is no possibility of a file descriptor |
| 16 | +-- leakage. |
| 17 | +-- |
| 18 | +-- >> import qualified Streamly.FileSystem.FileIO as File |
| 19 | +-- |
| 20 | +module Streamly.FileSystem.FileIO |
| 21 | + ( |
| 22 | + -- * Streaming IO |
| 23 | + -- | Stream data to or from a file or device sequentially. When reading, |
| 24 | + -- the stream is lazy and generated on-demand as the consumer consumes it. |
| 25 | + -- Read IO requests to the IO device are performed in chunks limited to a |
| 26 | + -- maximum size of 32KiB, this is referred to as @defaultChunkSize@ in the |
| 27 | + -- documentation. One IO request may or may not read the full |
| 28 | + -- chunk. If the whole stream is not consumed, it is possible that we may |
| 29 | + -- read slightly more from the IO device than what the consumer needed. |
| 30 | + -- Unless specified otherwise in the API, writes are collected into chunks |
| 31 | + -- of @defaultChunkSize@ before they are written to the IO device. |
| 32 | + |
| 33 | + -- Streaming APIs work for all kind of devices, seekable or non-seekable; |
| 34 | + -- including disks, files, memory devices, terminals, pipes, sockets and |
| 35 | + -- fifos. While random access APIs work only for files or devices that have |
| 36 | + -- random access or seek capability for example disks, memory devices. |
| 37 | + -- Devices like terminals, pipes, sockets and fifos do not have random |
| 38 | + -- access capability. |
| 39 | + |
| 40 | + -- ** File IO Using Handle |
| 41 | + withFile |
| 42 | + |
| 43 | + -- ** Streams |
| 44 | + , read |
| 45 | + , readChunksWith |
| 46 | + , readChunks |
| 47 | + |
| 48 | + -- ** Folds |
| 49 | + , write |
| 50 | + , writeWith |
| 51 | + , writeChunks |
| 52 | + ) |
| 53 | +where |
| 54 | + |
| 55 | +import Streamly.Internal.FileSystem.FileIO |
| 56 | +import Prelude hiding (read) |
0 commit comments