Hackage.Security.Util.IO

hackage-security-0.5.3.0: Hackage security library

Safe Haskell | None
Language | Haskell2010

Hackage.Security.Util.IO

Contents

- Miscelleneous
- Debugging

Synopsis

- getFileSize :: (Num a, FsRoot root) => Path root -> IO a
- handleDoesNotExist :: IO a -> IO (Maybe a)
- withDirLock :: Path Absolute -> IO a -> IO a
- timedIO :: String -> IO a -> IO a

# Miscelleneous

getFileSize :: (Num a, FsRoot root) => Path root -> IO a #

handleDoesNotExist :: IO a -> IO (Maybe a) #

withDirLock :: Path Absolute -> IO a -> IO a #

Attempt to create a filesystem lock in the specified directory.

This will use OS-specific file locking primitives: GHC.IO.Handle.Lock with `base-4.10" and later or a shim for` base@ versions.

Throws an exception if the lock is already present.

May fallback to locking via creating a directory: Given a file `pathto`, we do this by attempting to create the directory `/pathto/hackage-security-lock`, and deleting the directory again afterwards. Creating a directory that already exists will throw an exception on most OSs (certainly Linux, OSX and Windows) and is a reasonably common way to implement a lock file.

# Debugging

timedIO :: String -> IO a -> IO a #