Safe Haskell | None |
---|---|
Language | Haskell2010 |
Miscelleneous
withDirLock :: Path Absolute -> IO a -> IO a Source #
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.