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

Commit 85ae1ce

Browse files
committed
Rename chdir to setwd
1 parent 5dc41d1 commit 85ae1ce

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ The operating system on which the program is running.
4646

4747
## Functions
4848

49-
### chdir {#system-chdir}
50-
51-
`chdir (directory)`
52-
53-
Change the working directory to the given path.
54-
55-
Parameters:
56-
57-
`directory`
58-
: Path of the directory which is to become the new working directory.
59-
60-
6149
### env
6250

6351
`env ()`
@@ -164,6 +152,18 @@ Parameters:
164152
`value`
165153
: new value (string).
166154

155+
### setwd
156+
157+
`setwd (directory)`
158+
159+
Change the working directory to the given path.
160+
161+
Parameters:
162+
163+
`directory`
164+
: Path of the directory which is to become the new working
165+
directory (string)
166+
167167
### tmpdirname
168168

169169
`tmpdirname ()`

src/Foreign/Lua/Module/System.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ module Foreign.Lua.Module.System (
2121
, os
2222

2323
-- * Functions
24-
, chdir
2524
, env
2625
, getwd
2726
, getenv
2827
, ls
2928
, mkdir
3029
, rmdir
3130
, setenv
31+
, setwd
3232
, tmpdirname
3333
, with_env
3434
, with_tmpdir
@@ -63,14 +63,14 @@ pushModule = do
6363
addField "compiler_name" compiler_name
6464
addField "compiler_version" compiler_version
6565
addField "os" os
66-
addFunction "chdir" chdir
6766
addFunction "env" env
6867
addFunction "getenv" getenv
6968
addFunction "getwd" getwd
7069
addFunction "ls" ls
7170
addFunction "mkdir" mkdir
7271
addFunction "rmdir" rmdir
7372
addFunction "setenv" setenv
73+
addFunction "setwd" setwd
7474
addFunction "tmpdirname" tmpdirname
7575
addFunction "with_env" with_env
7676
addFunction "with_tmpdir" with_tmpdir
@@ -110,10 +110,6 @@ os = Info.os
110110
-- Functions
111111
--
112112

113-
-- | Change current working directory.
114-
chdir :: FilePath -> Lua ()
115-
chdir fp = ioToLua $ Directory.setCurrentDirectory fp
116-
117113
-- | Retrieve the entire environment
118114
env :: Lua NumResults
119115
env = do
@@ -160,6 +156,10 @@ rmdir fp recursive =
160156
setenv :: String -> String -> Lua ()
161157
setenv name value = ioToLua (Env.setEnv name value)
162158

159+
-- | Change current working directory.
160+
setwd :: FilePath -> Lua ()
161+
setwd fp = ioToLua $ Directory.setCurrentDirectory fp
162+
163163
-- | Get the current directory for temporary files.
164164
tmpdirname :: Lua FilePath
165165
tmpdirname = ioToLua Directory.getTemporaryDirectory

test/system-module-tests.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function in_tmpdir (callback)
2828
return system.with_tmpdir(
2929
'hello',
3030
function (tmpdir)
31-
system.chdir(tmpdir)
31+
system.setwd(tmpdir)
3232
local result = callback(tmpdir)
33-
system.chdir(orig_dir)
33+
system.setwd(orig_dir)
3434
return result
3535
end
3636
)

0 commit comments

Comments
 (0)