packages feed

rawfilepath 1.0.1 → 1.1.0

raw patch · 3 files changed

+94/−54 lines, 3 filesdep ~unix

Dependency ranges changed: unix

Files

README.md view
@@ -1,6 +1,14 @@ # rawfilepath -Version: 1.0.1+Version: 1.1.0++## TL;DR++- Use all "process" and "directory" features+- like `callProcess` or `getDirectoryFiles`+- without worrying about `FilePath` encoding issues or performance penalties.++## Overview  The `unix` package provides `RawFilePath` which is a type synonym of `ByteString`. Unlike `FilePath` (which is `String`), it has no performance issues because it is `ByteString`. It has no encoding issues because it is `ByteString` which is a sequence of bytes instead of characters. 
rawfilepath.cabal view
@@ -1,63 +1,74 @@-name:                rawfilepath-version:             1.0.1-synopsis:            Use RawFilePath instead of FilePath-description:         Please see README.md-homepage:            https://github.com/xtendo-org/rawfilepath#readme-license:             Apache-2.0-license-file:        LICENSE-author:              XT-maintainer:          e@xtendo.org-copyright:           2016 XT-category:            System-build-type:          Simple-cabal-version:       >=1.10+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.35.2.+--+-- see: https://github.com/sol/hpack++name:           rawfilepath+version:        1.1.0+synopsis:       Use RawFilePath instead of FilePath+description:    Please see README.md+category:       System+homepage:       https://github.com/xtendo-org/rawfilepath#readme+bug-reports:    https://github.com/xtendo-org/rawfilepath/issues+author:         XT et al.+maintainer:     git@xtendo.org+copyright:      (C) 2016-2023 XT et al.+license:        Apache-2.0+license-file:   LICENSE+build-type:     Simple extra-source-files:-  README.md+    README.md +source-repository head+  type: git+  location: https://github.com/xtendo-org/rawfilepath+ library-  hs-source-dirs:      src   exposed-modules:-    Data.ByteString.RawFilePath,-    RawFilePath-    RawFilePath.Directory-    RawFilePath.Process+      Data.ByteString.RawFilePath+      RawFilePath+      RawFilePath.Directory+      RawFilePath.Process   other-modules:-    RawFilePath.Directory.Internal-    RawFilePath.Import-    RawFilePath.Process.Basic-    RawFilePath.Process.Common-    RawFilePath.Process.Internal-    RawFilePath.Process.Posix-    RawFilePath.Process.Utility+      RawFilePath.Directory.Internal+      RawFilePath.Import+      RawFilePath.Process.Basic+      RawFilePath.Process.Common+      RawFilePath.Process.Internal+      RawFilePath.Process.Posix+      RawFilePath.Process.Utility+      Paths_rawfilepath+  hs-source-dirs:+      src+  default-extensions:+      BangPatterns+      CPP+      LambdaCase+      OverloadedStrings+      RecordWildCards+  include-dirs:+      cbits   c-sources:-    cbits/runProcess.c-    cbits/processFlags.c-    cbits/processFlags.h-  include-dirs: cbits+      cbits/runProcess.c+      cbits/processFlags.c+      cbits/processFlags.h   build-depends:-    bytestring,-    unix,-    base >= 4.7 && < 5-  default-language:    Haskell2010-  default-extensions:-    BangPatterns-    CPP-    LambdaCase-    OverloadedStrings-    RecordWildCards+      base >=4.7 && <5+    , bytestring+    , unix+  default-language: Haskell2010  test-suite RawFilePath-test-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  main-is:             Spec.hs+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_rawfilepath+  hs-source-dirs:+      test+  ghc-options: -threaded -rtsopts -with-rtsopts=-N   build-depends:-    bytestring,--    base,-    rawfilepath-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  default-language:    Haskell2010--source-repository head-  type:     git-  location: https://github.com/xtendo-org/rawfilepath+      base+    , bytestring+    , rawfilepath+  default-language: Haskell2010
src/Data/ByteString/RawFilePath.hs view
@@ -48,7 +48,27 @@ withFile :: RawFilePath -> IOMode -> (Handle -> IO r) -> IO r withFile path ioMode = bracket (open >>= fdToHandle) hClose   where+#if MIN_VERSION_unix(2,8,0)     open = case ioMode of+        ReadMode -> openFd path ReadOnly $ defaultFlags Nothing+        WriteMode -> createFile path stdFileMode+        AppendMode -> openFd path WriteOnly $ appendFlags $ Just stdFileMode+        ReadWriteMode -> openFd path ReadWrite $ defaultFlags $ Just stdFileMode+    defaultFlags creat = OpenFileFlags+        { System.Posix.ByteString.append = False+        , creat = creat+        , exclusive = False+        , noctty = True+        , nonBlock = False+        , trunc = False+        , nofollow = False+        , cloexec = False+        , directory = False+        , sync = False+        }+    appendFlags creat = (defaultFlags creat) { System.Posix.ByteString.append = True }+#else+    open = case ioMode of         ReadMode -> openFd path ReadOnly Nothing defaultFlags         WriteMode -> createFile path stdFileMode         AppendMode -> openFd path WriteOnly (Just stdFileMode) appendFlags@@ -61,3 +81,4 @@         , trunc = False         }     appendFlags = defaultFlags { System.Posix.ByteString.append = True }+#endif