add typesafe std/paths, std/files, std/dirs, std/symlinks (#20582)
* split std/os; add typesafe std/paths * add more files, dirs, paths * add documentation * add testcase * remove tryRemoveFile * clean up * Delete test.nim * apply changes * add `add` and fixes
This commit is contained in:
parent
66cbcaab84
commit
3c12b72168
6 changed files with 775 additions and 0 deletions
23
tests/stdlib/tfilesanddirs.nim
Normal file
23
tests/stdlib/tfilesanddirs.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import std/[paths, files, dirs]
|
||||
|
||||
from stdtest/specialpaths import buildDir
|
||||
import std/[syncio, assertions]
|
||||
|
||||
block fileOperations:
|
||||
let files = @[Path"these.txt", Path"are.x", Path"testing.r", Path"files.q"]
|
||||
let dirs = @[Path"some", Path"created", Path"test", Path"dirs"]
|
||||
|
||||
let dname = Path"__really_obscure_dir_name"
|
||||
|
||||
createDir(dname.Path)
|
||||
doAssert dirExists(Path(dname))
|
||||
|
||||
# Test creating files and dirs
|
||||
for dir in dirs:
|
||||
createDir(Path(dname/dir))
|
||||
doAssert dirExists(Path(dname/dir))
|
||||
|
||||
for file in files:
|
||||
let fh = open(string(dname/file), fmReadWrite) # createFile
|
||||
fh.close()
|
||||
doAssert fileExists(Path(dname/file))
|
||||
Loading…
Add table
Add a link
Reference in a new issue