Debian Codegraph @

c2hs/base/general/FNameOps.hs

raw symbols SCIP
1 -- Compiler Toolkit: operations on file names
2 --
3 -- Author : Manuel M. T. Chakravarty
4 -- Created: 15 November 98
5 --
6 -- Version $Revision: 1.1.1.1 $ from $Date: 2004/11/13 16:42:47 $
7 --
8 -- Copyright (c) [1998..1999] Manuel M. T. Chakravarty
9 --
10 -- This file is free software; you can redistribute it and/or modify
11 -- it under the terms of the GNU General Public License as published by
12 -- the Free Software Foundation; either version 2 of the License, or
13 -- (at your option) any later version.
14 --
15 -- This file is distributed in the hope that it will be useful,
16 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
17 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 -- GNU General Public License for more details.
19 --
20 --- DESCRIPTION ---------------------------------------------------------------
21 --
22 -- Typical operations needed when manipulating file names.
23 --
24 --- DOCU ----------------------------------------------------------------------
25 --
26 -- language: Haskell 98
27 --
28 --- TODO ----------------------------------------------------------------------
29 --
30
31 module FNameOps (basename, dirname, stripDirname, suffix, stripSuffix, addPath,
32 splitSearchPath)
33 where
34
35 import System.FilePath
36
37 -- strip directory and suffix (EXPORTED)
38 --
39 -- eg, ../lib/libc.so -> libc
40 --
41 basename :: FilePath -> FilePath
42 basename = takeBaseName
43
44 -- strip basename and suffix (EXPORTED)
45 --
46 -- eg, ../lib/libc.so -> ../lib/
47 --
48 dirname :: FilePath -> FilePath
49 dirname = takeDirectory
50
51 -- remove dirname (EXPORTED)
52 --
53 -- eg, ../lib/libc.so -> libc.so
54 --
55 stripDirname :: FilePath -> FilePath
56 stripDirname = takeFileName
57
58 -- get suffix (EXPORTED)
59 --
60 -- eg, ../lib/libc.so -> .so
61 --
62 suffix :: FilePath -> String
63 suffix = takeExtension
64
65 -- remove suffix (EXPORTED)
66 --
67 -- eg, ../lib/libc.so -> ../lib/libc
68 --
69 stripSuffix :: FilePath -> FilePath
70 stripSuffix = dropExtension
71
72 -- prepend a path to a file name (EXPORTED)
73 --
74 -- eg, ../lib/, libc.so -> ../lib/libc.so
75 -- ../lib , libc.so -> ../lib/libc.so
76 --
77 addPath :: FilePath -> FilePath -> FilePath
78 addPath = (</>)
79
80