packages feed

unix-compat 0.4.1.1 → 0.4.1.3

raw patch · 5 files changed

+51/−25 lines, 5 filesdep +Win32PVP ok

version bump matches the API change (PVP)

Dependencies added: Win32

API changes (from Hackage documentation)

Files

cbits/HsUname.c view
@@ -22,7 +22,7 @@     strcat(dest, src); } -#define StringCchPrintf snprintf+#define StringCchPrintf _snprintf  #endif 
cbits/mktemp.c view
@@ -104,7 +104,7 @@         for (; trv > path; --trv) {             if (*trv == '/') {                 *trv = '\0';-                rval = stat(path, &sbuf);+                rval = _stat(path, &sbuf);                 *trv = '/';                 if (rval != 0)                     return (0);@@ -124,7 +124,7 @@                 return (1);             if (errno != EEXIST)                 return (0);-        } else if (stat(path, &sbuf))+        } else if (_stat(path, &sbuf))             return (errno == ENOENT);          /* If we have a collision, cycle through the space of filenames */
src/System/PosixCompat/Files.hsc view
@@ -124,6 +124,7 @@ import System.IO (IOMode(..), openFile, hFileSize, hSetFileSize, hClose) import System.IO.Error import System.PosixCompat.Types+import System.Win32.File hiding (getFileType)  import System.PosixCompat.Internal.Time (       getClockTime, clockTimeToEpochTime@@ -297,23 +298,32 @@     (fileMode stat `intersectFileModes` fileTypeModes) == socketMode  getFileStatus :: FilePath -> IO FileStatus-getFileStatus path =-    do perm  <- liftM permsToMode $ getPermissions path-       typ   <- getFileType path-       size  <- if typ == regularFileMode then getFileSize path else return 0-       mtime <- liftM modificationTimeToEpochTime $ getModificationTime path-       return $ FileStatus-                { deviceID         = -1-                , fileID           = -1-                , fileMode         = typ .|. perm-                , linkCount        = 1-                , fileOwner        = 0-                , fileGroup        = 0-                , specialDeviceID  = 0-                , fileSize         = size-                , accessTime       = mtime-                , modificationTime = mtime-                , statusChangeTime = mtime }+getFileStatus path = do+    perm  <- liftM permsToMode (getPermissions path)+    typ   <- getFileType path+    size  <- if typ == regularFileMode then getFileSize path else return 0+    mtime <- liftM modificationTimeToEpochTime (getModificationTime path)+    info  <- bracket openPath closeHandle getFileInformationByHandle+    return $ FileStatus+             { deviceID         = fromIntegral (bhfiVolumeSerialNumber info)+             , fileID           = fromIntegral (bhfiFileIndex info)+             , fileMode         = typ .|. perm+             , linkCount        = fromIntegral (bhfiNumberOfLinks info)+             , fileOwner        = 0+             , fileGroup        = 0+             , specialDeviceID  = 0+             , fileSize         = size+             , accessTime       = mtime+             , modificationTime = mtime+             , statusChangeTime = mtime }+  where+    openPath = createFile path+                 gENERIC_READ+                 (fILE_SHARE_READ .|. fILE_SHARE_WRITE .|. fILE_SHARE_DELETE)+                 Nothing+                 oPEN_EXISTING+                 (sECURITY_ANONYMOUS .|. fILE_FLAG_BACKUP_SEMANTICS)+                 Nothing  permsToMode :: Permissions -> FileMode permsToMode perms = r .|. w .|. x
src/System/PosixCompat/Types.hs view
@@ -8,20 +8,31 @@ redefined by this module. -} module System.PosixCompat.Types (-      module System.Posix.Types #ifdef mingw32_HOST_OS+     module AllPosixTypesButFileID+    , FileID     , UserID     , GroupID     , LinkCount+#else+     module System.Posix.Types #endif     ) where -import System.Posix.Types- #ifdef mingw32_HOST_OS+-- Since CIno (FileID's underlying type) reflects <sys/type.h> ino_t,+-- which mingw defines as short int (int16), it must be overriden to+-- match the size of windows fileIndex (word64).+import System.Posix.Types as AllPosixTypesButFileID hiding (FileID) -import Data.Word (Word32)+import Data.Word (Word32, Word64) +newtype FileID = FileID Word64+  deriving (Eq, Ord, Enum, Bounded, Integral, Num, Real)+instance Show FileID where show (FileID x) = show x+instance Read FileID where readsPrec i s = [ (FileID x, s')+                                           | (x,s') <- readsPrec i s]+ newtype UserID = UserID Word32   deriving (Eq, Ord, Enum, Bounded, Integral, Num, Real) instance Show UserID where show (UserID x) = show x@@ -40,4 +51,6 @@ instance Read LinkCount where readsPrec i s = [ (LinkCount x, s')                                               | (x,s') <- readsPrec i s] +#else+import System.Posix.Types #endif
unix-compat.cabal view
@@ -1,5 +1,5 @@ name:           unix-compat-version:        0.4.1.1+version:        0.4.1.3 synopsis:       Portable POSIX-compatibility layer. description:    This package provides portable implementations of parts                 of the unix package. This package re-exports the unix@@ -42,6 +42,9 @@     c-sources:       cbits/HsUname.c       cbits/mktemp.c++    extra-libraries: msvcrt+    build-depends: Win32 >= 2.3.0.2      if flag(old-time)       build-depends: old-time >= 1.0.0.0 && < 1.2.0.0