I want to check if a directory exists, if not create it.
How can I achieve this? I tried writeFile
since I wanted to create a file in it, but that doesn't seem to work.
Asked
Active
Viewed 842 times
4

joppiesaus
- 5,471
- 3
- 26
- 36
1 Answers
7
existsDir
: http://nim-lang.org/docs/os.html#existsDir,string
createDir
: http://nim-lang.org/docs/os.html#createDir,string
So this should work:
import os
let dir = "foo"
if not existsDir(dir):
createDir(dir)

def-
- 5,275
- 20
- 18