1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Provide a getter for the project data directory.

This commit is contained in:
Fredia Huya-Kouadio
2021-09-10 10:52:41 -07:00
parent 1cbb1f2796
commit c8b022c165
8 changed files with 33 additions and 12 deletions

View File

@@ -1888,13 +1888,14 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str
}
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
{ //check that .import folder exists
{ //check that the project data folder exists
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
DirAccess *da = DirAccess::open("res://");
if (da->change_dir(".import") != OK) {
Error err = da->make_dir(".import");
if (da->change_dir(project_data_dir_name) != OK) {
Error err = da->make_dir(project_data_dir_name);
if (err) {
memdelete(da);
ERR_FAIL_MSG("Failed to create 'res://.import' folder.");
ERR_FAIL_MSG("Failed to create folder res://" + project_data_dir_name);
}
}
memdelete(da);
@@ -1973,6 +1974,10 @@ Error EditorFileSystem::_resource_import(const String &p_path) {
}
bool EditorFileSystem::_should_skip_directory(const String &p_path) {
if (p_path == ProjectSettings::get_singleton()->get_project_data_path()) {
return true;
}
if (FileAccess::exists(p_path.plus_file("project.godot"))) { // skip if another project inside this
return true;
}
@@ -2088,8 +2093,9 @@ EditorFileSystem::EditorFileSystem() {
scanning_changes_done = false;
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->change_dir("res://.import") != OK) {
da->make_dir("res://.import");
String project_data_path = ProjectSettings::get_singleton()->get_project_data_path();
if (da->change_dir(project_data_path) != OK) {
da->make_dir(project_data_path);
}
// This should probably also work on Unix and use the string it returns for FAT32 or exFAT
using_fat32_or_exfat = (da->get_filesystem_type() == "FAT32" || da->get_filesystem_type() == "exFAT");