Error on create directory on exported game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexholly
:warning: Old Version Published before Godot 3 was released.

This works inside the godot engine but not when I export the game.
the game has chmod 777

Writing a File works but creating a folder doesn’t

OS:Ubuntu
path=/media/name/Volume/newfolder

var d = Directory.new()
if( !d.dir_exists(path) ):
	var err = d.make_dir_recursive(path)
	print(err)

Result:

ERROR: make_dir_recursive: Method/Function Failed, returning: err At: core/os/dir_access.cpp:186.
err=2 

Creating a folder with make_dir(path) also doesn’t work.

:bust_in_silhouette: Reply From: FlavoredCactus

I was having this same issue until I had an aha moment.
directory (or d in this case) needs to open the path you want to make the directory at
so…
d.open(path)
you should set the path variable to a directory that exists already and you will be making the new directory in that existing directory.

the reason on a exported game why this does not work is because d’s current directory is “res://” which is inside of your executable and not accesible

i hope this helped a bit.

Globals.globalize_path("res://")

Is function worth remembering

Kermer | 2016-03-18 12:13

:bust_in_silhouette: Reply From: twinpixel

it should look like this:

var d = Directory.new()
if !(d.dir_exists("user://somedir")):
    print("ERR: dir does not exist ")
    d.open("user://")
    d.make_dir("user://somedir")