MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_full_path

Method get_full_path

utility/common.cpp:1301–1339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1299}
1300
1301String gdre::get_full_path(const String &p_path, DirAccess::AccessType p_access) {
1302 String path = p_path.simplify_path();
1303 bool is_dir = DirAccess::exists(path);
1304 if (!(is_dir || FileAccess::exists(path))) {
1305 return path;
1306 }
1307 Ref<DirAccess> da = DirAccess::create(p_access);
1308 ERR_FAIL_COND_V_MSG(da.is_null(), path, "Failed to create DirAccess.");
1309 ERR_FAIL_COND_V_MSG(da->change_dir(p_path.get_base_dir()) != OK, path, "Failed to change directory.");
1310 String real_base_dir = da->get_current_dir();
1311 da->list_dir_begin();
1312 String file = da->get_next();
1313 Vector<String> potential_paths;
1314 String new_path;
1315 while (file != "") {
1316 if (file == p_path.get_file()) {
1317 new_path = real_base_dir.path_join(file);
1318 break;
1319 } else if (file.to_lower() == p_path.get_file().to_lower()) {
1320 potential_paths.push_back(real_base_dir.path_join(file));
1321 }
1322 file = da->get_next();
1323 }
1324 if (new_path.is_empty()) {
1325 if (potential_paths.size() >= 1) {
1326 if (potential_paths.size() > 1) {
1327 WARN_PRINT(vformat("Multiple files found for %s, using %s", p_path, potential_paths[0]));
1328 }
1329 new_path = potential_paths[0];
1330 }
1331 }
1332 if (!new_path.is_empty()) {
1333 if (is_dir) {
1334 return DirAccess::get_full_path(new_path, p_access);
1335 }
1336 return new_path;
1337 }
1338 return path;
1339}
1340
1341bool gdre::directory_has_any_of(const String &p_dir_path, const Vector<String> &p_files_or_dirs) {
1342 for (auto &file_or_dir : p_files_or_dirs) {

Callers

nothing calls this directly

Calls 8

createFunction · 0.85
change_dirMethod · 0.80
get_current_dirMethod · 0.80
list_dir_beginMethod · 0.80
get_nextMethod · 0.80
push_backMethod · 0.80
get_fileMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected