X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FDirectory.hs;h=e5e988fa88222c7f0917c1e66f91b55bec3b0e94;hb=a70f356e023abdd0abb130cc149b0e3de7469044;hp=e3b3ed3fcd26f1b89db18b3c467a474182b064f7;hpb=79ce1f09530ec30a5da1d4b703413cad1948ca39;p=haskell-directory.git diff --git a/System/Directory.hs b/System/Directory.hs index e3b3ed3..e5e988f 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -507,7 +507,37 @@ renameFile opath npath = {- |@'copyFile' old new@ copies the existing file from /old/ to /new/. If the /new/ file already exists, it is atomically replaced by the /old/ file. -Neither path may refer to an existing directory. +Neither path may refer to an existing directory. The permissions of /old/ are +copied to /new/, if possible. +-} + +{- NOTES: + +It's tempting to try to remove the target file before opening it for +writing. This could be useful: for example if the target file is an +executable that is in use, writing will fail, but unlinking first +would succeed. + +However, it certainly isn't always what you want. + + * if the target file is hardlinked, removing it would break + the hard link, but just opening would preserve it. + + * opening and truncating will preserve permissions and + ACLs on the target. + + * If the destination file is read-only in a writable directory, + we might want copyFile to fail. Removing the target first + would succeed, however. + + * If the destination file is special (eg. /dev/null), removing + it is probably not the right thing. Copying to /dev/null + should leave /dev/null intact, not replace it with a plain + file. + + * There's a small race condition between removing the target and + opening it for writing during which time someone might + create it again. -} copyFile :: FilePath -> FilePath -> IO () copyFile fromFPath toFPath = @@ -591,7 +621,7 @@ findExecutable binary = return (Just fpath) else return Nothing -foreign import stdcall unsafe "SearchPath" +foreign import stdcall unsafe "SearchPathA" c_SearchPath :: CString -> CString -> CString @@ -599,6 +629,10 @@ foreign import stdcall unsafe "SearchPath" -> CString -> Ptr CString -> IO CInt +# if !defined(__GLASGOW_HASKELL__) +long_path_size :: Int +long_path_size = 4096 +# endif #else do path <- getEnv "PATH"