module System.Unix.FilePath
(dirName,
baseName,
realpath,
(<++>))
where
import Data.List
import System.FilePath (makeRelative, (</>), takeFileName, dropFileName)
import Foreign.C
import Foreign.Marshal.Array
a <++> b = a </> (makeRelative "" b)
dirName :: FilePath -> FilePath
dirName = dropFileName
baseName :: FilePath -> String
baseName = takeFileName
realpath :: FilePath -> IO FilePath
realpath fp =
withCString fp $ \cfp ->
allocaArray (4096) $ \res ->
throwErrnoIfNull "realpath" (c_realpath cfp res) >>= peekCString
foreign import ccall unsafe "realpath" c_realpath :: CString -> CString -> IO CString