Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a directory?

Tags:

nim-lang

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.

like image 262
joppiesaus Avatar asked Oct 11 '25 10:10

joppiesaus


1 Answers

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)
like image 190
def- Avatar answered Oct 14 '25 04:10

def-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!