~ubuntu-branches/ubuntu/trusty/agda/trusty

« back to all changes in this revision

Viewing changes to src/full/Agda/Utils/FileName.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane, Kiwamu Okabe, Iain Lane
  • Date: 2013-04-10 11:46:43 UTC
  • mfrom: (4.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20130410114643-prunhsz59f0fhrdn
Tags: 2.3.2-1
[ Kiwamu Okabe ]
* New patch: Extend haskell-src-exts dependency and fix type miss.

[ Iain Lane ]
* [dfbca48] Imported Upstream version 2.3.2
* [7746bcc] Remove all patches — all upstream.
* [2cdb691] Update build-deps to match control file
* [868ebf4] agda-mode no longer depends on haskell-mode or GHCi.
  Remove dependency and update .el file accordingly
* [9e0ba22] Add agda-bin package here, as the separate package has been
  removed
* [75a240f] agda-mode needs to depend on agda-bin
* [d290f95] Allow Quickcheck up to 2.7. Fix haskeline build-dep.
* [79190e6] Add missing geniplate and parallel BDs

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  , mkAbsolute
8
8
  , absolute
9
9
  , (===)
 
10
  , doesFileExistCaseSensitive
10
11
  , tests
11
12
  ) where
12
13
 
13
14
import Agda.Utils.TestHelpers
14
15
import Agda.Utils.QuickCheck
15
16
import Data.Function
16
 
import Data.Generics (Typeable, Data)
 
17
import Data.Typeable (Typeable)
17
18
import Data.List
18
19
import Data.Maybe
19
20
import Control.Applicative
21
22
import System.Directory
22
23
import System.FilePath
23
24
 
 
25
#if mingw32_HOST_OS
 
26
import Control.Exception (bracket)
 
27
import System.Win32 (findFirstFile, findClose, getFindDataFileName)
 
28
#endif
 
29
 
24
30
#include "../undefined.h"
25
31
import Agda.Utils.Impossible
26
32
 
30
36
-- paths point to the same files or directories.
31
37
 
32
38
newtype AbsolutePath = AbsolutePath { filePath :: FilePath }
33
 
  deriving (Show, Eq, Ord, Typeable, Data)
 
39
  deriving (Eq, Ord, Typeable)
 
40
 
 
41
instance Show AbsolutePath where
 
42
  show = filePath
34
43
 
35
44
-- | The paths have to be absolute, valid and normalised, without
36
45
-- trailing path separators.
94
103
(===) :: AbsolutePath -> AbsolutePath -> Bool
95
104
(===) = equalFilePath `on` filePath
96
105
 
 
106
-- | Case-sensitive doesFileExist for Windows.
 
107
-- This is case-sensitive only on the file name part, not on the directory part.
 
108
-- (Ideally, path components coming from module name components should be
 
109
--  checked case-sensitively and the other path components should be checked
 
110
--  case insenstively.)
 
111
doesFileExistCaseSensitive :: FilePath -> IO Bool
 
112
#if mingw32_HOST_OS
 
113
doesFileExistCaseSensitive f = do
 
114
  ex <- doesFileExist f
 
115
  if ex then bracket (findFirstFile f) (findClose . fst) $
 
116
               fmap (takeFileName f ==) . getFindDataFileName . snd
 
117
        else return False
 
118
#else
 
119
doesFileExistCaseSensitive f = doesFileExist f
 
120
#endif
 
121
 
97
122
------------------------------------------------------------------------
98
123
-- Generators
99
124