33{-# LANGUAGE ScopedTypeVariables #-}
44
55module Streamly.Coreutils.FileTest.Windows
6- ( Uid
7- , Gid
8- , sameFileAs
6+ ( sameFileAs
97 , isTerminalFd
108 {-
9+ , Uid
10+ , Gid
1111 , isOwnedByUserId
1212 , isOwnedByGroupId
1313 -}
@@ -35,10 +35,7 @@ import Control.Exception
3535 , throwIO
3636 )
3737
38- import Data.Bits (shiftL , (.|.) , (.&.) )
39- import Data.Word (Word64 )
4038import Foreign.C.Types (CInt (.. ))
41- import Foreign.Ptr (nullPtr )
4239import System.PosixCompat.Files (FileStatus , isSymbolicLink , ownerWriteMode )
4340import System.Posix.Types (Fd (.. ))
4441import System.Win32.Console (getConsoleMode )
@@ -68,7 +65,6 @@ import System.Win32.File
6865 )
6966import System.Win32.Security
7067 ( PSID
71- , SID
7268 , dACL_SECURITY_INFORMATION
7369 , oWNER_SECURITY_INFORMATION
7470 )
@@ -91,12 +87,12 @@ import Streamly.Coreutils.FileTest.Common
9187-- Types
9288-------------------------------------------------------------------------------
9389
90+ {-
9491-- | Wraps a Windows SID pointer representing a user identity.
9592newtype Uid = Uid PSID
9693-- | Wraps a Windows SID pointer representing a group identity.
9794newtype Gid = Gid PSID
9895
99- {-
10096isOwnedByUserId :: Uid -> FileTest
10197isOwnedByUserId (Uid uid) = withPathM $ \fp -> undefined
10298
@@ -269,7 +265,7 @@ fileId path =
269265 withFileHandle path $ \ h -> do
270266 info <- getFileInformationByHandle h
271267 let vol = bhfiVolumeSerialNumber info
272- idx = fromIntegral ( bhfiFileIndex info) :: Word64
268+ idx = bhfiFileIndex info
273269 pure (vol, idx)
274270
275271-- | True if both paths refer to the same underlying file or directory,
@@ -306,7 +302,7 @@ isConsoleHandle h =
306302isTerminalFd :: Fd -> FileTest
307303isTerminalFd (Fd fd) =
308304 withPathM $ \ _ -> do
309- h <- c_get_osfhandle ( fromIntegral fd)
305+ h <- c_get_osfhandle fd
310306 if h == iNVALID_HANDLE_VALUE
311307 then pure False
312308 else do
@@ -576,9 +572,6 @@ isExecutable = withPathM pathIsExecutable
576572fILE_ATTRIBUTE_DIRECTORY :: DWORD
577573fILE_ATTRIBUTE_DIRECTORY = 0x10
578574
579- fILE_ATTRIBUTE_REPARSE_POINT :: DWORD
580- fILE_ATTRIBUTE_REPARSE_POINT = 0x400
581-
582575-- | True iff the path is a reparse point (symlink or junction) that the OS
583576-- also marks as a directory object.
584577isPathDirSymLink :: FilePath -> FileStatus -> IO Bool
0 commit comments