diff --git a/src/HSFM/FileSystem/FileOperations.hs b/src/HSFM/FileSystem/FileOperations.hs index 04ef817..3afe1ae 100644 --- a/src/HSFM/FileSystem/FileOperations.hs +++ b/src/HSFM/FileSystem/FileOperations.hs @@ -331,8 +331,10 @@ copyFile cm from@(_ :/ RegFile {}) to@(_ :/ Dir {}) fn copyFile _ _ _ _ = throw $ InvalidOperation "wrong input type" --- |Unsafe version of `copyFile` without initial sanity checks. Thise +-- |Unsafe version of `copyFile` without initial sanity checks. This -- holds the actual copy logic though and is called by `copyFile` in the end. +-- It's also used for cases where we don't need/want sanity checks +-- and need the extra bit of performance. unsafeCopyFile :: CopyMode -> AnchoredFile a -- ^ source file -> AnchoredFile a -- ^ destination dir diff --git a/src/HSFM/FileSystem/FileType.hs b/src/HSFM/FileSystem/FileType.hs index 5d7ea46..63eb129 100644 --- a/src/HSFM/FileSystem/FileType.hs +++ b/src/HSFM/FileSystem/FileType.hs @@ -389,6 +389,9 @@ readFile ff p = do readFileUnsafe ff (cdp P. P.basename p) +-- |A variant of `readFile` which does not use `realpath` at all. +-- Suitable for cases where we know the paths are safe/correct +-- and need the extra bit of performance. readFileUnsafe :: (Path Abs -> IO a) -> Path Abs -> IO (AnchoredFile a) @@ -442,6 +445,9 @@ readDirectoryContents getfiles ff p = do return $ removeNonexistent fcs +-- |A variant of `readDirectoryContents` which uses `readFileUnsafe`. +-- Suitable for cases where we know the paths are safe/correct +-- and need the extra bit of performance. readDirectoryContentsUnsafe :: (Path Abs -> IO [Path Fn]) -> (Path Abs -> IO a) -> Path Abs