0 votes

I am trying to move a folder from res:// to user:// using the following code:

var dir = Directory.new()

dir.rename("res://dir_name", "user://dir_name")
if dir.open("user://dir_name") == OK:
    print("not existing")


not existing
Godot version v3.2.3.stable.official
in Engine by (160 points)

Have you tried adding a leading slash ("/") to the directory names? Something like this?

dir.rename("res://dir_name/", "user://dir_name/")

Otherwise, this could be a function that's only related to files (though this functionally is based upon a Unix environment). Have you also tried detecting the directory after trying to move it, e.g.

if not dir.dir_exists("user://dir_name"):
    push_error("Directory doesn't exist")

If all else fails, try copying the directory:

dir.copy("res://dir_name", "user://dir_name")

You could then remove the old directory, though that's a bit harder, as the remove() function will only delete empty directories.

1 Answer

0 votes

res:// directory is not modifiable during runtime

by (7,839 points)

But what's about modding then? How to make sure no mod overwrites another?

If you want to support modding, I'd try to stick with files in the user:// space and load/read/parse those instead. Mods breaking each other is something you'r enever able to fully avoid. If people can screw up some way, they'll find it sooner or later. This even hits big AAA games like Skyrim. Just make organizing mods as convenient as possible and if there are conflicts you can detect, warn the user, plus potentially avoid loading the conflicting mod.

But I have the mod files to be downloaded by Godot.
And Godot always downloads the files into the root of the res://-folder.
What should I do now? There isn't even the possibility to copy
the folder to the user://-directory.

To be fair, I haven't tried this myself yet, but you should be able to download a file and do whatever with it without writing it first. Have a look at the example in this answer.

Oh sorry that was not true.
Godot does not download the files in the res:// folder,
it imports the resources in there. And after that,
I cant move them inside this "res" directory.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.