Z-IO-0.6.4.0: Simple and high performance IO toolkit for Haskell
Copyright(c) Dong Han 2017-2020
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.IO.FileSystem.Threaded

Description

This module provides filesystem API exactly same with Base, operations(except seek) are implemented using libuv's threadpool to achieve non-block behavior (non-block here meaning won't block other haskell threads), which would be prefered when the operations' estimated time is long(>1ms) or running with a non-threaded haskell runtime, such as accessing network filesystem or scan a very large directory. Otherwise you may block RTS's capability thus all the other haskell threads live on it.

The threadpool version operations have overheads similar to safe FFI, but provide same adventages:

  • The libuv's threadpool have a limit on concurrent threads number (4 by default), which can reduce disk contention.
  • The threadpool version works with non-threaded runtime, which doesn't have safe FFI available.
  • The threadpool version won't relinquish current HEC (Haskell Execution Context) a.k.a. capability.

Most of the time you don't need this module though, since modern hardware(SSD) are sufficiently fast.

Synopsis

Regular file devices

data File Source #

File and its operations are NOT thread safe, use MVar File in multiple threads.

Note this is a differet data type from Z.IO.FileSystem 's one, the Input and Output instance use thread pool version functions.

libuv implements read and write method with both implict and explict offset capable. Implict offset interface is provided by Input / Output instances. Explict offset interface is provided by readFileP / writeFileP.

Instances

Instances details
Show File Source # 
Instance details

Defined in Z.IO.FileSystem.Threaded

Methods

showsPrec :: Int -> File -> ShowS #

show :: File -> String #

showList :: [File] -> ShowS #

Print File Source # 
Instance details

Defined in Z.IO.FileSystem.Threaded

Methods

toUTF8BuilderP :: Int -> File -> Builder () #

Output File Source # 
Instance details

Defined in Z.IO.FileSystem.Threaded

Methods

writeOutput :: File -> Ptr Word8 -> Int -> IO () Source #

Input File Source # 
Instance details

Defined in Z.IO.FileSystem.Threaded

Methods

readInput :: File -> Ptr Word8 -> Int -> IO Int Source #

initFile Source #

Arguments

:: CBytes 
-> FileFlag

Opening flags, e.g. O_CREAT .|. O_RDWR

-> FileMode

Sets the file mode (permission and sticky bits), but only if the file was created, see DEFAULT_FILE_MODE.

-> Resource File 

init a file Resource, which open a file when used.

Resource closing will wait for the referencing counter goes down to zero (no reading or writing is in process), which can be a problem if you are using multiple readers or writers in multiple threads. In that case you have to stop all reading or writing thread if you don't want to block the resource thread.

readFileP Source #

Arguments

:: HasCallStack 
=> File 
-> Ptr Word8

buffer

-> Int

buffer size

-> Int64

file offset, pass -1 to use default(system) offset

-> IO Int

read length

Read file with given offset

Read length may be smaller than buffer size.

writeFileP Source #

Arguments

:: HasCallStack 
=> File 
-> Ptr Word8

buffer

-> Int

buffer size

-> Int64

file offset, pass -1 to use default(system) offset

-> IO () 

Write buffer to file

This function will loop until all bytes are written.

Note on linux files opened with O_APPEND behave differently since this function use pwrite:

POSIX requires that opening a file with the O_APPEND flag should have no effect
on the location at which pwrite() writes data. However, on Linux,
if a file is opened with O_APPEND, pwrite() appends data to the end of the file,
regardless of the value of offset.

getFileFD :: File -> IO FD Source #

Return File fd.

seek :: HasCallStack => File -> Int64 -> Whence -> IO Int64 Source #

Set file's system offset.

Equivalent to lseek64(3).

readFile :: HasCallStack => CBytes -> IO Bytes Source #

Quickly open a file and read its content.

readTextFile :: HasCallStack => CBytes -> IO Text Source #

Quickly open a file and read its content as UTF8 text.

writeFile :: HasCallStack => CBytes -> Bytes -> IO () Source #

Quickly open a file and write some content.

writeTextFile :: HasCallStack => CBytes -> Text -> IO () Source #

Quickly open a file and write some content as UTF8 text.

readJSONFile :: (HasCallStack, JSON a) => CBytes -> IO a Source #

Quickly open a file and read its content as a JSON value. Throw OtherError with name EPARSE if JSON value is not parsed.

writeJSONFile :: (HasCallStack, JSON a) => CBytes -> a -> IO () Source #

Quickly open a file and write a JSON Value.

File offset bundle

data FilePtr Source #

File bundled with offset.

Reading or writing using Input / Output instance will automatically increase offset. FilePtr and its operations are NOT thread safe, use MVar FilePtr in multiple threads.

The notes on linux writeFileP applied to FilePtr too.

Instances

Instances details
Output FilePtr Source # 
Instance details

Defined in Z.IO.FileSystem.Threaded

Methods

writeOutput :: FilePtr -> Ptr Word8 -> Int -> IO () Source #

Input FilePtr Source # 
Instance details

Defined in Z.IO.FileSystem.Threaded

Methods

readInput :: FilePtr -> Ptr Word8 -> Int -> IO Int Source #

newFilePtr Source #

Arguments

:: File

the file we're reading

-> Int64

initial offset

-> IO FilePtr 

Create a file offset bundle from an File.

getFilePtrOffset :: FilePtr -> IO Int64 Source #

Get current offset.

setFilePtrOffset :: FilePtr -> Int64 -> IO () Source #

Change current offset.

Filesystem operations

mkdir :: HasCallStack => CBytes -> FileMode -> IO () Source #

Equivalent to mkdir(2).

Note mode is currently not implemented on Windows. On unix you should set execute bit if you want the directory is accessable, e.g. 0o777.

mkdirp :: HasCallStack => CBytes -> FileMode -> IO () Source #

Recursive directory creation function. Like mkdir, but makes all intermediate-level directories needed to contain the leaf directory.

Equivalent to mkdir -p,

Note mode is currently not implemented on Windows. On unix you should set execute bit if you want the directory is accessable(so that child folder can be created), e.g. DEFAULT_DIR_MODE.

unlink :: HasCallStack => CBytes -> IO () Source #

Equivalent to unlink(2).

mkdtemp :: HasCallStack => CBytes -> IO CBytes Source #

Equivalent to http://linux.die.net/man/3/mkdtemp

Creates a temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable, and searchable only by the creating user ID. The user of mkdtemp() is responsible for deleting the temporary directory and its contents when done with it.

Note: the argument is the prefix of the temporary directory, so no need to add XXXXXX ending.

initTempFile :: CBytes -> Resource File Source #

Make a temporary file under system getTempDir and automatically clean after used.

>>> withResource (initTempFile "foo") $ printStd
File 13

initTempDir :: CBytes -> Resource CBytes Source #

Make a temporary directory under system getTempDir and automatically clean after used.

>>> withResource (initTempDir "foo") $ printStd
"/tmp/fooxfWR0L"

rmdir :: HasCallStack => CBytes -> IO () Source #

Equivalent to rmdir(2).

Note this function may inherent OS limitations such as argument must be an empty folder.

rmrf :: HasCallStack => CBytes -> IO () Source #

Removes a file or directory at path together with its contents and subdirectories. Symbolic links are removed without affecting their targets. If the path does not exist, nothing happens.

data DirEntType Source #

Instances

Instances details
Enum DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Eq DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Ord DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Read DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Show DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Generic DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Associated Types

type Rep DirEntType :: Type -> Type #

JSON DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

Print DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep DirEntType Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep DirEntType = D1 ('MetaData "DirEntType" "Z.IO.UV.FFI" "Z-IO-0.6.4.0-3RdtkLMi3pWlcaS0GimBE" 'False) (((C1 ('MetaCons "DirEntUnknown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DirEntFile" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DirEntDir" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DirEntLink" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "DirEntFIFO" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DirEntSocket" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DirEntChar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DirEntBlock" 'PrefixI 'False) (U1 :: Type -> Type))))

scandir :: HasCallStack => CBytes -> IO [(CBytes, DirEntType)] Source #

Equivalent to scandir(3).

Note Unlike scandir(3), this function does not return the “.” and “..” entries.

Note On Linux, getting the type of an entry is only supported by some file systems (btrfs, ext2, ext3 and ext4 at the time of this writing), check the getdents(2) man page.

scandirRecursively :: HasCallStack => CBytes -> (CBytes -> DirEntType -> IO Bool) -> IO [CBytes] Source #

Find all files and directories within a given directory with a predicator.

 import Z.IO.FileSystem.FilePath (splitExtension)
 -- find all haskell source file within current dir
 scandirRecursively "."  (\ p _ -> (== ".hs") . snd <$> splitExtension p)

File stats

data FStat Source #

Instances

Instances details
Eq FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Methods

(==) :: FStat -> FStat -> Bool #

(/=) :: FStat -> FStat -> Bool #

Ord FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Methods

compare :: FStat -> FStat -> Ordering #

(<) :: FStat -> FStat -> Bool #

(<=) :: FStat -> FStat -> Bool #

(>) :: FStat -> FStat -> Bool #

(>=) :: FStat -> FStat -> Bool #

max :: FStat -> FStat -> FStat #

min :: FStat -> FStat -> FStat #

Read FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Show FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Methods

showsPrec :: Int -> FStat -> ShowS #

show :: FStat -> String #

showList :: [FStat] -> ShowS #

Generic FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Associated Types

type Rep FStat :: Type -> Type #

Methods

from :: FStat -> Rep FStat x #

to :: Rep FStat x -> FStat #

JSON FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Print FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

Methods

toUTF8BuilderP :: Int -> FStat -> Builder () #

type Rep FStat Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep FStat = D1 ('MetaData "FStat" "Z.IO.UV.FFI" "Z-IO-0.6.4.0-3RdtkLMi3pWlcaS0GimBE" 'False) (C1 ('MetaCons "FStat" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "stDev") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "stMode") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 FileMode)) :*: (S1 ('MetaSel ('Just "stNlink") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "stUID") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 UID))) :*: ((S1 ('MetaSel ('Just "stGID") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 GID) :*: S1 ('MetaSel ('Just "stRdev") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "stIno") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "stSize") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64)))) :*: (((S1 ('MetaSel ('Just "stBlksize") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "stBlocks") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "stFlags") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "stGen") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "stAtim") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 UVTimeSpec) :*: S1 ('MetaSel ('Just "stMtim") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 UVTimeSpec)) :*: (S1 ('MetaSel ('Just "stCtim") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 UVTimeSpec) :*: S1 ('MetaSel ('Just "stBirthtim") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 UVTimeSpec))))))

data UVTimeSpec Source #

Constructors

UVTimeSpec 

Instances

Instances details
Eq UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Ord UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Read UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Show UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Generic UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Associated Types

type Rep UVTimeSpec :: Type -> Type #

JSON UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Print UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

Storable UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep UVTimeSpec Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep UVTimeSpec = D1 ('MetaData "UVTimeSpec" "Z.IO.UV.FFI" "Z-IO-0.6.4.0-3RdtkLMi3pWlcaS0GimBE" 'False) (C1 ('MetaCons "UVTimeSpec" 'PrefixI 'True) (S1 ('MetaSel ('Just "uvtSecond") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 CLong) :*: S1 ('MetaSel ('Just "uvtNanoSecond") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 CLong)))

doesPathExist :: CBytes -> IO Bool Source #

Does given path exist?

doesFileExist :: CBytes -> IO Bool Source #

Returns True if the argument file exists and is either a file or a symbolic link to a file, and False otherwise.

doesDirExist :: CBytes -> IO Bool Source #

Returns True if the argument directory exists and is either a directory or a symbolic link to a directory, and False otherwise.

isLink :: HasCallStack => CBytes -> IO Bool Source #

If given path is a symbolic link?

isDir :: HasCallStack => CBytes -> IO Bool Source #

If given path is a directory or a symbolic link to a directory?

isFile :: HasCallStack => CBytes -> IO Bool Source #

If given path is a file or a symbolic link to a file?

isLinkSt :: FStat -> Bool Source #

Shortcut to \ st -> stMode st .&. S_IFMT == S_IFLNK

Note you should use lstat to get the link's stat.

isDirSt :: FStat -> Bool Source #

Shortcut to \ st -> stMode st .&. S_IFMT == S_IFDIR

isFileSt :: FStat -> Bool Source #

Shortcut to \ st -> stMode st .&. S_IFMT == S_IFREG

stat :: HasCallStack => CBytes -> IO FStat Source #

Equivalent to stat(2)

fstat :: HasCallStack => File -> IO FStat Source #

Equivalent to fstat(2)

stat' :: HasCallStack => CBytes -> IO (Maybe FStat) Source #

Equivalent to stat(2)

Return Nothing instead of throwing NoSuchThing if the file doesn't exist.

lstat' :: HasCallStack => CBytes -> IO (Maybe FStat) Source #

Equivalent to lstat(2)

Return Nothing instead of throwing NoSuchThing if the link doesn't exist.

rename :: HasCallStack => CBytes -> CBytes -> IO () Source #

Equivalent to rename(2).

Note On Windows if this function fails with UV_EBUSY, UV_EPERM or UV_EACCES, it will retry to rename the file up to four times with 250ms wait between attempts before giving up. If both path and new_path are existing directories this function will work only if target directory is empty.

fsync :: HasCallStack => File -> IO () Source #

Equivalent to fsync(2).

fdatasync :: HasCallStack => File -> IO () Source #

Equivalent to fdatasync(2).

ftruncate :: HasCallStack => File -> Int64 -> IO () Source #

Equivalent to ftruncate(2).

copyfile :: HasCallStack => CBytes -> CBytes -> CopyFileFlag -> IO () Source #

Copies a file from path to new_path.

Warning: If the destination path is created, but an error occurs while copying the data, then the destination path is removed. There is a brief window of time between closing and removing the file where another process could access the file.

data AccessResult Source #

Instances

Instances details
Enum AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

Eq AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

Ord AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

Show AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

Generic AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

Associated Types

type Rep AccessResult :: Type -> Type #

JSON AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

Print AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep AccessResult Source # 
Instance details

Defined in Z.IO.UV.FFI

type Rep AccessResult = D1 ('MetaData "AccessResult" "Z.IO.UV.FFI" "Z-IO-0.6.4.0-3RdtkLMi3pWlcaS0GimBE" 'False) (C1 ('MetaCons "NoExistence" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoPermission" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AccessOK" 'PrefixI 'False) (U1 :: Type -> Type)))

access :: HasCallStack => CBytes -> AccessMode -> IO AccessResult Source #

Equivalent to access(2) on Unix. Windows uses GetFileAttributesW().

chmod :: HasCallStack => CBytes -> FileMode -> IO () Source #

Equivalent to chmod(2).

fchmod :: HasCallStack => File -> FileMode -> IO () Source #

Equivalent to fchmod(2).

utime Source #

Arguments

:: HasCallStack 
=> CBytes 
-> Double

atime, i.e. access time

-> Double

mtime, i.e. modify time

-> IO () 

Equivalent to utime(2).

libuv choose Double type due to cross platform concerns, we only provide micro-second precision.

futime :: HasCallStack => File -> Double -> Double -> IO () Source #

Equivalent to futime(3).

Same precision notes with utime.

lutime Source #

Arguments

:: HasCallStack 
=> CBytes 
-> Double

atime, i.e. access time

-> Double

mtime, i.e. modify time

-> IO () 

Equivalent to lutime(3).

Same precision notes with utime.

link :: HasCallStack => CBytes -> CBytes -> IO () Source #

Equivalent to link(2).

symlink :: HasCallStack => CBytes -> CBytes -> SymlinkFlag -> IO () Source #

Equivalent to symlink(2).

| Note On Windows the flags parameter can be specified to control how the symlink will be created.

On other platforms these flags are ignored.

realpath :: HasCallStack => CBytes -> IO CBytes Source #

Equivalent to realpath(3) on Unix. Windows uses GetFinalPathNameByHandle.

Warning This function has certain platform-specific caveats that were discovered when used in Node.

  • macOS and other BSDs: this function will fail with UV_ELOOP if more than 32 symlinks are found while resolving the given path. This limit is hardcoded and cannot be sidestepped.
  • Windows: while this function works in the common case, there are a number of corner cases where it doesn’t:

    • Paths in ramdisk volumes created by tools which sidestep the Volume Manager (such as ImDisk) cannot be resolved.
    • Inconsistent casing when using drive letters.
    • Resolved path bypasses subst’d drives.

While this function can still be used, it’s not recommended if scenarios such as the above need to be supported. The background story and some more details on these issues can be checked here.

Note This function is not implemented on Windows XP and Windows Server 2003. On these systems, UV_ENOSYS is returned.

chown :: HasCallStack => CBytes -> UID -> GID -> IO () Source #

Equivalent to chown(2).

fchown :: HasCallStack => FD -> UID -> GID -> IO () Source #

Equivalent to fchown(2).

lchown :: HasCallStack => CBytes -> UID -> GID -> IO () Source #

Equivalent to lchown(2).

opening constant

AccessMode

pattern F_OK :: AccessMode Source #

pattern R_OK :: AccessMode Source #

pattern W_OK :: AccessMode Source #

pattern X_OK :: AccessMode Source #

FileMode

pattern DEFAULT_FILE_MODE :: FileMode Source #

Default mode for file open, 0x666(readable and writable).

pattern DEFAULT_DIR_MODE :: FileMode Source #

Default mode for open, 0x755.

pattern S_IRWXU :: FileMode Source #

00700 user (file owner) has read, write and execute permission

pattern S_IRUSR :: FileMode Source #

00400 user has read permission

pattern S_IWUSR :: FileMode Source #

00200 user has write permission

pattern S_IXUSR :: FileMode Source #

00100 user has execute permission

pattern S_IRWXG :: FileMode Source #

00070 group has read, write and execute permission

pattern S_IRGRP :: FileMode Source #

00040 group has read permission

pattern S_IWGRP :: FileMode Source #

00020 group has write permission

pattern S_IXGRP :: FileMode Source #

00010 group has execute permission

pattern S_IRWXO :: FileMode Source #

00007 others have read, write and execute permission

pattern S_IROTH :: FileMode Source #

00004 others have read permission

file type constant

pattern S_IFMT :: FileMode Source #

This is the file type mask.

pattern S_IFLNK :: FileMode Source #

This is the file type constant of a symbolic link.

pattern S_IFDIR :: FileMode Source #

This is the file type constant of a directory file.

pattern S_IFREG :: FileMode Source #

This is the file type constant of a regular file.

FileFlag

pattern O_APPEND :: FileFlag Source #

The file is opened in append mode. Before each write, the file offset is positioned at the end of the file.

pattern O_CREAT :: FileFlag Source #

The file is created if it does not already exist.

pattern O_DIRECT :: FileFlag Source #

File IO is done directly to and from user-space buffers, which must be aligned. Buffer size and address should be a multiple of the physical sector size of the block device, (DO NOT USE WITH Z-IO's BufferedIO)

pattern O_DSYNC :: FileFlag Source #

The file is opened for synchronous IO. Write operations will complete once all data and a minimum of metadata are flushed to disk.

Note O_DSYNC is supported on Windows via FILE_FLAG_WRITE_THROUGH.

pattern O_EXCL :: FileFlag Source #

If the O_CREAT flag is set and the file already exists, fail the open.

Note In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), the open will fail with the error EBUSY.

pattern O_EXLOCK :: FileFlag Source #

Atomically obtain an exclusive lock.

Note UV_FS_O_EXLOCK is only supported on macOS and Windows. (libuv: Changed in version 1.17.0: support is added for Windows.)

pattern O_NOATIME :: FileFlag Source #

Do not update the file access time when the file is read.

Note O_NOATIME is not supported on Windows.

pattern O_NOFOLLOW :: FileFlag Source #

If the path is a symbolic link, fail the open.

Note O_NOFOLLOW is not supported on Windows.

pattern O_RDONLY :: FileFlag Source #

Open the file for read-only access.

pattern O_RDWR :: FileFlag Source #

Open the file for read-write access.

pattern O_SYMLINK :: FileFlag Source #

Open the symbolic link itself rather than the resource it points to.

pattern O_SYNC :: FileFlag Source #

The file is opened for synchronous IO. Write operations will complete once all data and all metadata are flushed to disk.

Note O_SYNC is supported on Windows via FILE_FLAG_WRITE_THROUGH.

pattern O_TRUNC :: FileFlag Source #

If the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero.

pattern O_WRONLY :: FileFlag Source #

Open the file for write-only access.

pattern O_RANDOM :: FileFlag Source #

Access is intended to be random. The system can use this as a hint to optimize file caching.

Note O_RANDOM is only supported on Windows via FILE_FLAG_RANDOM_ACCESS.

pattern O_SHORT_LIVED :: FileFlag Source #

The file is temporary and should not be flushed to disk if possible.

Note O_SHORT_LIVED is only supported on Windows via FILE_ATTRIBUTE_TEMPORARY.

pattern O_SEQUENTIAL :: FileFlag Source #

Access is intended to be sequential from beginning to end. The system can use this as a hint to optimize file caching.

Note O_SEQUENTIAL is only supported on Windows via FILE_FLAG_SEQUENTIAL_SCAN.

pattern O_TEMPORARY :: FileFlag Source #

The file is temporary and should not be flushed to disk if possible.

Note O_TEMPORARY is only supported on Windows via FILE_ATTRIBUTE_TEMPORARY.

CopyFileFlag

type CopyFileFlag = CInt Source #

Flags control copying.

  • COPYFILE_EXCL: If present, uv_fs_copyfile() will fail with UV_EEXIST if the destination path already exists. The default behavior is to overwrite the destination if it exists.
  • COPYFILE_FICLONE: If present, uv_fs_copyfile() will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
  • COPYFILE_FICLONE_FORCE: If present, uv_fs_copyfile() will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, or an error occurs while attempting to use copy-on-write, then an error is returned.

SymlinkFlag

type SymlinkFlag = CInt Source #

On Windows the flags parameter can be specified to control how the symlink will be created: