4

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.

joppiesaus
  • 5,471
  • 3
  • 26
  • 36

1 Answers1

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