From: mthomas Date: Thu, 24 Oct 2002 07:49:40 +0000 (+0000) Subject: [project @ 2002-10-24 07:49:40 by mthomas] X-Git-Tag: nhc98-1-18-release~808 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a7269f9891d0d332c261f29498f293ae60503559;p=haskell-directory.git [project @ 2002-10-24 07:49:40 by mthomas] Unchecked quick fix. Hope to test tonight after getting home. --- diff --git a/System/Directory.hs b/System/Directory.hs index 911ff4e..0ddd3d2 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -560,7 +560,7 @@ getModificationTime name = withFileStatus :: FilePath -> (Ptr CStat -> IO a) -> IO a withFileStatus name f = do allocaBytes sizeof_stat $ \p -> - withCString name $ \s -> do + withCString (fileNameEndClean name) $ \s -> do throwErrnoIfMinus1Retry_ "withFileStatus" (c_stat s p) f p @@ -581,6 +581,16 @@ isDirectory stat = do mode <- st_mode stat return (s_isdir mode) +fileNameEndClean :: String -> String +fileNameEndClean name = + if i >= 0 && (ec == '\\' || ec == '/') then + fileNameEndClean (take i name) + else + name + where + i = (length name) - 1 + ec = name !! i + emptyCMode :: CMode emptyCMode = 0