mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-07 10:12:51 -06:00
use the standard System.FilePath module instead of our own broken file path manipulation functions
This commit is contained in:
@@ -35,6 +35,7 @@ import Data.Char
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import System.Directory
|
||||
import System.FilePath
|
||||
|
||||
type ModName = String
|
||||
type ModEnv = [(ModName,ModTime)]
|
||||
@@ -58,7 +59,7 @@ getAllFiles opts ps env file = do
|
||||
let paths = [(f,p) | ((f,_),p) <- ds]
|
||||
let pds1 = [(p,f) | f <- ds1, Just p <- [lookup f paths]]
|
||||
if oElem fromSource opts
|
||||
then return [gfFile (prefixPathName p f) | (p,f) <- pds1]
|
||||
then return [gfFile (p </> f) | (p,f) <- pds1]
|
||||
else do
|
||||
|
||||
|
||||
@@ -84,7 +85,7 @@ selectFormat :: Options -> ModEnv -> (InitPath,ModName) ->
|
||||
IO (ModName,(InitPath,(CompStatus,Maybe ModTime)))
|
||||
|
||||
selectFormat opts env (p,f) = do
|
||||
let pf = prefixPathName p f
|
||||
let pf = p </> f
|
||||
let mtenv = lookup f env -- Nothing if f is not in env
|
||||
let rtenv = lookup (resModName f) env
|
||||
let fromComp = oElem isCompiled opts -- i -gfc
|
||||
@@ -184,23 +185,23 @@ needCompile opts headers sfiles0 = paths $ res $ mark $ iter changed where
|
||||
-- construct list of paths to read
|
||||
paths cs = [mkName f p st | (f,(p,st)) <- cs, elem st [CSComp, CSRead,CSRes]]
|
||||
|
||||
mkName f p st = mk $ prefixPathName p f where
|
||||
mkName f p st = mk (p </> f) where
|
||||
mk = case st of
|
||||
CSComp -> gfFile
|
||||
CSRead -> gfcFile
|
||||
CSRes -> gfrFile
|
||||
|
||||
isGFC :: FilePath -> Bool
|
||||
isGFC = (== "gfc") . fileSuffix
|
||||
isGFC = (== ".gfc") . takeExtensions
|
||||
|
||||
gfcFile :: FilePath -> FilePath
|
||||
gfcFile = suffixFile "gfc"
|
||||
gfcFile f = addExtension f "gfc"
|
||||
|
||||
gfrFile :: FilePath -> FilePath
|
||||
gfrFile = suffixFile "gfr"
|
||||
gfrFile f = addExtension f "gfr"
|
||||
|
||||
gfFile :: FilePath -> FilePath
|
||||
gfFile = suffixFile "gf"
|
||||
gfFile f = addExtension f "gf"
|
||||
|
||||
resModName :: ModName -> ModName
|
||||
resModName = ('#':)
|
||||
@@ -210,10 +211,10 @@ resModName = ('#':)
|
||||
getImports :: [InitPath] -> FileName -> IOE [(ModuleHeader,InitPath)]
|
||||
getImports ps = get [] where
|
||||
get ds file0 = do
|
||||
let name = justModuleName file0 ---- fileBody file0
|
||||
let name = dropExtension file0 ---- dropExtension file0
|
||||
(p,s) <- tryRead name
|
||||
let ((typ,mname),imps) = importsOfFile s
|
||||
let namebody = justFileName name
|
||||
let namebody = takeFileName name
|
||||
ioeErr $ testErr (mname == namebody) $
|
||||
"module name" +++ mname +++ "differs from file name" +++ namebody
|
||||
case imps of
|
||||
|
||||
Reference in New Issue
Block a user