Win32-2.14.1.0: A binding to Windows Win32 API.
Copyright(c) Alastair Reid 1997-2003
LicenseBSD-style (see the file libraries/base/LICENSE)
MaintainerEsa Ilari Vuokko <ei@vuokko.info>
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

System.Win32.File

Description

A collection of FFI declarations for interfacing with Win32.

Synopsis

Access modes

Sharing modes

Creation modes

File attributes and flags

Move file flags

File pointer directions

Drive types

Define DOS device flags

Binary types

File notification flags

File types

Lock modes

GetFileEx information levels

Security attributes

BY_HANDLE file information

Win32 file attribute data

Helpers

failIfWithRetry :: (a -> Bool) -> String -> IO a -> IO a Source #

like failIf, but retried on sharing violations. This is necessary for many file operations; see https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/316609

failIfWithRetry_ :: (a -> Bool) -> String -> IO a -> IO () Source #

failIfFalseWithRetry_ :: String -> IO Bool -> IO () Source #

File operations

deleteFile :: String -> IO () Source #

copyFile :: String -> String -> Bool -> IO () Source #

moveFile :: String -> String -> IO () Source #

moveFileEx :: String -> Maybe String -> MoveFileFlag -> IO () Source #

setCurrentDirectory :: String -> IO () Source #

createDirectory :: String -> Maybe LPSECURITY_ATTRIBUTES -> IO () Source #

createDirectoryEx :: String -> String -> Maybe LPSECURITY_ATTRIBUTES -> IO () Source #

removeDirectory :: String -> IO () Source #

getTempFileName Source #

Arguments

:: String

directory for the temporary file (must be at most MAX_PATH - 14 characters long)

-> String

prefix for the temporary file name

-> Maybe UINT

if Nothing, a unique name is generated otherwise a non-zero value is used as the unique part

-> IO (String, UINT) 

Get a unique temporary filename.

Calls GetTempFileNameW.

HANDLE operations

createFile_NoRetry :: String -> AccessMode -> ShareMode -> Maybe LPSECURITY_ATTRIBUTES -> CreateMode -> FileAttributeOrFlag -> Maybe HANDLE -> IO HANDLE Source #

Like createFile, but does not use failIfWithRetry. If another process has the same file open, this will fail.

Reading/writing

Some operations below bear the win32_ prefix to avoid shadowing operations from Prelude.

data OVERLAPPED Source #

Instances

Instances details
Show OVERLAPPED Source # 
Instance details

Defined in System.Win32.File.Internal

Methods

showsPrec :: Int -> OVERLAPPED -> ShowS

show :: OVERLAPPED -> String

showList :: [OVERLAPPED] -> ShowS

Storable OVERLAPPED Source # 
Instance details

Defined in System.Win32.File.Internal

Methods

sizeOf :: OVERLAPPED -> Int

alignment :: OVERLAPPED -> Int

peekElemOff :: Ptr OVERLAPPED -> Int -> IO OVERLAPPED

pokeElemOff :: Ptr OVERLAPPED -> Int -> OVERLAPPED -> IO ()

peekByteOff :: Ptr b -> Int -> IO OVERLAPPED

pokeByteOff :: Ptr b -> Int -> OVERLAPPED -> IO ()

peek :: Ptr OVERLAPPED -> IO OVERLAPPED

poke :: Ptr OVERLAPPED -> OVERLAPPED -> IO ()

win32_ReadFile :: HANDLE -> Ptr a -> DWORD -> Maybe LPOVERLAPPED -> IO DWORD Source #

win32_WriteFile :: HANDLE -> Ptr a -> DWORD -> Maybe LPOVERLAPPED -> IO DWORD Source #

File notifications

Directories

findFirstFile :: String -> IO (HANDLE, FindData) Source #

findClose :: HANDLE -> IO () Source #

DOS device flags

defineDosDevice :: DefineDosDeviceFlags -> String -> Maybe String -> IO () Source #

getDiskFreeSpace :: Maybe String -> IO (DWORD, DWORD, DWORD, DWORD) Source #

setVolumeLabel :: Maybe String -> Maybe String -> IO () Source #

File locks

lockFile Source #

Arguments

:: HANDLE

CreateFile handle

-> LockMode

Locking mode

-> DWORD64

Size of region to lock

-> DWORD64

Beginning offset of file to lock

-> IO BOOL

Indicates if locking was successful, if not query getLastError.

Locks a given range in a file handle, To lock an entire file use 0xFFFFFFFFFFFFFFFF for size and 0 for offset.

unlockFile Source #

Arguments

:: HANDLE

CreateFile handle

-> DWORD64

Size of region to unlock

-> DWORD64

Beginning offset of file to unlock

-> IO BOOL

Indicates if unlocking was successful, if not query getLastError.

Unlocks a given range in a file handle, To unlock an entire file use 0xFFFFFFFFFFFFFFFF for size and 0 for offset.