Copyright | (c) Alastair Reid 1997-2003 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | Esa Ilari Vuokko <ei@vuokko.info> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
- 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
- File operations
- HANDLE operations
- File notifications
- Directories
- DOS device flags
- File locks
A collection of FFI declarations for interfacing with Win32.
Synopsis
- type AccessMode = UINT
- gENERIC_NONE :: AccessMode
- gENERIC_READ :: AccessMode
- gENERIC_WRITE :: AccessMode
- gENERIC_EXECUTE :: AccessMode
- gENERIC_ALL :: AccessMode
- dELETE :: AccessMode
- rEAD_CONTROL :: AccessMode
- wRITE_DAC :: AccessMode
- wRITE_OWNER :: AccessMode
- sYNCHRONIZE :: AccessMode
- sTANDARD_RIGHTS_REQUIRED :: AccessMode
- sTANDARD_RIGHTS_READ :: AccessMode
- sTANDARD_RIGHTS_WRITE :: AccessMode
- sTANDARD_RIGHTS_EXECUTE :: AccessMode
- sTANDARD_RIGHTS_ALL :: AccessMode
- sPECIFIC_RIGHTS_ALL :: AccessMode
- aCCESS_SYSTEM_SECURITY :: AccessMode
- mAXIMUM_ALLOWED :: AccessMode
- fILE_ADD_FILE :: AccessMode
- fILE_ADD_SUBDIRECTORY :: AccessMode
- fILE_ALL_ACCESS :: AccessMode
- fILE_APPEND_DATA :: AccessMode
- fILE_CREATE_PIPE_INSTANCE :: AccessMode
- fILE_DELETE_CHILD :: AccessMode
- fILE_EXECUTE :: AccessMode
- fILE_LIST_DIRECTORY :: AccessMode
- fILE_READ_ATTRIBUTES :: AccessMode
- fILE_READ_DATA :: AccessMode
- fILE_READ_EA :: AccessMode
- fILE_TRAVERSE :: AccessMode
- fILE_WRITE_ATTRIBUTES :: AccessMode
- fILE_WRITE_DATA :: AccessMode
- fILE_WRITE_EA :: AccessMode
- type ShareMode = UINT
- fILE_SHARE_NONE :: ShareMode
- fILE_SHARE_READ :: ShareMode
- fILE_SHARE_WRITE :: ShareMode
- fILE_SHARE_DELETE :: ShareMode
- type CreateMode = UINT
- cREATE_NEW :: CreateMode
- cREATE_ALWAYS :: CreateMode
- oPEN_EXISTING :: CreateMode
- oPEN_ALWAYS :: CreateMode
- tRUNCATE_EXISTING :: CreateMode
- type FileAttributeOrFlag = UINT
- fILE_ATTRIBUTE_READONLY :: FileAttributeOrFlag
- fILE_ATTRIBUTE_HIDDEN :: FileAttributeOrFlag
- fILE_ATTRIBUTE_SYSTEM :: FileAttributeOrFlag
- fILE_ATTRIBUTE_DIRECTORY :: FileAttributeOrFlag
- fILE_ATTRIBUTE_ARCHIVE :: FileAttributeOrFlag
- fILE_ATTRIBUTE_NORMAL :: FileAttributeOrFlag
- fILE_ATTRIBUTE_TEMPORARY :: FileAttributeOrFlag
- fILE_ATTRIBUTE_COMPRESSED :: FileAttributeOrFlag
- fILE_ATTRIBUTE_REPARSE_POINT :: FileAttributeOrFlag
- fILE_FLAG_WRITE_THROUGH :: FileAttributeOrFlag
- fILE_FLAG_OVERLAPPED :: FileAttributeOrFlag
- fILE_FLAG_NO_BUFFERING :: FileAttributeOrFlag
- fILE_FLAG_RANDOM_ACCESS :: FileAttributeOrFlag
- fILE_FLAG_SEQUENTIAL_SCAN :: FileAttributeOrFlag
- fILE_FLAG_DELETE_ON_CLOSE :: FileAttributeOrFlag
- fILE_FLAG_BACKUP_SEMANTICS :: FileAttributeOrFlag
- fILE_FLAG_POSIX_SEMANTICS :: FileAttributeOrFlag
- sECURITY_ANONYMOUS :: FileAttributeOrFlag
- sECURITY_IDENTIFICATION :: FileAttributeOrFlag
- sECURITY_IMPERSONATION :: FileAttributeOrFlag
- sECURITY_DELEGATION :: FileAttributeOrFlag
- sECURITY_CONTEXT_TRACKING :: FileAttributeOrFlag
- sECURITY_EFFECTIVE_ONLY :: FileAttributeOrFlag
- sECURITY_SQOS_PRESENT :: FileAttributeOrFlag
- sECURITY_VALID_SQOS_FLAGS :: FileAttributeOrFlag
- type MoveFileFlag = DWORD
- mOVEFILE_REPLACE_EXISTING :: MoveFileFlag
- mOVEFILE_COPY_ALLOWED :: MoveFileFlag
- mOVEFILE_DELAY_UNTIL_REBOOT :: MoveFileFlag
- type FilePtrDirection = DWORD
- fILE_BEGIN :: FilePtrDirection
- fILE_CURRENT :: FilePtrDirection
- fILE_END :: FilePtrDirection
- type DriveType = UINT
- dRIVE_UNKNOWN :: DriveType
- dRIVE_NO_ROOT_DIR :: DriveType
- dRIVE_REMOVABLE :: DriveType
- dRIVE_FIXED :: DriveType
- dRIVE_REMOTE :: DriveType
- dRIVE_CDROM :: DriveType
- dRIVE_RAMDISK :: DriveType
- type DefineDosDeviceFlags = DWORD
- dDD_RAW_TARGET_PATH :: DefineDosDeviceFlags
- dDD_REMOVE_DEFINITION :: DefineDosDeviceFlags
- dDD_EXACT_MATCH_ON_REMOVE :: DefineDosDeviceFlags
- type BinaryType = DWORD
- sCS_32BIT_BINARY :: BinaryType
- sCS_DOS_BINARY :: BinaryType
- sCS_WOW_BINARY :: BinaryType
- sCS_PIF_BINARY :: BinaryType
- sCS_POSIX_BINARY :: BinaryType
- sCS_OS216_BINARY :: BinaryType
- type FileNotificationFlag = DWORD
- fILE_NOTIFY_CHANGE_FILE_NAME :: FileNotificationFlag
- fILE_NOTIFY_CHANGE_DIR_NAME :: FileNotificationFlag
- fILE_NOTIFY_CHANGE_ATTRIBUTES :: FileNotificationFlag
- fILE_NOTIFY_CHANGE_SIZE :: FileNotificationFlag
- fILE_NOTIFY_CHANGE_LAST_WRITE :: FileNotificationFlag
- fILE_NOTIFY_CHANGE_SECURITY :: FileNotificationFlag
- type FileType = DWORD
- fILE_TYPE_UNKNOWN :: FileType
- fILE_TYPE_DISK :: FileType
- fILE_TYPE_CHAR :: FileType
- fILE_TYPE_PIPE :: FileType
- fILE_TYPE_REMOTE :: FileType
- type LockMode = DWORD
- lOCKFILE_EXCLUSIVE_LOCK :: LockMode
- lOCKFILE_FAIL_IMMEDIATELY :: LockMode
- data GET_FILEEX_INFO_LEVELS
- getFileExInfoStandard :: GET_FILEEX_INFO_LEVELS
- getFileExMaxInfoLevel :: GET_FILEEX_INFO_LEVELS
- data SECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES {
- nLength :: !DWORD
- lpSecurityDescriptor :: !LPVOID
- bInheritHandle :: !BOOL
- type PSECURITY_ATTRIBUTES = Ptr SECURITY_ATTRIBUTES
- type LPSECURITY_ATTRIBUTES = Ptr SECURITY_ATTRIBUTES
- type MbLPSECURITY_ATTRIBUTES = Maybe LPSECURITY_ATTRIBUTES
- data BY_HANDLE_FILE_INFORMATION = BY_HANDLE_FILE_INFORMATION {}
- data WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA {}
- failIfWithRetry :: (a -> Bool) -> String -> IO a -> IO a
- failIfWithRetry_ :: (a -> Bool) -> String -> IO a -> IO ()
- failIfFalseWithRetry_ :: String -> IO Bool -> IO ()
- deleteFile :: String -> IO ()
- copyFile :: String -> String -> Bool -> IO ()
- moveFile :: String -> String -> IO ()
- moveFileEx :: String -> Maybe String -> MoveFileFlag -> IO ()
- setCurrentDirectory :: String -> IO ()
- createDirectory :: String -> Maybe LPSECURITY_ATTRIBUTES -> IO ()
- createDirectoryEx :: String -> String -> Maybe LPSECURITY_ATTRIBUTES -> IO ()
- removeDirectory :: String -> IO ()
- getBinaryType :: String -> IO BinaryType
- getTempFileName :: String -> String -> Maybe UINT -> IO (String, UINT)
- createFile :: String -> AccessMode -> ShareMode -> Maybe LPSECURITY_ATTRIBUTES -> CreateMode -> FileAttributeOrFlag -> Maybe HANDLE -> IO HANDLE
- createFile_NoRetry :: String -> AccessMode -> ShareMode -> Maybe LPSECURITY_ATTRIBUTES -> CreateMode -> FileAttributeOrFlag -> Maybe HANDLE -> IO HANDLE
- closeHandle :: HANDLE -> IO ()
- getFileType :: HANDLE -> IO FileType
- flushFileBuffers :: HANDLE -> IO ()
- setEndOfFile :: HANDLE -> IO ()
- setFileAttributes :: String -> FileAttributeOrFlag -> IO ()
- getFileAttributes :: String -> IO FileAttributeOrFlag
- getFileAttributesExStandard :: String -> IO WIN32_FILE_ATTRIBUTE_DATA
- getFileInformationByHandle :: HANDLE -> IO BY_HANDLE_FILE_INFORMATION
- data OVERLAPPED = OVERLAPPED {}
- type LPOVERLAPPED = Ptr OVERLAPPED
- type MbLPOVERLAPPED = Maybe LPOVERLAPPED
- win32_ReadFile :: HANDLE -> Ptr a -> DWORD -> Maybe LPOVERLAPPED -> IO DWORD
- win32_WriteFile :: HANDLE -> Ptr a -> DWORD -> Maybe LPOVERLAPPED -> IO DWORD
- setFilePointerEx :: HANDLE -> LARGE_INTEGER -> FilePtrDirection -> IO LARGE_INTEGER
- findFirstChangeNotification :: String -> Bool -> FileNotificationFlag -> IO HANDLE
- findNextChangeNotification :: HANDLE -> IO ()
- findCloseChangeNotification :: HANDLE -> IO ()
- data FindData
- getFindDataFileName :: FindData -> IO FilePath
- findFirstFile :: String -> IO (HANDLE, FindData)
- findNextFile :: HANDLE -> FindData -> IO Bool
- findClose :: HANDLE -> IO ()
- defineDosDevice :: DefineDosDeviceFlags -> String -> Maybe String -> IO ()
- areFileApisANSI :: IO Bool
- setFileApisToOEM :: IO ()
- setFileApisToANSI :: IO ()
- setHandleCount :: UINT -> IO UINT
- getLogicalDrives :: IO DWORD
- getDiskFreeSpace :: Maybe String -> IO (DWORD, DWORD, DWORD, DWORD)
- setVolumeLabel :: Maybe String -> Maybe String -> IO ()
- lockFile :: HANDLE -> LockMode -> DWORD64 -> DWORD64 -> IO BOOL
- unlockFile :: HANDLE -> DWORD64 -> DWORD64 -> IO BOOL
Access modes
type AccessMode = UINT Source #
dELETE :: AccessMode Source #
Sharing modes
Creation modes
type CreateMode = UINT Source #
File attributes and flags
type FileAttributeOrFlag = UINT Source #
Move file flags
type MoveFileFlag = DWORD Source #
File pointer directions
type FilePtrDirection = DWORD Source #
Drive types
Define DOS device flags
type DefineDosDeviceFlags = DWORD Source #
Binary types
type BinaryType = DWORD Source #
File notification flags
type FileNotificationFlag = DWORD Source #
File types
Lock modes
GetFileEx information levels
data GET_FILEEX_INFO_LEVELS Source #
Instances
Eq GET_FILEEX_INFO_LEVELS Source # | |
Defined in System.Win32.File.Internal (==) :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Bool (/=) :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Bool | |
Ord GET_FILEEX_INFO_LEVELS Source # | |
Defined in System.Win32.File.Internal compare :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Ordering (<) :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Bool (<=) :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Bool (>) :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Bool (>=) :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> Bool max :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS min :: GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS -> GET_FILEEX_INFO_LEVELS |
Security attributes
data SECURITY_ATTRIBUTES Source #
Instances
Show SECURITY_ATTRIBUTES Source # | |
Defined in System.Win32.File.Internal showsPrec :: Int -> SECURITY_ATTRIBUTES -> ShowS show :: SECURITY_ATTRIBUTES -> String showList :: [SECURITY_ATTRIBUTES] -> ShowS | |
Storable SECURITY_ATTRIBUTES Source # | |
Defined in System.Win32.File.Internal sizeOf :: SECURITY_ATTRIBUTES -> Int alignment :: SECURITY_ATTRIBUTES -> Int peekElemOff :: Ptr SECURITY_ATTRIBUTES -> Int -> IO SECURITY_ATTRIBUTES pokeElemOff :: Ptr SECURITY_ATTRIBUTES -> Int -> SECURITY_ATTRIBUTES -> IO () peekByteOff :: Ptr b -> Int -> IO SECURITY_ATTRIBUTES pokeByteOff :: Ptr b -> Int -> SECURITY_ATTRIBUTES -> IO () peek :: Ptr SECURITY_ATTRIBUTES -> IO SECURITY_ATTRIBUTES poke :: Ptr SECURITY_ATTRIBUTES -> SECURITY_ATTRIBUTES -> IO () |
type PSECURITY_ATTRIBUTES = Ptr SECURITY_ATTRIBUTES Source #
type LPSECURITY_ATTRIBUTES = Ptr SECURITY_ATTRIBUTES Source #
type MbLPSECURITY_ATTRIBUTES = Maybe LPSECURITY_ATTRIBUTES Source #
BY_HANDLE file information
data BY_HANDLE_FILE_INFORMATION Source #
Instances
Show BY_HANDLE_FILE_INFORMATION Source # | |
Defined in System.Win32.File.Internal showsPrec :: Int -> BY_HANDLE_FILE_INFORMATION -> ShowS show :: BY_HANDLE_FILE_INFORMATION -> String showList :: [BY_HANDLE_FILE_INFORMATION] -> ShowS | |
Storable BY_HANDLE_FILE_INFORMATION Source # | |
Defined in System.Win32.File.Internal sizeOf :: BY_HANDLE_FILE_INFORMATION -> Int alignment :: BY_HANDLE_FILE_INFORMATION -> Int peekElemOff :: Ptr BY_HANDLE_FILE_INFORMATION -> Int -> IO BY_HANDLE_FILE_INFORMATION pokeElemOff :: Ptr BY_HANDLE_FILE_INFORMATION -> Int -> BY_HANDLE_FILE_INFORMATION -> IO () peekByteOff :: Ptr b -> Int -> IO BY_HANDLE_FILE_INFORMATION pokeByteOff :: Ptr b -> Int -> BY_HANDLE_FILE_INFORMATION -> IO () peek :: Ptr BY_HANDLE_FILE_INFORMATION -> IO BY_HANDLE_FILE_INFORMATION poke :: Ptr BY_HANDLE_FILE_INFORMATION -> BY_HANDLE_FILE_INFORMATION -> IO () |
Win32 file attribute data
data WIN32_FILE_ATTRIBUTE_DATA Source #
Instances
Show WIN32_FILE_ATTRIBUTE_DATA Source # | |
Defined in System.Win32.File.Internal showsPrec :: Int -> WIN32_FILE_ATTRIBUTE_DATA -> ShowS show :: WIN32_FILE_ATTRIBUTE_DATA -> String showList :: [WIN32_FILE_ATTRIBUTE_DATA] -> ShowS | |
Storable WIN32_FILE_ATTRIBUTE_DATA Source # | |
Defined in System.Win32.File.Internal sizeOf :: WIN32_FILE_ATTRIBUTE_DATA -> Int alignment :: WIN32_FILE_ATTRIBUTE_DATA -> Int peekElemOff :: Ptr WIN32_FILE_ATTRIBUTE_DATA -> Int -> IO WIN32_FILE_ATTRIBUTE_DATA pokeElemOff :: Ptr WIN32_FILE_ATTRIBUTE_DATA -> Int -> WIN32_FILE_ATTRIBUTE_DATA -> IO () peekByteOff :: Ptr b -> Int -> IO WIN32_FILE_ATTRIBUTE_DATA pokeByteOff :: Ptr b -> Int -> WIN32_FILE_ATTRIBUTE_DATA -> IO () peek :: Ptr WIN32_FILE_ATTRIBUTE_DATA -> IO WIN32_FILE_ATTRIBUTE_DATA poke :: Ptr WIN32_FILE_ATTRIBUTE_DATA -> WIN32_FILE_ATTRIBUTE_DATA -> IO () |
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 #
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 #
getBinaryType :: String -> IO BinaryType Source #
:: 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 |
-> IO (String, UINT) |
Get a unique temporary filename.
Calls GetTempFileNameW
.
HANDLE operations
createFile :: String -> AccessMode -> ShareMode -> Maybe LPSECURITY_ATTRIBUTES -> CreateMode -> FileAttributeOrFlag -> Maybe HANDLE -> IO HANDLE Source #
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.
closeHandle :: HANDLE -> IO () Source #
getFileType :: HANDLE -> IO FileType Source #
flushFileBuffers :: HANDLE -> IO () Source #
setEndOfFile :: HANDLE -> IO () Source #
setFileAttributes :: String -> FileAttributeOrFlag -> IO () Source #
getFileAttributes :: String -> IO FileAttributeOrFlag Source #
getFileAttributesExStandard :: String -> IO WIN32_FILE_ATTRIBUTE_DATA Source #
Reading/writing
Some operations below bear the win32_
prefix to avoid shadowing
operations from Prelude.
data OVERLAPPED Source #
OVERLAPPED | |
|
Instances
Show OVERLAPPED Source # | |
Defined in System.Win32.File.Internal showsPrec :: Int -> OVERLAPPED -> ShowS show :: OVERLAPPED -> String showList :: [OVERLAPPED] -> ShowS | |
Storable OVERLAPPED Source # | |
Defined in System.Win32.File.Internal 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 () |
type LPOVERLAPPED = Ptr OVERLAPPED Source #
type MbLPOVERLAPPED = Maybe LPOVERLAPPED Source #
win32_ReadFile :: HANDLE -> Ptr a -> DWORD -> Maybe LPOVERLAPPED -> IO DWORD Source #
win32_WriteFile :: HANDLE -> Ptr a -> DWORD -> Maybe LPOVERLAPPED -> IO DWORD Source #
setFilePointerEx :: HANDLE -> LARGE_INTEGER -> FilePtrDirection -> IO LARGE_INTEGER Source #
File notifications
findFirstChangeNotification :: String -> Bool -> FileNotificationFlag -> IO HANDLE Source #
findNextChangeNotification :: HANDLE -> IO () Source #
findCloseChangeNotification :: HANDLE -> IO () Source #
Directories
getFindDataFileName :: FindData -> IO FilePath Source #
findFirstFile :: String -> IO (HANDLE, FindData) Source #
findNextFile :: HANDLE -> FindData -> IO Bool Source #
DOS device flags
defineDosDevice :: DefineDosDeviceFlags -> String -> Maybe String -> IO () Source #
areFileApisANSI :: IO Bool Source #
setFileApisToOEM :: IO () Source #
setFileApisToANSI :: IO () Source #
setHandleCount :: UINT -> IO UINT Source #
getLogicalDrives :: IO DWORD Source #
setVolumeLabel :: Maybe String -> Maybe String -> IO () Source #
File locks
:: 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.