Restructure module layout

This commit is contained in:
Julian Ospald 2016-03-30 20:16:34 +02:00
parent efd2535ef9
commit 74a48b2668
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
15 changed files with 89 additions and 83 deletions

View File

@ -12,31 +12,34 @@ category: Desktop
build-type: Simple build-type: Simple
cabal-version: >=1.10 cabal-version: >=1.10
data-files: data/Gtk/builder.xml data-files:
LICENSE
data/Gtk/builder.xml
data/Gtk/icons/error.png data/Gtk/icons/error.png
data/Gtk/icons/gtk-directory.png data/Gtk/icons/gtk-directory.png
data/Gtk/icons/gtk-file.png data/Gtk/icons/gtk-file.png
data/Gtk/icons/hsfm.png data/Gtk/icons/hsfm.png
hsfm.cabal hsfm.cabal
LICENSE
library library
exposed-modules: Data.DirTree exposed-modules:
IO.Utils HSFM.FileSystem.Errors
IO.File HSFM.FileSystem.FileOperations
IO.Error HSFM.FileSystem.FileType
MyPrelude HSFM.Utils.IO
HSFM.Utils.MyPrelude
build-depends: base >= 4.7, build-depends:
base >= 4.7,
bytestring, bytestring,
data-default,
containers, containers,
data-default,
filepath >= 1.3.0.0, filepath >= 1.3.0.0,
hinotify, hinotify,
hpath,
mtl >= 2.2, mtl >= 2.2,
old-locale >= 1, old-locale >= 1,
hpath,
process, process,
safe, safe,
stm, stm,
@ -54,29 +57,31 @@ library
"-with-rtsopts=-N" "-with-rtsopts=-N"
executable hsfm-gtk executable hsfm-gtk
main-is: GUI/Gtk.hs main-is: HSFM/GUI/Gtk.hs
other-modules: GUI.Gtk.Callbacks other-modules:
GUI.Gtk.Data HSFM.GUI.Gtk.Callbacks
GUI.Gtk.Dialogs HSFM.GUI.Gtk.Data
GUI.Gtk.Icons HSFM.GUI.Gtk.Dialogs
GUI.Gtk.MyGUI HSFM.GUI.Gtk.Icons
GUI.Gtk.MyView HSFM.GUI.Gtk.MyGUI
GUI.Gtk.Utils HSFM.GUI.Gtk.MyView
MyPrelude HSFM.GUI.Gtk.Utils
HSFM.Utils.MyPrelude
build-depends: hsfm, build-depends:
Cabal >= 1.22.0.0,
base >= 4.7, base >= 4.7,
bytestring, bytestring,
Cabal >= 1.22.0.0,
containers, containers,
data-default, data-default,
gtk3 >= 0.14.1,
glib >= 0.13,
filepath >= 1.3.0.0, filepath >= 1.3.0.0,
glib >= 0.13,
gtk3 >= 0.14.1,
hinotify, hinotify,
hpath,
hsfm,
mtl >= 2.2, mtl >= 2.2,
old-locale >= 1, old-locale >= 1,
hpath,
process, process,
safe, safe,
stm, stm,

View File

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
-- |Provides error handling. -- |Provides error handling.
module IO.Error where module HSFM.FileSystem.Errors where
import Control.Applicative import Control.Applicative
@ -44,7 +44,7 @@ import Foreign.C.Error
getErrno getErrno
, Errno , Errno
) )
import IO.Utils import HSFM.Utils.IO
import System.FilePath import System.FilePath
( (
equalFilePath equalFilePath

View File

@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-- It would be nicer to pass states around, but the filesystem state changes -- It would be nicer to pass states around, but the filesystem state changes
-- too quickly and cannot be relied upon. Lazy implementations of filesystem -- too quickly and cannot be relied upon. Lazy implementations of filesystem
-- trees have been tried as well, but they can introduce subtle bugs. -- trees have been tried as well, but they can introduce subtle bugs.
module IO.File where module HSFM.FileSystem.FileOperations where
import Control.Applicative import Control.Applicative
@ -41,7 +41,6 @@ import Control.Monad
( (
unless unless
) )
import Data.DirTree
import Data.Foldable import Data.Foldable
( (
for_ for_
@ -56,8 +55,10 @@ import HPath
, Fn , Fn
) )
import qualified HPath as P import qualified HPath as P
import IO.Error import HSFM.FileSystem.Errors
import IO.Utils import HSFM.FileSystem.FileType
import HSFM.Utils.IO
import HSFM.Utils.MyPrelude
import System.FilePath import System.FilePath
( (
(</>) (</>)
@ -186,7 +187,7 @@ copyDir cm from@(_ :/ Dir fromn (FileInfo { fileMode = fmode }))
throwSameFile fromp' destdirp' throwSameFile fromp' destdirp'
createDestdir destdirp fmode createDestdir destdirp fmode
destdir <- Data.DirTree.readFileWithFileInfo destdirp destdir <- HSFM.FileSystem.FileType.readFileWithFileInfo destdirp
contents <- readDirectoryContents' (fullPath from) contents <- readDirectoryContents' (fullPath from)
@ -208,8 +209,8 @@ copyDir cm from@(_ :/ Dir fromn (FileInfo { fileMode = fmode }))
createDirectory destdir' fmode createDirectory destdir' fmode
Replace -> do Replace -> do
whenM (doesDirectoryExist destdir') whenM (doesDirectoryExist destdir')
(deleteDirRecursive =<< Data.DirTree.readFileWithFileInfo (deleteDirRecursive =<<
destdir) HSFM.FileSystem.FileType.readFileWithFileInfo destdir)
createDirectory destdir' fmode createDirectory destdir' fmode
copyDir _ _ _ = throw $ InvalidOperation "wrong input type" copyDir _ _ _ = throw $ InvalidOperation "wrong input type"
@ -234,7 +235,7 @@ recreateSymlink cm symf@(_ :/ SymLink {})
createSymbolicLink sympoint (P.fromAbs symname) createSymbolicLink sympoint (P.fromAbs symname)
where where
delOld symname = do delOld symname = do
f <- Data.DirTree.readFileWithFileInfo symname f <- HSFM.FileSystem.FileType.readFileWithFileInfo symname
unless (failed . file $ f) unless (failed . file $ f)
(easyDelete f) (easyDelete f)
recreateSymlink _ _ _ = throw $ InvalidOperation "wrong input type" recreateSymlink _ _ _ = throw $ InvalidOperation "wrong input type"
@ -463,7 +464,7 @@ moveFile cm from to@(_ :/ Dir {}) = do
easyDelete from easyDelete from
where where
delOld to = do delOld to = do
to' <- Data.DirTree.readFileWithFileInfo to to' <- HSFM.FileSystem.FileType.readFileWithFileInfo to
unless (failed . file $ to') (easyDelete to') unless (failed . file $ to') (easyDelete to')
moveFile _ _ _ = throw $ InvalidOperation "wrong input type" moveFile _ _ _ = throw $ InvalidOperation "wrong input type"

View File

@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-- --
-- It doesn't allow to represent the whole filesystem, since that's only -- It doesn't allow to represent the whole filesystem, since that's only
-- possible through IO laziness, which introduces too much internal state. -- possible through IO laziness, which introduces too much internal state.
module Data.DirTree where module HSFM.FileSystem.FileType where
import Control.Applicative import Control.Applicative
@ -95,7 +95,7 @@ import HPath
, pattern Path , pattern Path
) )
import qualified HPath as P import qualified HPath as P
import MyPrelude import HSFM.Utils.MyPrelude
import Safe import Safe
( (
atDef atDef
@ -488,7 +488,7 @@ readFile :: (Path Abs -> IO a) -> Path Abs -> IO (AnchoredFile a)
readFile ff fp = readWith ff fp readFile ff fp = readWith ff fp
readFileWithFileInfo :: Path Abs -> IO (AnchoredFile FileInfo) readFileWithFileInfo :: Path Abs -> IO (AnchoredFile FileInfo)
readFileWithFileInfo = Data.DirTree.readFile getFileInfo readFileWithFileInfo = HSFM.FileSystem.FileType.readFile getFileInfo
-- |Build a list of AnchoredFile, given the path to a directory, filling -- |Build a list of AnchoredFile, given the path to a directory, filling
-- the free variables via `getFileInfo`. This includes the "." and ".." -- the free variables via `getFileInfo`. This includes the "." and ".."
@ -512,7 +512,7 @@ readDirectoryContentsWith :: (Path Abs -> IO [Path Fn])
-> IO [AnchoredFile a] -> IO [AnchoredFile a]
readDirectoryContentsWith getfiles ff p = do readDirectoryContentsWith getfiles ff p = do
files <- getfiles p files <- getfiles p
fcs <- mapM (\x -> Data.DirTree.readFile ff $ p P.</> x) files fcs <- mapM (\x -> HSFM.FileSystem.FileType.readFile ff $ p P.</> x) files
return $ removeNonexistent fcs return $ removeNonexistent fcs
@ -622,12 +622,12 @@ isSocketC _ = False
-- |Go up one directory in the filesystem hierarchy. -- |Go up one directory in the filesystem hierarchy.
goUp :: AnchoredFile FileInfo -> IO (AnchoredFile FileInfo) goUp :: AnchoredFile FileInfo -> IO (AnchoredFile FileInfo)
goUp af@(Path "" :/ _) = return af goUp af@(Path "" :/ _) = return af
goUp (bp :/ _) = Data.DirTree.readFile getFileInfo bp goUp (bp :/ _) = HSFM.FileSystem.FileType.readFile getFileInfo bp
-- |Go up one directory in the filesystem hierarchy. -- |Go up one directory in the filesystem hierarchy.
goUp' :: Path Abs -> IO (AnchoredFile FileInfo) goUp' :: Path Abs -> IO (AnchoredFile FileInfo)
goUp' fp = Data.DirTree.readFile getFileInfo $ P.dirname fp goUp' fp = HSFM.FileSystem.FileType.readFile getFileInfo $ P.dirname fp
-- |Get the contents of a directory. -- |Get the contents of a directory.

View File

@ -22,9 +22,9 @@ module Main where
import Graphics.UI.Gtk import Graphics.UI.Gtk
import GUI.Gtk.Data import HSFM.GUI.Gtk.Data
import GUI.Gtk.MyGUI import HSFM.GUI.Gtk.MyGUI
import GUI.Gtk.MyView import HSFM.GUI.Gtk.MyView
import Safe import Safe
( (
headDef headDef

View File

@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
module GUI.Gtk.Callbacks where module HSFM.GUI.Gtk.Callbacks where
import Control.Applicative import Control.Applicative
@ -43,20 +43,20 @@ import Control.Monad.IO.Class
( (
liftIO liftIO
) )
import Data.DirTree
import Data.Foldable import Data.Foldable
( (
for_ for_
) )
import Graphics.UI.Gtk import Graphics.UI.Gtk
import GUI.Gtk.Data
import GUI.Gtk.Dialogs
import GUI.Gtk.MyView
import GUI.Gtk.Utils
import qualified HPath as P import qualified HPath as P
import IO.Error import HSFM.FileSystem.Errors
import IO.File import HSFM.FileSystem.FileOperations
import IO.Utils import HSFM.FileSystem.FileType
import HSFM.GUI.Gtk.Data
import HSFM.GUI.Gtk.Dialogs
import HSFM.GUI.Gtk.MyView
import HSFM.GUI.Gtk.Utils
import HSFM.Utils.IO
import System.FilePath import System.FilePath
( (
isAbsolute isAbsolute
@ -217,7 +217,7 @@ open :: [Item] -> MyGUI -> MyView -> IO ()
open [item] mygui myview = withErrorDialog $ open [item] mygui myview = withErrorDialog $
case item of case item of
ADirOrSym r -> do ADirOrSym r -> do
nv <- Data.DirTree.readFileWithFileInfo $ fullPath r nv <- HSFM.FileSystem.FileType.readFileWithFileInfo $ fullPath r
refreshView' mygui myview nv refreshView' mygui myview nv
r -> r ->
void $ openFile r void $ openFile r
@ -325,7 +325,8 @@ renameF [item] mygui myview = withErrorDialog $ do
for_ pmfn $ \fn -> do for_ pmfn $ \fn -> do
let cmsg = "Really rename \"" ++ P.fromAbs (fullPath item) let cmsg = "Really rename \"" ++ P.fromAbs (fullPath item)
++ "\"" ++ " to \"" ++ P.fromAbs (anchor item P.</> fn) ++ "\"?" ++ "\"" ++ " to \"" ++ P.fromAbs (anchor item P.</> fn) ++ "\"?"
withConfirmationDialog cmsg $ IO.File.renameFile item fn withConfirmationDialog cmsg $
HSFM.FileSystem.FileOperations.renameFile item fn
renameF _ _ _ = withErrorDialog renameF _ _ _ = withErrorDialog
. throw $ InvalidOperation . throw $ InvalidOperation
"Operation not supported on multiple files" "Operation not supported on multiple files"

View File

@ -17,9 +17,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--} --}
module GUI.Gtk.Callbacks where module HSFM.GUI.Gtk.Callbacks where
import GUI.Gtk.Data import HSFM.GUI.Gtk.Data
setCallbacks :: MyGUI -> MyView -> IO () setCallbacks :: MyGUI -> MyView -> IO ()

View File

@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
module GUI.Gtk.Data where module HSFM.GUI.Gtk.Data where
import Control.Concurrent.MVar import Control.Concurrent.MVar
@ -29,9 +29,9 @@ import Control.Concurrent.STM
( (
TVar TVar
) )
import Data.DirTree
import Graphics.UI.Gtk import Graphics.UI.Gtk
import IO.File import HSFM.FileSystem.FileOperations
import HSFM.FileSystem.FileType
import System.INotify import System.INotify
( (
INotify INotify

View File

@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
module GUI.Gtk.Dialogs where module HSFM.GUI.Gtk.Dialogs where
import Control.Applicative import Control.Applicative
@ -60,9 +60,9 @@ import Distribution.Verbosity
silent silent
) )
import Graphics.UI.Gtk import Graphics.UI.Gtk
import GUI.Gtk.Data import HSFM.FileSystem.Errors
import IO.Error import HSFM.FileSystem.FileOperations
import IO.File import HSFM.GUI.Gtk.Data
import Paths_hsfm import Paths_hsfm
( (
getDataFileName getDataFileName

View File

@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
-- |Module for Gtk icon handling. -- |Module for Gtk icon handling.
module GUI.Gtk.Icons where module HSFM.GUI.Gtk.Icons where
import Data.Maybe import Data.Maybe

View File

@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
module GUI.Gtk.MyGUI where module HSFM.GUI.Gtk.MyGUI where
import Control.Concurrent.STM import Control.Concurrent.STM
@ -26,7 +26,7 @@ import Control.Concurrent.STM
newTVarIO newTVarIO
) )
import Graphics.UI.Gtk import Graphics.UI.Gtk
import GUI.Gtk.Data import HSFM.GUI.Gtk.Data
import Paths_hsfm import Paths_hsfm
( (
getDataFileName getDataFileName

View File

@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
module GUI.Gtk.MyView where module HSFM.GUI.Gtk.MyView where
import Control.Applicative import Control.Applicative
@ -36,7 +36,6 @@ import Control.Concurrent.STM
newTVarIO newTVarIO
, readTVarIO , readTVarIO
) )
import Data.DirTree
import Data.Foldable import Data.Foldable
( (
for_ for_
@ -48,13 +47,14 @@ import Data.Maybe
, fromMaybe , fromMaybe
) )
import Graphics.UI.Gtk import Graphics.UI.Gtk
import {-# SOURCE #-} GUI.Gtk.Callbacks (setCallbacks) import {-# SOURCE #-} HSFM.GUI.Gtk.Callbacks (setCallbacks)
import GUI.Gtk.Data
import GUI.Gtk.Icons
import GUI.Gtk.Utils
import qualified HPath as P import qualified HPath as P
import IO.File import HSFM.FileSystem.FileOperations
import IO.Utils import HSFM.FileSystem.FileType
import HSFM.GUI.Gtk.Data
import HSFM.GUI.Gtk.Icons
import HSFM.GUI.Gtk.Utils
import HSFM.Utils.IO
import System.FilePath import System.FilePath
( (
isAbsolute isAbsolute
@ -196,7 +196,7 @@ refreshView mygui myview mfp =
case mfp of case mfp of
Just fp -> do Just fp -> do
let mdir = fromMaybe (fromJust $ P.parseAbs "/") (P.parseAbs fp) let mdir = fromMaybe (fromJust $ P.parseAbs "/") (P.parseAbs fp)
cdir <- Data.DirTree.readFileWithFileInfo mdir cdir <- HSFM.FileSystem.FileType.readFileWithFileInfo mdir
refreshView' mygui myview cdir refreshView' mygui myview cdir
Nothing -> refreshView' mygui myview =<< getCurrentDir myview Nothing -> refreshView' mygui myview =<< getCurrentDir myview

View File

@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
module GUI.Gtk.Utils where module HSFM.GUI.Gtk.Utils where
import Control.Applicative import Control.Applicative
@ -29,7 +29,6 @@ import Control.Concurrent.STM
( (
readTVarIO readTVarIO
) )
import Data.DirTree
import Data.Maybe import Data.Maybe
( (
catMaybes catMaybes
@ -40,8 +39,8 @@ import Data.Traversable
forM forM
) )
import Graphics.UI.Gtk import Graphics.UI.Gtk
import GUI.Gtk.Data import HSFM.FileSystem.FileType
import HSFM.GUI.Gtk.Data
@ -109,7 +108,7 @@ fileListStore :: AnchoredFile FileInfo -- ^ current dir
-> MyView -> MyView
-> IO (ListStore Item) -> IO (ListStore Item)
fileListStore dt myview = do fileListStore dt myview = do
cs <- Data.DirTree.getContents dt cs <- HSFM.FileSystem.FileType.getContents dt
listStoreNew cs listStoreNew cs

View File

@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
{-# OPTIONS_HADDOCK ignore-exports #-} {-# OPTIONS_HADDOCK ignore-exports #-}
-- |Random and general IO utilities. -- |Random and general IO utilities.
module IO.Utils where module HSFM.Utils.IO where
import Control.Concurrent.STM import Control.Concurrent.STM

View File

@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--} --}
module MyPrelude where module HSFM.Utils.MyPrelude where
import Data.Default import Data.Default