Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
Created July 11, 2022 22:39
Show Gist options
  • Save TerrorJack/6352f35dc53e7b1b1baef4391ff86c3d to your computer and use it in GitHub Desktop.
Save TerrorJack/6352f35dc53e7b1b1baef4391ff86c3d to your computer and use it in GitHub Desktop.
diff --git a/System/Posix/Temp/PosixString.hsc b/System/Posix/Temp/PosixString.hsc
index 931bedf..61faf54 100644
--- a/System/Posix/Temp/PosixString.hsc
+++ b/System/Posix/Temp/PosixString.hsc
@@ -20,6 +20,7 @@ module System.Posix.Temp.PosixString (
#include "HsUnix.h"
+import qualified Data.ByteString.Char8 as B
import qualified System.OsPath.Data.ByteString.Short as BC
import Data.Word
@@ -99,7 +100,7 @@ mkdtemp (PosixString template') = do
return name
#else
name <- mktemp template
- h <- createDirectory (BC.unpack name) (toEnum 0o700)
+ h <- createDirectory (B.unpack (BC.fromShort (getPosixString name))) (toEnum 0o700)
return name
#endif
@@ -120,4 +121,3 @@ mktemp template = do
_X :: Word8
_X = 0x58
-
diff --git a/System/Posix/Terminal/PosixString.hsc b/System/Posix/Terminal/PosixString.hsc
index aa59df7..653ba27 100644
--- a/System/Posix/Terminal/PosixString.hsc
+++ b/System/Posix/Terminal/PosixString.hsc
@@ -86,6 +86,8 @@ import Foreign.C hiding (
throwErrnoPathIfMinus1_ )
import System.OsPath.Types
+import qualified System.OsPath.Data.ByteString.Short as BC
+import System.OsString.Internal.Types (PosixString(..))
import System.Posix.PosixPath.FilePath
#if !(HAVE_CTERMID && defined(HAVE_TERMIOS_H))
@@ -174,7 +176,7 @@ openPseudoTerminal = do
throwErrnoIfMinus1_ "openPseudoTerminal" (c_grantpt master)
throwErrnoIfMinus1_ "openPseudoTerminal" (c_unlockpt master)
slaveName <- getSlaveTerminalName (Fd master)
- slave <- openFd slaveName ReadWrite defaultFileFlags{noctty=True}
+ slave <- openFd (BC.fromShort (getPosixString slaveName)) ReadWrite defaultFileFlags{noctty=True}
pushModule slave "ptem"
pushModule slave "ldterm"
# ifndef __hpux
diff --git a/cabal.project.wasm32-wasi b/cabal.project.wasm32-wasi
index eafc622..99642d8 100644
--- a/cabal.project.wasm32-wasi
+++ b/cabal.project.wasm32-wasi
@@ -4,5 +4,7 @@ packages: .
package unix
ghc-options: -Wno-unused-imports
+allow-newer: all:base
+
write-ghc-environment-files: always
allow-newer: filepath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment