system-argv0 0.1 → 0.1.1
raw patch · 2 files changed
+17/−11 lines, 2 filesdep +bytestringdep +textdep ~system-filepath
Dependencies added: bytestring, text
Dependency ranges changed: system-filepath
Files
- lib/System/Argv0.hs +8/−4
- system-argv0.cabal +9/−7
lib/System/Argv0.hs view
@@ -7,6 +7,8 @@ import Prelude hiding (FilePath) +import qualified Data.ByteString as Bytes+import qualified Data.Text as Text import Foreign import Foreign.C #if defined(mingw32_HOST_OS) && __GLASGOW_HASKELL__ >= 702@@ -14,7 +16,8 @@ #endif import Filesystem.Path (FilePath)-import Filesystem.Path.CurrentOS (decodeString)+import Filesystem.Path.CurrentOS ()+import Filesystem.Path.Rules (decode, posix, windows) -- | Get @argv[0]@ as a 'FilePath'. This is how the program was invoked, and -- might not correspond to any actual file.@@ -27,7 +30,7 @@ getArgv0 = do m_argv0 <- getWin32ProgArgv0 argv0 <- maybe (fmap head getFullArgs) return m_argv0- return (decodeString argv0)+ return (decode windows (Text.pack argv0)) getWin32ProgArgv0 :: IO (Maybe String) getWin32ProgArgv0 =@@ -52,10 +55,11 @@ argv <- peek p_argv #ifdef mingw32_HOST_OS argv0 <- peekCString =<< peekElemOff argv 0+ return (decode windows (Text.pack argv0)) #else- argv0 <- peekCAString =<< peekElemOff argv 0+ argv0 <- Bytes.packCString =<< peekElemOff argv 0+ return (decode posix argv0) #endif- return (decodeString argv0) foreign import ccall unsafe "getProgArgv" c_getProgArgv :: Ptr CInt -> Ptr (Ptr CString) -> IO ()
system-argv0.cabal view
@@ -1,5 +1,5 @@ name: system-argv0-version: 0.1+version: 0.1.1 license: MIT license-file: license.txt author: John Millikin <jmillikin@gmail.com>@@ -8,10 +8,10 @@ cabal-version: >= 1.6 category: System stability: experimental-homepage: https://john-millikin.com/software/hs-argv0/+homepage: https://john-millikin.com/software/haskell-filesystem/ bug-reports: mailto:jmillikin@gmail.com -synopsis: Get @argv[0]@ as a FilePath.+synopsis: Get argv[0] as a FilePath. description: Get @argv[0]@ as a FilePath. This is how the program was invoked, and might not correspond to any actual file.@@ -21,12 +21,12 @@ source-repository head type: bazaar- location: https://john-millikin.com/software/hs-argv0/+ location: https://john-millikin.com/branches/system-argv0/0.1/ source-repository this type: bazaar- location: https://john-millikin.com/branches/hs-argv0/0.1/- tag: system-argv0_0.1+ location: https://john-millikin.com/branches/system-argv0/0.1/+ tag: system-argv0_0.1.1 library hs-source-dirs: lib@@ -34,7 +34,9 @@ build-depends: base >= 4.0 && < 5.0- , system-filepath >= 0.3.1 && < 0.5+ , bytestring+ , system-filepath >= 0.3 && < 0.5+ , text exposed-modules: System.Argv0