From f3cd0fa676de35d94c734cdbfb6f2b94a268b16b Mon Sep 17 00:00:00 2001 From: hasufell Date: Sun, 16 Nov 2014 00:25:17 +0100 Subject: [PATCH] Use System.FilePath.Posix instead of our own implementation --- CG2.cabal | 3 +-- GUI/Gtk.hs | 4 ++-- System/FileSystem/FileExt.hs | 26 -------------------------- 3 files changed, 3 insertions(+), 30 deletions(-) delete mode 100644 System/FileSystem/FileExt.hs diff --git a/CG2.cabal b/CG2.cabal index ab3ca08..e051d7d 100644 --- a/CG2.cabal +++ b/CG2.cabal @@ -62,7 +62,6 @@ executable Gtk Parser.PathParser Parser.Meshparser Parser.Core - System.FileSystem.FileExt Algebra.Vector Algorithms.ConvexHull.GrahamScan QueueEx @@ -86,6 +85,7 @@ executable Gtk safe >= 0.3.8, containers >= 0.5.0.0, diagrams-contrib >= 1.1.2.1 + filepath >= 1.3.0.2 -- Directories containing source files. -- hs-source-dirs: @@ -106,7 +106,6 @@ executable Gif Parser.PathParser Parser.Meshparser Parser.Core - System.FileSystem.FileExt Algebra.Vector Algorithms.ConvexHull.GrahamScan QueueEx diff --git a/GUI/Gtk.hs b/GUI/Gtk.hs index 0d8c090..b61433c 100644 --- a/GUI/Gtk.hs +++ b/GUI/Gtk.hs @@ -14,7 +14,7 @@ import Graphics.UI.Gtk import Graphics.UI.Gtk.Glade import MyPrelude import System.Directory -import System.FileSystem.FileExt +import System.FilePath.Posix import Text.Read @@ -231,7 +231,7 @@ saveAndDrawDiag :: FilePath -- ^ obj file to parse -> MyGUI -> IO Int saveAndDrawDiag fp fps mygui = - if cmpExt "obj" fp + if (==) ".obj" . takeExtension $ fp then do mesh <- readFile fp mainDrawWindow <- widgetGetDrawWindow (mainDraw mygui) diff --git a/System/FileSystem/FileExt.hs b/System/FileSystem/FileExt.hs deleted file mode 100644 index a624423..0000000 --- a/System/FileSystem/FileExt.hs +++ /dev/null @@ -1,26 +0,0 @@ -{-# OPTIONS_HADDOCK ignore-exports #-} - -module System.FileSystem.FileExt where - -import MyPrelude - - --- |Compare the extension of a file with the given String. -cmpExt :: String -> FilePath -> Bool -cmpExt checkExt = (==) checkExt . getExt - - --- |Get the extension of a file. -getExt :: FilePath -> String -getExt fp - | hasExt fp = last . - splitBy (== '.') . - last . - splitBy (== '/') $ - fp - | otherwise = "" - - --- |Check if the file has an extension. -hasExt :: FilePath -> Bool -hasExt = (>1) . length . splitBy (== '.')