more OsPath conversion (658/749)

At this point the test suite builds, and mostly the assistant is left.

Sponsored-by: unqueued
This commit is contained in:
Joey Hess 2025-02-08 15:17:33 -04:00
parent 5eef09a3cc
commit 2d224e0d28
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 163 additions and 138 deletions

View file

@ -48,9 +48,9 @@ checkDirectory mdir = do
v <- getEnv "GIT_ANNEX_SHELL_DIRECTORY"
case (v, mdir) of
(Nothing, _) -> noop
(Just d, Nothing) -> req d Nothing
(Just d, Nothing) -> req (toOsPath d) Nothing
(Just d, Just dir)
| d `equalFilePath` dir -> noop
| toOsPath d `equalFilePath` toOsPath dir -> noop
| otherwise -> do
home <- myHomeDir
d' <- canondir home d
@ -61,19 +61,21 @@ checkDirectory mdir = do
where
req d mdir' = giveup $ unwords
[ "Only allowed to access"
, d
, maybe "and could not determine directory from command line" ("not " ++) mdir'
, fromOsPath d
, maybe "and could not determine directory from command line"
(("not " ++) . fromOsPath)
mdir'
]
{- A directory may start with ~/ or in some cases, even /~/,
- or could just be relative to home, or of course could
- be absolute. -}
canondir home d
| "~/" `isPrefixOf` d = return d
| "/~/" `isPrefixOf` d = return $ drop 1 d
| otherwise = relHome $ fromRawFilePath $ absPathFrom
(toRawFilePath home)
(toRawFilePath d)
| "~/" `isPrefixOf` d = return $ toOsPath d
| "/~/" `isPrefixOf` d = return $ toOsPath $ drop 1 d
| otherwise = relHome $ absPathFrom
(toOsPath home)
(toOsPath d)
{- Modifies a Command to check that it is run in either a git-annex
- repository, or a repository with a gcrypt-id set. -}