windows disk free space checking
This commit is contained in:
parent
8699a36438
commit
063a183a61
4 changed files with 22 additions and 12 deletions
|
@ -351,20 +351,11 @@ driveList :: IO [RemovableDrive]
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
-- Just enumerate all likely drive letters for Windows.
|
-- Just enumerate all likely drive letters for Windows.
|
||||||
-- Could use wmic, but it only works for administrators.
|
-- Could use wmic, but it only works for administrators.
|
||||||
driveList = return $ map (\l -> gen $ l:":\\") ['A'..'Z']
|
driveList = mapM (\d -> genRemovableDrive $ d:":\\") ['A'..'Z']
|
||||||
where
|
|
||||||
gen dir = RemovableDrive
|
|
||||||
Nothing
|
|
||||||
(T.pack dir)
|
|
||||||
(T.pack gitAnnexAssistantDefaultDir)
|
|
||||||
#else
|
#else
|
||||||
#ifdef WITH_CLIBS
|
#ifdef WITH_CLIBS
|
||||||
driveList = mapM (gen . mnt_dir) =<< filter sane <$> getMounts
|
driveList = mapM (genRemovableDrive . mnt_dir) =<< filter sane <$> getMounts
|
||||||
where
|
where
|
||||||
gen dir = RemovableDrive
|
|
||||||
<$> getDiskFree dir
|
|
||||||
<*> pure (T.pack dir)
|
|
||||||
<*> pure (T.pack gitAnnexAssistantDefaultDir)
|
|
||||||
-- filter out some things that are surely not removable drives
|
-- filter out some things that are surely not removable drives
|
||||||
sane Mntent { mnt_dir = dir, mnt_fsname = dev }
|
sane Mntent { mnt_dir = dir, mnt_fsname = dev }
|
||||||
{- We want real disks like /dev/foo, not
|
{- We want real disks like /dev/foo, not
|
||||||
|
@ -387,6 +378,12 @@ driveList = return []
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
genRemovableDrive :: FilePath -> IO RemovableDrive
|
||||||
|
genRemovableDrive dir = RemovableDrive
|
||||||
|
<$> getDiskFree dir
|
||||||
|
<*> pure (T.pack dir)
|
||||||
|
<*> pure (T.pack gitAnnexAssistantDefaultDir)
|
||||||
|
|
||||||
{- Bootstraps from first run mode to a fully running assistant in a
|
{- Bootstraps from first run mode to a fully running assistant in a
|
||||||
- repository, by running the postFirstRun callback, which returns the
|
- repository, by running the postFirstRun callback, which returns the
|
||||||
- url to the new webapp. -}
|
- url to the new webapp. -}
|
||||||
|
|
|
@ -31,8 +31,18 @@ getDiskFree path = withFilePath path $ \c_path -> do
|
||||||
safeErrno (Errno v) = v == 0
|
safeErrno (Errno v) = v == 0
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#ifdef mingw32_HOST_OS
|
||||||
|
|
||||||
|
import System.Win32.File
|
||||||
|
|
||||||
|
getDiskFree :: FilePath -> IO (Maybe Integer)
|
||||||
|
getDiskFree path = catchMaybeIO $ do
|
||||||
|
(sectors, bytes, nfree, _ntotal) <- getDiskFreeSpace (Just path)
|
||||||
|
return $ toInteger sectors * toInteger bytes * toInteger nfree
|
||||||
|
#else
|
||||||
|
|
||||||
getDiskFree :: FilePath -> IO (Maybe Integer)
|
getDiskFree :: FilePath -> IO (Maybe Integer)
|
||||||
getDiskFree _ = return Nothing
|
getDiskFree _ = return Nothing
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -19,6 +19,7 @@ git-annex (5.20131131) UNRELEASED; urgency=low
|
||||||
* import: better handling of overwriting an existing file/directory/broken
|
* import: better handling of overwriting an existing file/directory/broken
|
||||||
link when importing
|
link when importing
|
||||||
* Windows: assistant and webapp work! (very experimental)
|
* Windows: assistant and webapp work! (very experimental)
|
||||||
|
* Windows: Support annex.diskreserve.
|
||||||
* Fix bad behavior in Firefox, which was caused by an earlier fix to
|
* Fix bad behavior in Firefox, which was caused by an earlier fix to
|
||||||
bad behavior in Chromium.
|
bad behavior in Chromium.
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,9 @@ Executable git-annex
|
||||||
if flag(Production)
|
if flag(Production)
|
||||||
GHC-Options: -O2
|
GHC-Options: -O2
|
||||||
|
|
||||||
if (! os(windows))
|
if (os(windows))
|
||||||
|
Build-Depends: Win32
|
||||||
|
else
|
||||||
Build-Depends: unix
|
Build-Depends: unix
|
||||||
-- Need to list these because they're generated from .hsc files.
|
-- Need to list these because they're generated from .hsc files.
|
||||||
Other-Modules: Utility.Touch Utility.Mounts
|
Other-Modules: Utility.Touch Utility.Mounts
|
||||||
|
|
Loading…
Reference in a new issue