Skip to content
This repository was archived by the owner on Mar 22, 2021. It is now read-only.

Commit bf57713

Browse files
committed
Use default ioToLua wrapper for tmpdirname
Error messages, should they happen, will still be informative.
1 parent 7b68066 commit bf57713

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/Foreign/Lua/Module/System.hs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ callWithFilename callback filename = do
117117
return . NumResults . fromIntegral . Lua.fromStackIndex $
118118
newTop - oldTop
119119

120-
tmpdirname :: Lua FilePath
121-
tmpdirname = do
122-
eitherTmpdir <- Lua.liftIO $ try Directory.getTemporaryDirectory
123-
case eitherTmpdir :: Either IOException FilePath of
124-
Right tmpdir -> return tmpdir
125-
Left _ -> Lua.throwException ("The operating system has no notion " ++
126-
"of temporary directory.")
127-
128120
-- | List the contents of a directory.
129121
ls :: Optional FilePath -> Lua [FilePath]
130122
ls fp = do
@@ -156,6 +148,10 @@ getenv name = ioToLua (Optional <$> Env.lookupEnv name)
156148
setenv :: String -> String -> Lua ()
157149
setenv name value = ioToLua (Env.setEnv name value)
158150

151+
-- | Get the current directory for temporary files.
152+
tmpdirname :: Lua FilePath
153+
tmpdirname = ioToLua Directory.getTemporaryDirectory
154+
159155
-- | Convert a System IO operation to a Lua operation.
160156
ioToLua :: IO a -> Lua a
161157
ioToLua action = do

0 commit comments

Comments
 (0)