dir_access.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /**************************************************************************/
  2. /* dir_access.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "dir_access.h"
  31. #include "core/config/project_settings.h"
  32. #include "core/io/file_access.h"
  33. #include "core/os/memory.h"
  34. #include "core/os/os.h"
  35. #include "core/templates/local_vector.h"
  36. thread_local Error DirAccess::last_dir_open_error = OK;
  37. String DirAccess::_get_root_path() const {
  38. switch (_access_type) {
  39. case ACCESS_RESOURCES:
  40. return ProjectSettings::get_singleton()->get_resource_path();
  41. case ACCESS_USERDATA:
  42. return OS::get_singleton()->get_user_data_dir();
  43. default:
  44. return "";
  45. }
  46. }
  47. String DirAccess::_get_root_string() const {
  48. switch (_access_type) {
  49. case ACCESS_RESOURCES:
  50. return "res://";
  51. case ACCESS_USERDATA:
  52. return "user://";
  53. default:
  54. return "";
  55. }
  56. }
  57. int DirAccess::get_current_drive() {
  58. String path = get_current_dir().to_lower();
  59. for (int i = 0; i < get_drive_count(); i++) {
  60. String d = get_drive(i).to_lower();
  61. if (path.begins_with(d)) {
  62. return i;
  63. }
  64. }
  65. return 0;
  66. }
  67. bool DirAccess::drives_are_shortcuts() {
  68. return false;
  69. }
  70. static Error _erase_recursive(DirAccess *da) {
  71. List<String> dirs;
  72. List<String> files;
  73. da->list_dir_begin();
  74. String n = da->get_next();
  75. while (!n.is_empty()) {
  76. if (n != "." && n != "..") {
  77. if (da->current_is_dir() && !da->is_link(n)) {
  78. dirs.push_back(n);
  79. } else {
  80. files.push_back(n);
  81. }
  82. }
  83. n = da->get_next();
  84. }
  85. da->list_dir_end();
  86. for (const String &E : dirs) {
  87. Error err = da->change_dir(E);
  88. if (err == OK) {
  89. err = _erase_recursive(da);
  90. if (err) {
  91. da->change_dir("..");
  92. return err;
  93. }
  94. err = da->change_dir("..");
  95. if (err) {
  96. return err;
  97. }
  98. err = da->remove(da->get_current_dir().path_join(E));
  99. if (err) {
  100. return err;
  101. }
  102. } else {
  103. return err;
  104. }
  105. }
  106. for (const String &E : files) {
  107. Error err = da->remove(da->get_current_dir().path_join(E));
  108. if (err) {
  109. return err;
  110. }
  111. }
  112. return OK;
  113. }
  114. Error DirAccess::erase_contents_recursive() {
  115. return _erase_recursive(this);
  116. }
  117. Error DirAccess::make_dir_recursive(const String &p_dir) {
  118. if (p_dir.length() < 1) {
  119. return OK;
  120. }
  121. String full_dir;
  122. if (p_dir.is_relative_path()) {
  123. //append current
  124. full_dir = get_current_dir().path_join(p_dir);
  125. } else {
  126. full_dir = p_dir;
  127. }
  128. full_dir = full_dir.replace("\\", "/");
  129. String base;
  130. if (full_dir.begins_with("res://")) {
  131. base = "res://";
  132. } else if (full_dir.begins_with("user://")) {
  133. base = "user://";
  134. } else if (full_dir.is_network_share_path()) {
  135. int pos = full_dir.find("/", 2);
  136. ERR_FAIL_COND_V(pos < 0, ERR_INVALID_PARAMETER);
  137. pos = full_dir.find("/", pos + 1);
  138. ERR_FAIL_COND_V(pos < 0, ERR_INVALID_PARAMETER);
  139. base = full_dir.substr(0, pos + 1);
  140. } else if (full_dir.begins_with("/")) {
  141. base = "/";
  142. } else if (full_dir.contains(":/")) {
  143. base = full_dir.substr(0, full_dir.find(":/") + 2);
  144. } else {
  145. ERR_FAIL_V(ERR_INVALID_PARAMETER);
  146. }
  147. full_dir = full_dir.replace_first(base, "").simplify_path();
  148. Vector<String> subdirs = full_dir.split("/");
  149. String curpath = base;
  150. for (int i = 0; i < subdirs.size(); i++) {
  151. curpath = curpath.path_join(subdirs[i]);
  152. Error err = make_dir(curpath);
  153. if (err != OK && err != ERR_ALREADY_EXISTS) {
  154. ERR_FAIL_V_MSG(err, "Could not create directory: " + curpath);
  155. }
  156. }
  157. return OK;
  158. }
  159. DirAccess::AccessType DirAccess::get_access_type() const {
  160. return _access_type;
  161. }
  162. String DirAccess::fix_path(const String &p_path) const {
  163. switch (_access_type) {
  164. case ACCESS_RESOURCES: {
  165. if (ProjectSettings::get_singleton()) {
  166. if (p_path.begins_with("res://")) {
  167. String resource_path = ProjectSettings::get_singleton()->get_resource_path();
  168. if (!resource_path.is_empty()) {
  169. return p_path.replace_first("res:/", resource_path);
  170. }
  171. return p_path.replace_first("res://", "");
  172. }
  173. }
  174. } break;
  175. case ACCESS_USERDATA: {
  176. if (p_path.begins_with("user://")) {
  177. String data_dir = OS::get_singleton()->get_user_data_dir();
  178. if (!data_dir.is_empty()) {
  179. return p_path.replace_first("user:/", data_dir);
  180. }
  181. return p_path.replace_first("user://", "");
  182. }
  183. } break;
  184. case ACCESS_FILESYSTEM: {
  185. return p_path;
  186. } break;
  187. case ACCESS_MAX:
  188. break; // Can't happen, but silences warning
  189. }
  190. return p_path;
  191. }
  192. DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { nullptr, nullptr, nullptr };
  193. Ref<DirAccess> DirAccess::create_for_path(const String &p_path) {
  194. Ref<DirAccess> da;
  195. if (p_path.begins_with("res://")) {
  196. da = create(ACCESS_RESOURCES);
  197. } else if (p_path.begins_with("user://")) {
  198. da = create(ACCESS_USERDATA);
  199. } else {
  200. da = create(ACCESS_FILESYSTEM);
  201. }
  202. return da;
  203. }
  204. Ref<DirAccess> DirAccess::open(const String &p_path, Error *r_error) {
  205. Ref<DirAccess> da = create_for_path(p_path);
  206. ERR_FAIL_COND_V_MSG(da.is_null(), nullptr, "Cannot create DirAccess for path '" + p_path + "'.");
  207. Error err = da->change_dir(p_path);
  208. if (r_error) {
  209. *r_error = err;
  210. }
  211. if (err != OK) {
  212. return nullptr;
  213. }
  214. return da;
  215. }
  216. Ref<DirAccess> DirAccess::_open(const String &p_path) {
  217. Error err = OK;
  218. Ref<DirAccess> da = open(p_path, &err);
  219. last_dir_open_error = err;
  220. if (err) {
  221. return Ref<DirAccess>();
  222. }
  223. return da;
  224. }
  225. int DirAccess::_get_drive_count() {
  226. Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  227. return d->get_drive_count();
  228. }
  229. String DirAccess::get_drive_name(int p_idx) {
  230. Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  231. return d->get_drive(p_idx);
  232. }
  233. Error DirAccess::make_dir_absolute(const String &p_dir) {
  234. Ref<DirAccess> d = DirAccess::create_for_path(p_dir);
  235. return d->make_dir(p_dir);
  236. }
  237. Error DirAccess::make_dir_recursive_absolute(const String &p_dir) {
  238. Ref<DirAccess> d = DirAccess::create_for_path(p_dir);
  239. return d->make_dir_recursive(p_dir);
  240. }
  241. bool DirAccess::dir_exists_absolute(const String &p_dir) {
  242. Ref<DirAccess> d = DirAccess::create_for_path(p_dir);
  243. return d->dir_exists(p_dir);
  244. }
  245. Error DirAccess::copy_absolute(const String &p_from, const String &p_to, int p_chmod_flags) {
  246. Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  247. // Support copying from res:// to user:// etc.
  248. String from = ProjectSettings::get_singleton()->globalize_path(p_from);
  249. String to = ProjectSettings::get_singleton()->globalize_path(p_to);
  250. return d->copy(from, to, p_chmod_flags);
  251. }
  252. Error DirAccess::rename_absolute(const String &p_from, const String &p_to) {
  253. Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  254. String from = ProjectSettings::get_singleton()->globalize_path(p_from);
  255. String to = ProjectSettings::get_singleton()->globalize_path(p_to);
  256. return d->rename(from, to);
  257. }
  258. Error DirAccess::remove_absolute(const String &p_path) {
  259. Ref<DirAccess> d = DirAccess::create_for_path(p_path);
  260. return d->remove(p_path);
  261. }
  262. Ref<DirAccess> DirAccess::create(AccessType p_access) {
  263. Ref<DirAccess> da = create_func[p_access] ? create_func[p_access]() : nullptr;
  264. if (da.is_valid()) {
  265. da->_access_type = p_access;
  266. // for ACCESS_RESOURCES and ACCESS_FILESYSTEM, current_dir already defaults to where game was started
  267. // in case current directory is force changed elsewhere for ACCESS_RESOURCES
  268. if (p_access == ACCESS_RESOURCES) {
  269. da->change_dir("res://");
  270. } else if (p_access == ACCESS_USERDATA) {
  271. da->change_dir("user://");
  272. }
  273. }
  274. return da;
  275. }
  276. Error DirAccess::get_open_error() {
  277. return last_dir_open_error;
  278. }
  279. String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
  280. Ref<DirAccess> d = DirAccess::create(p_access);
  281. if (d.is_null()) {
  282. return p_path;
  283. }
  284. d->change_dir(p_path);
  285. String full = d->get_current_dir();
  286. return full;
  287. }
  288. Error DirAccess::copy(const String &p_from, const String &p_to, int p_chmod_flags) {
  289. ERR_FAIL_COND_V_MSG(p_from == p_to, ERR_INVALID_PARAMETER, "Source and destination path are equal.");
  290. //printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
  291. Error err;
  292. {
  293. Ref<FileAccess> fsrc = FileAccess::open(p_from, FileAccess::READ, &err);
  294. ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to open " + p_from);
  295. Ref<FileAccess> fdst = FileAccess::open(p_to, FileAccess::WRITE, &err);
  296. ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to open " + p_to);
  297. const size_t copy_buffer_limit = 65536; // 64 KB
  298. fsrc->seek_end(0);
  299. uint64_t size = fsrc->get_position();
  300. fsrc->seek(0);
  301. err = OK;
  302. size_t buffer_size = MIN(size * sizeof(uint8_t), copy_buffer_limit);
  303. LocalVector<uint8_t> buffer;
  304. buffer.resize(buffer_size);
  305. while (size > 0) {
  306. if (fsrc->get_error() != OK) {
  307. err = fsrc->get_error();
  308. break;
  309. }
  310. if (fdst->get_error() != OK) {
  311. err = fdst->get_error();
  312. break;
  313. }
  314. int bytes_read = fsrc->get_buffer(buffer.ptr(), buffer_size);
  315. if (bytes_read <= 0) {
  316. err = FAILED;
  317. break;
  318. }
  319. fdst->store_buffer(buffer.ptr(), bytes_read);
  320. size -= bytes_read;
  321. }
  322. }
  323. if (err == OK && p_chmod_flags != -1) {
  324. err = FileAccess::set_unix_permissions(p_to, p_chmod_flags);
  325. // If running on a platform with no chmod support (i.e., Windows), don't fail
  326. if (err == ERR_UNAVAILABLE) {
  327. err = OK;
  328. }
  329. }
  330. return err;
  331. }
  332. // Changes dir for the current scope, returning back to the original dir
  333. // when scope exits
  334. class DirChanger {
  335. DirAccess *da;
  336. String original_dir;
  337. public:
  338. DirChanger(DirAccess *p_da, const String &p_dir) :
  339. da(p_da),
  340. original_dir(p_da->get_current_dir()) {
  341. p_da->change_dir(p_dir);
  342. }
  343. ~DirChanger() {
  344. da->change_dir(original_dir);
  345. }
  346. };
  347. Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, const String &p_to, int p_chmod_flags, bool p_copy_links) {
  348. List<String> dirs;
  349. String curdir = get_current_dir();
  350. list_dir_begin();
  351. String n = get_next();
  352. while (!n.is_empty()) {
  353. if (n != "." && n != "..") {
  354. if (p_copy_links && is_link(get_current_dir().path_join(n))) {
  355. create_link(read_link(get_current_dir().path_join(n)), p_to + n);
  356. } else if (current_is_dir()) {
  357. dirs.push_back(n);
  358. } else {
  359. const String &rel_path = n;
  360. if (!n.is_relative_path()) {
  361. list_dir_end();
  362. return ERR_BUG;
  363. }
  364. Error err = copy(get_current_dir().path_join(n), p_to + rel_path, p_chmod_flags);
  365. if (err) {
  366. list_dir_end();
  367. return err;
  368. }
  369. }
  370. }
  371. n = get_next();
  372. }
  373. list_dir_end();
  374. for (const String &rel_path : dirs) {
  375. String target_dir = p_to + rel_path;
  376. if (!p_target_da->dir_exists(target_dir)) {
  377. Error err = p_target_da->make_dir(target_dir);
  378. ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'.");
  379. }
  380. Error err = change_dir(rel_path);
  381. ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + rel_path + "'.");
  382. err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links);
  383. if (err) {
  384. change_dir("..");
  385. ERR_FAIL_V_MSG(err, "Failed to copy recursively.");
  386. }
  387. err = change_dir("..");
  388. ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to go back.");
  389. }
  390. return OK;
  391. }
  392. Error DirAccess::copy_dir(const String &p_from, String p_to, int p_chmod_flags, bool p_copy_links) {
  393. ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist.");
  394. Ref<DirAccess> target_da = DirAccess::create_for_path(p_to);
  395. ERR_FAIL_COND_V_MSG(target_da.is_null(), ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_to + "'.");
  396. if (!target_da->dir_exists(p_to)) {
  397. Error err = target_da->make_dir_recursive(p_to);
  398. ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + p_to + "'.");
  399. }
  400. if (!p_to.ends_with("/")) {
  401. p_to = p_to + "/";
  402. }
  403. DirChanger dir_changer(this, p_from);
  404. Error err = _copy_dir(target_da, p_to, p_chmod_flags, p_copy_links);
  405. return err;
  406. }
  407. bool DirAccess::exists(const String &p_dir) {
  408. Ref<DirAccess> da = DirAccess::create_for_path(p_dir);
  409. return da->change_dir(p_dir) == OK;
  410. }
  411. PackedStringArray DirAccess::get_files() {
  412. return _get_contents(false);
  413. }
  414. PackedStringArray DirAccess::get_files_at(const String &p_path) {
  415. Ref<DirAccess> da = DirAccess::open(p_path);
  416. ERR_FAIL_COND_V_MSG(da.is_null(), PackedStringArray(), vformat("Couldn't open directory at path \"%s\".", p_path));
  417. return da->get_files();
  418. }
  419. PackedStringArray DirAccess::get_directories() {
  420. return _get_contents(true);
  421. }
  422. PackedStringArray DirAccess::get_directories_at(const String &p_path) {
  423. Ref<DirAccess> da = DirAccess::open(p_path);
  424. ERR_FAIL_COND_V_MSG(da.is_null(), PackedStringArray(), vformat("Couldn't open directory at path \"%s\".", p_path));
  425. return da->get_directories();
  426. }
  427. PackedStringArray DirAccess::_get_contents(bool p_directories) {
  428. PackedStringArray ret;
  429. list_dir_begin();
  430. String s = _get_next();
  431. while (!s.is_empty()) {
  432. if (current_is_dir() == p_directories) {
  433. ret.append(s);
  434. }
  435. s = _get_next();
  436. }
  437. ret.sort();
  438. return ret;
  439. }
  440. String DirAccess::_get_next() {
  441. String next = get_next();
  442. while (!next.is_empty() && ((!include_navigational && (next == "." || next == "..")) || (!include_hidden && current_is_hidden()))) {
  443. next = get_next();
  444. }
  445. return next;
  446. }
  447. void DirAccess::set_include_navigational(bool p_enable) {
  448. include_navigational = p_enable;
  449. }
  450. bool DirAccess::get_include_navigational() const {
  451. return include_navigational;
  452. }
  453. void DirAccess::set_include_hidden(bool p_enable) {
  454. include_hidden = p_enable;
  455. }
  456. bool DirAccess::get_include_hidden() const {
  457. return include_hidden;
  458. }
  459. bool DirAccess::is_case_sensitive(const String &p_path) const {
  460. return true;
  461. }
  462. void DirAccess::_bind_methods() {
  463. ClassDB::bind_static_method("DirAccess", D_METHOD("open", "path"), &DirAccess::_open);
  464. ClassDB::bind_static_method("DirAccess", D_METHOD("get_open_error"), &DirAccess::get_open_error);
  465. ClassDB::bind_method(D_METHOD("list_dir_begin"), &DirAccess::list_dir_begin, DEFVAL(false), DEFVAL(false));
  466. ClassDB::bind_method(D_METHOD("get_next"), &DirAccess::_get_next);
  467. ClassDB::bind_method(D_METHOD("current_is_dir"), &DirAccess::current_is_dir);
  468. ClassDB::bind_method(D_METHOD("list_dir_end"), &DirAccess::list_dir_end);
  469. ClassDB::bind_method(D_METHOD("get_files"), &DirAccess::get_files);
  470. ClassDB::bind_static_method("DirAccess", D_METHOD("get_files_at", "path"), &DirAccess::get_files_at);
  471. ClassDB::bind_method(D_METHOD("get_directories"), &DirAccess::get_directories);
  472. ClassDB::bind_static_method("DirAccess", D_METHOD("get_directories_at", "path"), &DirAccess::get_directories_at);
  473. ClassDB::bind_static_method("DirAccess", D_METHOD("get_drive_count"), &DirAccess::_get_drive_count);
  474. ClassDB::bind_static_method("DirAccess", D_METHOD("get_drive_name", "idx"), &DirAccess::get_drive_name);
  475. ClassDB::bind_method(D_METHOD("get_current_drive"), &DirAccess::get_current_drive);
  476. ClassDB::bind_method(D_METHOD("change_dir", "to_dir"), &DirAccess::change_dir);
  477. ClassDB::bind_method(D_METHOD("get_current_dir", "include_drive"), &DirAccess::get_current_dir, DEFVAL(true));
  478. ClassDB::bind_method(D_METHOD("make_dir", "path"), &DirAccess::make_dir);
  479. ClassDB::bind_static_method("DirAccess", D_METHOD("make_dir_absolute", "path"), &DirAccess::make_dir_absolute);
  480. ClassDB::bind_method(D_METHOD("make_dir_recursive", "path"), &DirAccess::make_dir_recursive);
  481. ClassDB::bind_static_method("DirAccess", D_METHOD("make_dir_recursive_absolute", "path"), &DirAccess::make_dir_recursive_absolute);
  482. ClassDB::bind_method(D_METHOD("file_exists", "path"), &DirAccess::file_exists);
  483. ClassDB::bind_method(D_METHOD("dir_exists", "path"), &DirAccess::dir_exists);
  484. ClassDB::bind_static_method("DirAccess", D_METHOD("dir_exists_absolute", "path"), &DirAccess::dir_exists_absolute);
  485. ClassDB::bind_method(D_METHOD("get_space_left"), &DirAccess::get_space_left);
  486. ClassDB::bind_method(D_METHOD("copy", "from", "to", "chmod_flags"), &DirAccess::copy, DEFVAL(-1));
  487. ClassDB::bind_static_method("DirAccess", D_METHOD("copy_absolute", "from", "to", "chmod_flags"), &DirAccess::copy_absolute, DEFVAL(-1));
  488. ClassDB::bind_method(D_METHOD("rename", "from", "to"), &DirAccess::rename);
  489. ClassDB::bind_static_method("DirAccess", D_METHOD("rename_absolute", "from", "to"), &DirAccess::rename_absolute);
  490. ClassDB::bind_method(D_METHOD("remove", "path"), &DirAccess::remove);
  491. ClassDB::bind_static_method("DirAccess", D_METHOD("remove_absolute", "path"), &DirAccess::remove_absolute);
  492. ClassDB::bind_method(D_METHOD("is_link", "path"), &DirAccess::is_link);
  493. ClassDB::bind_method(D_METHOD("read_link", "path"), &DirAccess::read_link);
  494. ClassDB::bind_method(D_METHOD("create_link", "source", "target"), &DirAccess::create_link);
  495. ClassDB::bind_method(D_METHOD("set_include_navigational", "enable"), &DirAccess::set_include_navigational);
  496. ClassDB::bind_method(D_METHOD("get_include_navigational"), &DirAccess::get_include_navigational);
  497. ClassDB::bind_method(D_METHOD("set_include_hidden", "enable"), &DirAccess::set_include_hidden);
  498. ClassDB::bind_method(D_METHOD("get_include_hidden"), &DirAccess::get_include_hidden);
  499. ClassDB::bind_method(D_METHOD("is_case_sensitive", "path"), &DirAccess::is_case_sensitive);
  500. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "include_navigational"), "set_include_navigational", "get_include_navigational");
  501. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "include_hidden"), "set_include_hidden", "get_include_hidden");
  502. }