diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-09-19 18:39:50 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-09-19 18:39:50 -0300 |
commit | 549d344f0fef5e5748ded69b6a037698ff55f8bc (patch) | |
tree | a22ee2a3b0d6303fe3e4348831e7f581dd8a0a07 /core/os/dir_access.cpp | |
parent | 526aae62edfa31aa156d604e8b25caab512c6bff (diff) | |
download | redot-engine-549d344f0fef5e5748ded69b6a037698ff55f8bc.tar.gz |
Fixing Issues...
- #672 (default user:// in $HOME/.godot/app_userdata (linux/osx) and $APPDATA/Godot/app_userdata (Windows)
- #676 (draw both tiles and octants in order from top to bottom, left to right )
- #686 (unicode escape sequences work now)
- #702 (was not a bug, but a test was added to see if bodies went too far away)
Diffstat (limited to 'core/os/dir_access.cpp')
-rw-r--r-- | core/os/dir_access.cpp | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 496ebdfa27..3ab4d4bb7f 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -130,35 +130,46 @@ Error DirAccess::make_dir_recursive(String p_dir) { if (p_dir.length() < 1) { return OK; }; + + String full_dir; Globals* g = Globals::get_singleton(); - String cur = normalize_path(g->globalize_path(get_current_dir())); - if (cur[cur.length()-1] != '/') { - cur = cur + "/"; - }; - String dir = normalize_path(g->globalize_path(p_dir)); - if (dir.length() < 1) { - return OK; - }; - if (dir[dir.length()-1] != '/') { - dir = dir + "/"; - }; + if (!p_dir.is_abs_path()) { + //append current - ERR_FAIL_COND_V(dir.find(cur) != 0, FAILED); + String cur = normalize_path(g->globalize_path(get_current_dir())); + if (cur[cur.length()-1] != '/') { + cur = cur + "/"; + }; + + full_dir=(cur+"/"+p_dir).simplify_path(); + } else { + //validate and use given + String dir = normalize_path(g->globalize_path(p_dir)); + if (dir.length() < 1) { + return OK; + }; + if (dir[dir.length()-1] != '/') { + dir = dir + "/"; + }; + full_dir=dir; + } - String rel = dir.substr(cur.length(), (dir.length() - cur.length())); + int slices = full_dir.get_slice_count("/"); int pos = 0; - while (pos < rel.length()) { + while (pos < full_dir.length()) { - int n = rel.find("/", pos); + int n = full_dir.find("/", pos); if (n < 0) { - n = rel.length(); + n = full_dir.length(); }; pos = n + 1; if (pos > 1) { - Error err = make_dir(rel.substr(0, pos -1)); + String to_create = full_dir.substr(0, pos -1); + //print_line("MKDIR: "+to_create); + Error err = make_dir(to_create); if (err != OK && err != ERR_ALREADY_EXISTS) { ERR_FAIL_V(err); |