-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #536 from briandowns/add_more_functions_to_system
Add mkdirTemp to System module
- Loading branch information
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Env; | ||
import System; | ||
|
||
const tmpDir = Env.get("TMPDIR") + "XXXXXX"; | ||
|
||
var res = System.mkdirTemp(tmpDir); | ||
|
||
print(res); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ import "constants.du"; | |
import "chmod.du"; | ||
import "chown.du"; | ||
import "uname.du"; | ||
import "mkdirTemp.du"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* mkdirTemp.du | ||
* | ||
* Testing the System.mkdirTemp function | ||
* | ||
* mkdirTemp makes a temporary directory. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
import Path; | ||
import System; | ||
|
||
class TestSystemMkdirTest < UnitTest { | ||
testSystemMkdir(tempDirName) { | ||
if (System.platform != "windows") { | ||
if (Path.exists(tempDirName)) { | ||
this.assertSuccess(System.rmdir(tempDirName)); | ||
} | ||
|
||
System.mkdirTemp(tempDirName).match( | ||
def (result) => { | ||
this.assertEquals(result[0:-6], tempDirName[0:-6]); | ||
this.assertSuccess(System.rmdir(result)); | ||
}, | ||
def (error) => { | ||
this.assertEquals(error, "Invalid argument"); | ||
} | ||
); | ||
} | ||
} | ||
|
||
testSystemMkdirProvider() { | ||
return [ | ||
'test_mkdir_temp', | ||
'test_mkdir_tempXXXXXX' | ||
]; | ||
} | ||
} | ||
|
||
TestSystemMkdirTest().run(); |