OsPath transition Windows build fixes
This gets it building on Windows again, with 1 test suite failure (addurl). Sponsored-by: Kevin Mueller
This commit is contained in:
parent
9dc43396b3
commit
a149336a59
23 changed files with 58 additions and 62 deletions
|
@ -468,12 +468,13 @@ isPointerFile f = catchDefaultIO Nothing $
|
||||||
- than .git to be used.
|
- than .git to be used.
|
||||||
-}
|
-}
|
||||||
isLinkToAnnex :: S.ByteString -> Bool
|
isLinkToAnnex :: S.ByteString -> Bool
|
||||||
isLinkToAnnex s = p `OS.isInfixOf` (toOsPath s)
|
isLinkToAnnex s = p `OS.isInfixOf` s'
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
-- '/' is used inside pointer files on Windows, not the native '\'
|
-- '/' is used inside pointer files on Windows, not the native '\'
|
||||||
|| p' `OS.isInfixOf` s
|
|| p' `OS.isInfixOf` s'
|
||||||
#endif
|
#endif
|
||||||
where
|
where
|
||||||
|
s' = toOsPath s
|
||||||
p = pathSeparator `OS.cons` objectDir
|
p = pathSeparator `OS.cons` objectDir
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
p' = toInternalGitPath p
|
p' = toInternalGitPath p
|
||||||
|
|
|
@ -36,7 +36,9 @@ import qualified Utility.FileIO as F
|
||||||
import Utility.OpenFile
|
import Utility.OpenFile
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
#endif
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
import Control.Concurrent.Async
|
import Control.Concurrent.Async
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
|
|
|
@ -105,7 +105,7 @@ startDaemon assistant foreground startdelay cannotrun listenhost listenport star
|
||||||
( liftIO $ withNullHandle $ \nullh -> do
|
( liftIO $ withNullHandle $ \nullh -> do
|
||||||
loghandle <- openLog (fromOsPath logfile)
|
loghandle <- openLog (fromOsPath logfile)
|
||||||
e <- getEnvironment
|
e <- getEnvironment
|
||||||
cmd <- programPath
|
cmd <- fromOsPath <$> programPath
|
||||||
ps <- getArgs
|
ps <- getArgs
|
||||||
let p = (proc cmd ps)
|
let p = (proc cmd ps)
|
||||||
{ env = Just (addEntry flag "1" e)
|
{ env = Just (addEntry flag "1" e)
|
||||||
|
@ -116,7 +116,7 @@ startDaemon assistant foreground startdelay cannotrun listenhost listenport star
|
||||||
exitcode <- withCreateProcess p $ \_ _ _ pid ->
|
exitcode <- withCreateProcess p $ \_ _ _ pid ->
|
||||||
waitForProcess pid
|
waitForProcess pid
|
||||||
exitWith exitcode
|
exitWith exitcode
|
||||||
, start (Utility.Daemon.foreground (Just (fromOsPath pidfile))) $
|
, start (Utility.Daemon.foreground (Just pidfile)) $
|
||||||
case startbrowser of
|
case startbrowser of
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
Just a -> Just $ a Nothing Nothing
|
Just a -> Just $ a Nothing Nothing
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
- A build of libmagic will also be included in the installer, if its files
|
- A build of libmagic will also be included in the installer, if its files
|
||||||
- are found in the current directory:
|
- are found in the current directory:
|
||||||
- ./magic.mgc ./libmagic-1.dll ./libgnurx-0.dll
|
- ./magic.mgc ./libmagic-1.dll ./libgnurx-0.dll
|
||||||
- To build git-annex to usse libmagic, it has to be built with the
|
- To build git-annex to use libmagic, it has to be built with the
|
||||||
- magicmime build flag turned on.
|
- magicmime build flag turned on.
|
||||||
-
|
-
|
||||||
- Copyright 2013-2020 Joey Hess <id@joeyh.name>
|
- Copyright 2013-2020 Joey Hess <id@joeyh.name>
|
||||||
|
@ -27,7 +27,6 @@
|
||||||
{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
|
{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
|
||||||
|
|
||||||
import Development.NSIS
|
import Development.NSIS
|
||||||
import System.FilePath
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.String
|
import Data.String
|
||||||
|
@ -42,27 +41,29 @@ import Utility.SafeCommand
|
||||||
import Utility.Process
|
import Utility.Process
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
import Utility.Directory
|
import Utility.Directory
|
||||||
|
import Utility.SystemDirectory
|
||||||
|
import Utility.OsPath
|
||||||
import Build.BundledPrograms
|
import Build.BundledPrograms
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
withTmpDir "nsis-build" $ \tmpdir -> do
|
withTmpDir "nsis-build" $ \tmpdir -> do
|
||||||
let gitannex = tmpdir </> gitannexprogram
|
let gitannex = fromOsPath $ tmpdir </> toOsPath gitannexprogram
|
||||||
mustSucceed "ln" [File "git-annex.exe", File gitannex]
|
mustSucceed "ln" [File "git-annex.exe", File gitannex]
|
||||||
magicDLLs' <- installwhenpresent magicDLLs tmpdir
|
magicDLLs' <- installwhenpresent magicDLLs tmpdir
|
||||||
magicShare' <- installwhenpresent magicShare tmpdir
|
magicShare' <- installwhenpresent magicShare tmpdir
|
||||||
let license = tmpdir </> licensefile
|
let license = fromOsPath $ tmpdir </> toOsPath licensefile
|
||||||
mustSucceed "sh" [Param "-c", Param $ "zcat standalone/licences.gz > '" ++ license ++ "'"]
|
mustSucceed "sh" [Param "-c", Param $ "zcat standalone/licences.gz > '" ++ license ++ "'"]
|
||||||
webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git annex webapp"
|
webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git annex webapp"
|
||||||
autostartscript <- vbsLauncher tmpdir "git-annex-autostart" "git annex assistant --autostart"
|
autostartscript <- vbsLauncher tmpdir "git-annex-autostart" "git annex assistant --autostart"
|
||||||
let htmlhelp = tmpdir </> "git-annex.html"
|
let htmlhelp = fromOsPath $ tmpdir </> literalOsPath "git-annex.html"
|
||||||
writeFile htmlhelp htmlHelpText
|
writeFile htmlhelp htmlHelpText
|
||||||
let gitannexcmd = tmpdir </> "git-annex.cmd"
|
let gitannexcmd = fromOsPath $ tmpdir </> literalOsPath "git-annex.cmd"
|
||||||
writeFile gitannexcmd "git annex %*"
|
writeFile gitannexcmd "git annex %*"
|
||||||
writeFile nsifile $ makeInstaller
|
writeFile nsifile $ makeInstaller
|
||||||
gitannex gitannexcmd license htmlhelp (winPrograms ++ magicDLLs') magicShare'
|
gitannex gitannexcmd license htmlhelp (winPrograms ++ magicDLLs') magicShare'
|
||||||
[ webappscript, autostartscript ]
|
[ webappscript, autostartscript ]
|
||||||
mustSucceed "makensis" [File nsifile]
|
mustSucceed "makensis" [File nsifile]
|
||||||
removeFile nsifile -- left behind if makensis fails
|
removeFile (toOsPath nsifile) -- left behind if makensis fails
|
||||||
where
|
where
|
||||||
nsifile = "git-annex.nsi"
|
nsifile = "git-annex.nsi"
|
||||||
mustSucceed cmd params = do
|
mustSucceed cmd params = do
|
||||||
|
@ -72,19 +73,19 @@ main = do
|
||||||
False -> error $ cmd ++ " failed"
|
False -> error $ cmd ++ " failed"
|
||||||
installwhenpresent fs tmpdir = do
|
installwhenpresent fs tmpdir = do
|
||||||
fs' <- forM fs $ \f -> do
|
fs' <- forM fs $ \f -> do
|
||||||
present <- doesFileExist f
|
present <- doesFileExist (toOsPath f)
|
||||||
if present
|
if present
|
||||||
then do
|
then do
|
||||||
mustSucceed "ln" [File f, File (tmpdir </> f)]
|
mustSucceed "ln" [File f, File (fromOsPath (tmpdir </> toOsPath f))]
|
||||||
return (Just f)
|
return (Just f)
|
||||||
else return Nothing
|
else return Nothing
|
||||||
return (catMaybes fs')
|
return (catMaybes fs')
|
||||||
|
|
||||||
{- Generates a .vbs launcher which runs a command without any visible DOS
|
{- Generates a .vbs launcher which runs a command without any visible DOS
|
||||||
- box. It expects to be passed the directory where git-annex is installed. -}
|
- box. It expects to be passed the directory where git-annex is installed. -}
|
||||||
vbsLauncher :: FilePath -> String -> String -> IO String
|
vbsLauncher :: OsPath -> String -> String -> IO String
|
||||||
vbsLauncher tmpdir basename cmd = do
|
vbsLauncher tmpdir basename cmd = do
|
||||||
let f = tmpdir </> basename ++ ".vbs"
|
let f = fromOsPath $ tmpdir </> toOsPath (basename ++ ".vbs")
|
||||||
writeFile f $ unlines
|
writeFile f $ unlines
|
||||||
[ "Set objshell=CreateObject(\"Wscript.Shell\")"
|
[ "Set objshell=CreateObject(\"Wscript.Shell\")"
|
||||||
, "objShell.CurrentDirectory = Wscript.Arguments.item(0)"
|
, "objShell.CurrentDirectory = Wscript.Arguments.item(0)"
|
||||||
|
@ -207,7 +208,7 @@ makeInstaller gitannex gitannexcmd license htmlhelp extrabins sharefiles launche
|
||||||
removefilesFrom "$INSTDIR" [license, uninstaller]
|
removefilesFrom "$INSTDIR" [license, uninstaller]
|
||||||
where
|
where
|
||||||
addfile f = file [] (str f)
|
addfile f = file [] (str f)
|
||||||
removefilesFrom d = mapM_ (\f -> delete [RebootOK] $ fromString $ d ++ "/" ++ takeFileName f)
|
removefilesFrom d = mapM_ (\f -> delete [RebootOK] $ fromString $ d ++ "/" ++ fromOsPath (takeFileName (toOsPath f)))
|
||||||
|
|
||||||
winPrograms :: [FilePath]
|
winPrograms :: [FilePath]
|
||||||
winPrograms = map (\p -> p ++ ".exe") bundledPrograms
|
winPrograms = map (\p -> p ++ ".exe") bundledPrograms
|
||||||
|
|
|
@ -122,8 +122,8 @@ parseRemoteLocation s knownurl repo = go
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
-- git on Windows will write a path to .git/config with "drive:",
|
-- git on Windows will write a path to .git/config with "drive:",
|
||||||
-- which is not to be confused with a "host:"
|
-- which is not to be confused with a "host:"
|
||||||
dosstyle = hasDrive
|
dosstyle = hasDrive . toOsPath
|
||||||
dospath = fromRawFilePath . fromInternalGitPath . toRawFilePath
|
dospath = fromOsPath . fromInternalGitPath . toOsPath
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
insteadOfUrl :: String -> S.ByteString -> RepoFullConfig -> Maybe String
|
insteadOfUrl :: String -> S.ByteString -> RepoFullConfig -> Maybe String
|
||||||
|
|
|
@ -480,7 +480,7 @@ retrieveExportWithContentIdentifierM ii dir cow loc cids dest gk p =
|
||||||
closeFd dupfd
|
closeFd dupfd
|
||||||
bracketIO open close $ \(h, dupfd) -> do
|
bracketIO open close $ \(h, dupfd) -> do
|
||||||
#else
|
#else
|
||||||
let open = openBinaryFile f' ReadMode
|
let open = F.openBinaryFile f ReadMode
|
||||||
let close = hClose
|
let close = hClose
|
||||||
bracketIO open close $ \h -> do
|
bracketIO open close $ \h -> do
|
||||||
#endif
|
#endif
|
||||||
|
|
2
Test.hs
2
Test.hs
|
@ -88,9 +88,9 @@ import qualified Utility.Aeson
|
||||||
import qualified Utility.CopyFile
|
import qualified Utility.CopyFile
|
||||||
import qualified Utility.MoveFile
|
import qualified Utility.MoveFile
|
||||||
import qualified Utility.StatelessOpenPGP
|
import qualified Utility.StatelessOpenPGP
|
||||||
import qualified Utility.OsString as OS
|
|
||||||
import qualified Types.Remote
|
import qualified Types.Remote
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
import qualified Utility.OsString as OS
|
||||||
import qualified Remote.Helper.Encryptable
|
import qualified Remote.Helper.Encryptable
|
||||||
import qualified Types.Crypto
|
import qualified Types.Crypto
|
||||||
import qualified Utility.Gpg
|
import qualified Utility.Gpg
|
||||||
|
|
|
@ -158,7 +158,7 @@ checkDaemon pidfile = maybe (return Nothing) (check . readish)
|
||||||
where
|
where
|
||||||
check Nothing = return Nothing
|
check Nothing = return Nothing
|
||||||
check (Just pid) = do
|
check (Just pid) = do
|
||||||
v <- lockShared =<< winLockFile pid (fromOsPath pidfile)
|
v <- lockShared =<< winLockFile pid pidfile
|
||||||
case v of
|
case v of
|
||||||
Just h -> do
|
Just h -> do
|
||||||
dropLock h
|
dropLock h
|
||||||
|
|
|
@ -134,7 +134,7 @@ watchDir dir prune scanevents hooks runstartup =
|
||||||
#else
|
#else
|
||||||
#if WITH_WIN32NOTIFY
|
#if WITH_WIN32NOTIFY
|
||||||
type DirWatcherHandle = Win32Notify.WatchManager
|
type DirWatcherHandle = Win32Notify.WatchManager
|
||||||
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO Win32Notify.WatchManager -> IO Win32Notify.WatchManager) -> IO DirWatcherHandle
|
watchDir :: OsPath -> Pruner -> Bool -> WatchHooks -> (IO Win32Notify.WatchManager -> IO Win32Notify.WatchManager) -> IO DirWatcherHandle
|
||||||
watchDir dir prune scanevents hooks runstartup =
|
watchDir dir prune scanevents hooks runstartup =
|
||||||
runstartup $ Win32Notify.watchDir dir prune scanevents hooks
|
runstartup $ Win32Notify.watchDir dir prune scanevents hooks
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -14,15 +14,15 @@ import qualified Utility.RawFilePath as R
|
||||||
import System.Win32.Notify
|
import System.Win32.Notify
|
||||||
import System.PosixCompat.Files (isRegularFile)
|
import System.PosixCompat.Files (isRegularFile)
|
||||||
|
|
||||||
watchDir :: FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO WatchManager
|
watchDir :: OsPath -> (OsPath -> Bool) -> Bool -> WatchHooks -> IO WatchManager
|
||||||
watchDir dir ignored scanevents hooks = do
|
watchDir dir ignored scanevents hooks = do
|
||||||
scan dir
|
scan dir
|
||||||
wm <- initWatchManager
|
wm <- initWatchManager
|
||||||
void $ watchDirectory wm dir True [Create, Delete, Modify, Move] dispatch
|
void $ watchDirectory wm (fromOsPath dir) True [Create, Delete, Modify, Move] dispatch
|
||||||
return wm
|
return wm
|
||||||
where
|
where
|
||||||
dispatch evt
|
dispatch evt
|
||||||
| ignoredPath ignored (filePath evt) = noop
|
| ignoredPath ignored (toOsPath (filePath evt)) = noop
|
||||||
| otherwise = case evt of
|
| otherwise = case evt of
|
||||||
(Deleted _ _)
|
(Deleted _ _)
|
||||||
| isDirectory evt -> runhook delDirHook Nothing
|
| isDirectory evt -> runhook delDirHook Nothing
|
||||||
|
@ -40,11 +40,11 @@ watchDir dir ignored scanevents hooks = do
|
||||||
runhook addHook Nothing
|
runhook addHook Nothing
|
||||||
runhook modifyHook Nothing
|
runhook modifyHook Nothing
|
||||||
where
|
where
|
||||||
runhook h s = maybe noop (\a -> a (filePath evt) s) (h hooks)
|
runhook h s = maybe noop (\a -> a (toOsPath (filePath evt)) s) (h hooks)
|
||||||
|
|
||||||
scan d = unless (ignoredPath ignored d) $
|
scan d = unless (ignoredPath ignored d) $
|
||||||
mapM_ (go . fromRawFilePath) =<< emptyWhenDoesNotExist
|
mapM_ go =<< emptyWhenDoesNotExist
|
||||||
(dirContentsRecursiveSkipping (const False) False (toRawFilePath d))
|
(dirContentsRecursiveSkipping (const False) False d)
|
||||||
where
|
where
|
||||||
go f
|
go f
|
||||||
| ignoredPath ignored f = noop
|
| ignoredPath ignored f = noop
|
||||||
|
@ -61,8 +61,8 @@ watchDir dir ignored scanevents hooks = do
|
||||||
where
|
where
|
||||||
runhook h s = maybe noop (\a -> a f s) (h hooks)
|
runhook h s = maybe noop (\a -> a f s) (h hooks)
|
||||||
|
|
||||||
getstatus = catchMaybeIO . R.getFileStatus . toRawFilePath
|
getstatus = catchMaybeIO . R.getFileStatus . fromOsPath
|
||||||
|
|
||||||
{- Check each component of the path to see if it's ignored. -}
|
{- Check each component of the path to see if it's ignored. -}
|
||||||
ignoredPath :: (FilePath -> Bool) -> FilePath -> Bool
|
ignoredPath :: (OsPath -> Bool) -> OsPath -> Bool
|
||||||
ignoredPath ignored = any ignored . map dropTrailingPathSeparator . splitPath
|
ignoredPath ignored = any ignored . map dropTrailingPathSeparator . splitPath
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||||
|
|
||||||
module Utility.Directory.Stream (
|
module Utility.Directory.Stream (
|
||||||
|
@ -24,7 +25,6 @@ import Prelude
|
||||||
|
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
import qualified System.Win32 as Win32
|
import qualified System.Win32 as Win32
|
||||||
import System.FilePath
|
|
||||||
#else
|
#else
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import qualified System.Posix.Directory.ByteString as Posix
|
import qualified System.Posix.Directory.ByteString as Posix
|
||||||
|
@ -50,7 +50,7 @@ openDirectory path = do
|
||||||
isopen <- newMVar ()
|
isopen <- newMVar ()
|
||||||
return (DirectoryHandle isopen dirp)
|
return (DirectoryHandle isopen dirp)
|
||||||
#else
|
#else
|
||||||
(h, fdat) <- Win32.findFirstFile (fromRawFilePath path </> "*")
|
(h, fdat) <- Win32.findFirstFile (fromOsPath (toOsPath path </> literalOsPath "*"))
|
||||||
-- Indicate that the fdat contains a filename that readDirectory
|
-- Indicate that the fdat contains a filename that readDirectory
|
||||||
-- has not yet returned, by making the MVar be full.
|
-- has not yet returned, by making the MVar be full.
|
||||||
-- (There's always at least a "." entry.)
|
-- (There's always at least a "." entry.)
|
||||||
|
|
|
@ -37,7 +37,6 @@ import System.File.OsPath
|
||||||
-- https://github.com/haskell/file-io/issues/39
|
-- https://github.com/haskell/file-io/issues/39
|
||||||
import Utility.Path.Windows
|
import Utility.Path.Windows
|
||||||
import Utility.OsPath
|
import Utility.OsPath
|
||||||
import System.OsPath
|
|
||||||
import System.IO (IO, Handle, IOMode)
|
import System.IO (IO, Handle, IOMode)
|
||||||
import Prelude (return)
|
import Prelude (return)
|
||||||
import qualified System.File.OsPath as O
|
import qualified System.File.OsPath as O
|
||||||
|
|
|
@ -18,12 +18,11 @@ module Utility.FileSize (
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
import System.IO
|
import System.IO
|
||||||
import qualified Utility.FileIO as F
|
import qualified Utility.FileIO as F
|
||||||
import Utility.OsPath
|
|
||||||
#else
|
#else
|
||||||
import System.PosixCompat.Files (fileSize)
|
import System.PosixCompat.Files (fileSize)
|
||||||
|
import qualified Utility.RawFilePath as R
|
||||||
#endif
|
#endif
|
||||||
import System.PosixCompat.Files (FileStatus)
|
import System.PosixCompat.Files (FileStatus)
|
||||||
import qualified Utility.RawFilePath as R
|
|
||||||
import Utility.OsPath
|
import Utility.OsPath
|
||||||
|
|
||||||
type FileSize = Integer
|
type FileSize = Integer
|
||||||
|
|
|
@ -179,7 +179,7 @@ feedRead cmd params passphrase feeder reader = do
|
||||||
go (passphrasefd ++ params)
|
go (passphrasefd ++ params)
|
||||||
#else
|
#else
|
||||||
-- store the passphrase in a temp file for gpg
|
-- store the passphrase in a temp file for gpg
|
||||||
withTmpFile (toOsPath "gpg") $ \tmpfile h -> do
|
withTmpFile (literalOsPath "gpg") $ \tmpfile h -> do
|
||||||
liftIO $ B.hPutStr h passphrase
|
liftIO $ B.hPutStr h passphrase
|
||||||
liftIO $ hClose h
|
liftIO $ hClose h
|
||||||
let passphrasefile = [Param "--passphrase-file", File (fromOsPath tmpfile)]
|
let passphrasefile = [Param "--passphrase-file", File (fromOsPath tmpfile)]
|
||||||
|
|
|
@ -21,11 +21,12 @@ import Control.Concurrent
|
||||||
|
|
||||||
import Utility.Path.Windows
|
import Utility.Path.Windows
|
||||||
import Utility.FileSystemEncoding
|
import Utility.FileSystemEncoding
|
||||||
|
import Utility.OsPath
|
||||||
#if MIN_VERSION_Win32(2,13,4)
|
#if MIN_VERSION_Win32(2,13,4)
|
||||||
import Common (tryNonAsync)
|
import Common (tryNonAsync)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
type LockFile = RawFilePath
|
type LockFile = OsPath
|
||||||
|
|
||||||
type LockHandle = HANDLE
|
type LockHandle = HANDLE
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ lockExclusive = openLock fILE_SHARE_NONE
|
||||||
-}
|
-}
|
||||||
openLock :: ShareMode -> LockFile -> IO (Maybe LockHandle)
|
openLock :: ShareMode -> LockFile -> IO (Maybe LockHandle)
|
||||||
openLock sharemode f = do
|
openLock sharemode f = do
|
||||||
f' <- convertToWindowsNativeNamespace f
|
f' <- convertToWindowsNativeNamespace (fromOsPath f)
|
||||||
#if MIN_VERSION_Win32(2,13,4)
|
#if MIN_VERSION_Win32(2,13,4)
|
||||||
r <- tryNonAsync $ createFile_NoRetry (fromRawFilePath f') gENERIC_READ sharemode
|
r <- tryNonAsync $ createFile_NoRetry (fromRawFilePath f') gENERIC_READ sharemode
|
||||||
Nothing oPEN_ALWAYS fILE_ATTRIBUTE_NORMAL
|
Nothing oPEN_ALWAYS fILE_ATTRIBUTE_NORMAL
|
||||||
|
|
|
@ -21,6 +21,7 @@ import Prelude
|
||||||
import System.PosixCompat.Files (isDirectory)
|
import System.PosixCompat.Files (isDirectory)
|
||||||
import Control.Monad.IfElse
|
import Control.Monad.IfElse
|
||||||
import Utility.SafeCommand
|
import Utility.SafeCommand
|
||||||
|
import qualified Utility.RawFilePath as R
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Utility.SystemDirectory
|
import Utility.SystemDirectory
|
||||||
|
@ -28,7 +29,6 @@ import Utility.Tmp
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
import Utility.Monad
|
import Utility.Monad
|
||||||
import Utility.OsPath
|
import Utility.OsPath
|
||||||
import qualified Utility.RawFilePath as R
|
|
||||||
import Author
|
import Author
|
||||||
|
|
||||||
{- Moves one filename to another.
|
{- Moves one filename to another.
|
||||||
|
|
|
@ -43,7 +43,6 @@ import qualified Utility.OsString as OS
|
||||||
|
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Utility.FileSystemEncoding
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
copyright :: Authored t => t
|
copyright :: Authored t => t
|
||||||
|
@ -230,11 +229,11 @@ relPathDirToFileAbs from to
|
||||||
numcommon = length common
|
numcommon = length common
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
normdrive = map toLower
|
normdrive = map toLower
|
||||||
|
. fromOsPath
|
||||||
-- Get just the drive letter, removing any leading
|
-- Get just the drive letter, removing any leading
|
||||||
-- path separator, which takeDrive leaves on the drive
|
-- path separator, which takeDrive leaves on the drive
|
||||||
-- letter.
|
-- letter.
|
||||||
. dropWhileEnd (isPathSeparator . fromIntegral . ord)
|
. OS.dropWhileEnd isPathSeparator
|
||||||
. fromOsPath
|
|
||||||
. takeDrive
|
. takeDrive
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -261,7 +260,7 @@ searchPath command
|
||||||
indir d = check (d </> command')
|
indir d = check (d </> command')
|
||||||
check f = firstM doesFileExist
|
check f = firstM doesFileExist
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
[f, f <> ".exe"]
|
[f, f <> literalOsPath ".exe"]
|
||||||
#else
|
#else
|
||||||
[f]
|
[f]
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,11 +60,6 @@ createLink a b = do
|
||||||
b' <- fromRawFilePath <$> convertToWindowsNativeNamespace b
|
b' <- fromRawFilePath <$> convertToWindowsNativeNamespace b
|
||||||
P.createLink a' b'
|
P.createLink a' b'
|
||||||
|
|
||||||
{- On windows, removeLink is not available, so only remove files,
|
|
||||||
- not symbolic links. -}
|
|
||||||
removeLink :: RawFilePath -> IO ()
|
|
||||||
removeLink = D.removeFile . fromRawFilePath
|
|
||||||
|
|
||||||
getFileStatus :: RawFilePath -> IO FileStatus
|
getFileStatus :: RawFilePath -> IO FileStatus
|
||||||
getFileStatus p = P.getFileStatus . fromRawFilePath
|
getFileStatus p = P.getFileStatus . fromRawFilePath
|
||||||
=<< convertToWindowsNativeNamespace p
|
=<< convertToWindowsNativeNamespace p
|
||||||
|
|
|
@ -25,6 +25,7 @@ import Utility.Tuple
|
||||||
|
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
import qualified System.FilePath.Posix as Posix
|
import qualified System.FilePath.Posix as Posix
|
||||||
|
import qualified Utility.OsString as OS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Data.Char
|
import Data.Char
|
||||||
|
@ -102,7 +103,7 @@ rsyncUrlIsShell s
|
||||||
rsyncUrlIsPath :: String -> Bool
|
rsyncUrlIsPath :: String -> Bool
|
||||||
rsyncUrlIsPath s
|
rsyncUrlIsPath s
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
| not (null (takeDrive s)) = True
|
| not (OS.null (takeDrive (toOsPath s))) = True
|
||||||
#endif
|
#endif
|
||||||
| rsyncUrlIsShell s = False
|
| rsyncUrlIsShell s = False
|
||||||
| otherwise = ':' `notElem` s
|
| otherwise = ':' `notElem` s
|
||||||
|
@ -174,15 +175,15 @@ filterRsyncSafeOptions = fst3 . getOpt Permute
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
toMSYS2Path :: FilePath -> FilePath
|
toMSYS2Path :: FilePath -> FilePath
|
||||||
toMSYS2Path p
|
toMSYS2Path p
|
||||||
| null drive = recombine parts
|
| OS.null drive = recombine parts
|
||||||
| otherwise = recombine $ "/" : driveletter drive : parts
|
| otherwise = recombine $ "/" : driveletter (fromOsPath drive) : parts
|
||||||
where
|
where
|
||||||
(drive, p') = splitDrive p
|
(drive, p') = splitDrive (toOsPath p)
|
||||||
parts = splitDirectories p'
|
parts = map fromOsPath $ splitDirectories p'
|
||||||
driveletter = map toLower . takeWhile (/= ':')
|
driveletter = map toLower . takeWhile (/= ':')
|
||||||
recombine = fixtrailing . Posix.joinPath
|
recombine = fixtrailing . Posix.joinPath
|
||||||
fixtrailing s
|
fixtrailing s
|
||||||
| hasTrailingPathSeparator p = Posix.addTrailingPathSeparator s
|
| hasTrailingPathSeparator (toOsPath p) = Posix.addTrailingPathSeparator s
|
||||||
| otherwise = s
|
| otherwise = s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,6 @@ import Utility.Exception
|
||||||
import Utility.PartialPrelude
|
import Utility.PartialPrelude
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef mingw32_HOST_OS
|
|
||||||
import System.FilePath
|
|
||||||
#endif
|
|
||||||
|
|
||||||
shellPath :: FilePath
|
shellPath :: FilePath
|
||||||
shellPath = "/bin/sh"
|
shellPath = "/bin/sh"
|
||||||
|
|
||||||
|
@ -46,13 +42,13 @@ findShellCommand f = do
|
||||||
Just ('#':'!':rest) -> case words rest of
|
Just ('#':'!':rest) -> case words rest of
|
||||||
[] -> defcmd
|
[] -> defcmd
|
||||||
(c:ps) -> do
|
(c:ps) -> do
|
||||||
let ps' = map Param ps ++ [File f]
|
let ps' = map Param ps ++ [File (fromOsPath f)]
|
||||||
-- If the command is not inSearchPath,
|
-- If the command is not inSearchPath,
|
||||||
-- take the base of it, and run eg "sh"
|
-- take the base of it, and run eg "sh"
|
||||||
-- which in some cases on windows will work
|
-- which in some cases on windows will work
|
||||||
-- despite it not being inSearchPath.
|
-- despite it not being inSearchPath.
|
||||||
ok <- inSearchPath c
|
ok <- inSearchPath c
|
||||||
return (if ok then c else takeFileName c, ps')
|
return (if ok then c else fromOsPath (takeFileName (toOsPath c)), ps')
|
||||||
_ -> defcmd
|
_ -> defcmd
|
||||||
#endif
|
#endif
|
||||||
where
|
where
|
||||||
|
|
|
@ -159,7 +159,7 @@ feedRead cmd subcmd params password emptydirectory feeder reader = do
|
||||||
go (Just emptydirectory) (passwordfd ++ params)
|
go (Just emptydirectory) (passwordfd ++ params)
|
||||||
#else
|
#else
|
||||||
-- store the password in a temp file
|
-- store the password in a temp file
|
||||||
withTmpFile (toOsPath "sop") $ \tmpfile h -> do
|
withTmpFile (literalOsPath "sop") $ \tmpfile h -> do
|
||||||
liftIO $ B.hPutStr h password
|
liftIO $ B.hPutStr h password
|
||||||
liftIO $ hClose h
|
liftIO $ hClose h
|
||||||
let passwordfile = [Param $ "--with-password=" ++ fromOsPath tmpfile]
|
let passwordfile = [Param $ "--with-password=" ++ fromOsPath tmpfile]
|
||||||
|
|
|
@ -136,5 +136,7 @@ relatedTemplate' _ = "t"
|
||||||
- of openTempFile, and some extra has been added to make it longer
|
- of openTempFile, and some extra has been added to make it longer
|
||||||
- than any likely implementation.
|
- than any likely implementation.
|
||||||
-}
|
-}
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
templateAddedLength :: Int
|
templateAddedLength :: Int
|
||||||
templateAddedLength = 20
|
templateAddedLength = 20
|
||||||
|
#endif
|
||||||
|
|
|
@ -32,8 +32,8 @@ withTmpDir :: (MonadMask m, MonadIO m) => Template -> (OsPath -> m a) -> m a
|
||||||
withTmpDir template a = do
|
withTmpDir template a = do
|
||||||
topleveltmpdir <- liftIO $
|
topleveltmpdir <- liftIO $
|
||||||
catchDefaultIO (literalOsPath ".") getTemporaryDirectory
|
catchDefaultIO (literalOsPath ".") getTemporaryDirectory
|
||||||
let p = fromOsPath $ topleveltmpdir </> template
|
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
let p = fromOsPath $ topleveltmpdir </> template
|
||||||
-- Use mkdtemp to create a temp directory securely in /tmp.
|
-- Use mkdtemp to create a temp directory securely in /tmp.
|
||||||
bracket
|
bracket
|
||||||
(liftIO $ toOsPath <$> mkdtemp p)
|
(liftIO $ toOsPath <$> mkdtemp p)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue