summaryrefslogtreecommitdiffstats
path: root/editor/editor_paths.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2024-09-11 12:23:58 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2024-09-11 12:57:06 +0300
commit14dee6e4b0f6fc483c2024527d6cf08615b6bfef (patch)
treeea84d9b697ad45e9f110b547d393c5bd8f814c8c /editor/editor_paths.cpp
parent97ef3c837263099faf02d8ebafd6c77c94d2aaba (diff)
downloadredot-engine-14dee6e4b0f6fc483c2024527d6cf08615b6bfef.tar.gz
[Editor] Add .editorconfig to the projects.
Diffstat (limited to 'editor/editor_paths.cpp')
-rw-r--r--editor/editor_paths.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp
index 7f24e8fd2e..ff869f8a8a 100644
--- a/editor/editor_paths.cpp
+++ b/editor/editor_paths.cpp
@@ -245,7 +245,7 @@ EditorPaths::EditorPaths() {
}
}
- // Check that the project data directory '.gdignore' file exists
+ // Check that the project data directory `.gdignore` file exists.
String project_data_gdignore_file_path = project_data_dir.path_join(".gdignore");
if (!FileAccess::exists(project_data_gdignore_file_path)) {
// Add an empty .gdignore file to avoid scan.
@@ -253,10 +253,26 @@ EditorPaths::EditorPaths() {
if (f.is_valid()) {
f->store_line("");
} else {
- ERR_PRINT("Failed to create file " + project_data_gdignore_file_path);
+ ERR_PRINT("Failed to create file " + project_data_gdignore_file_path.quote() + ".");
}
}
+ // Check that `.editorconfig` file exists.
+ String project_editorconfig_path = "res://.editorconfig";
+ if (!FileAccess::exists(project_editorconfig_path)) {
+ Ref<FileAccess> f = FileAccess::open(project_editorconfig_path, FileAccess::WRITE);
+ if (f.is_valid()) {
+ f->store_line("root = true");
+ f->store_line("");
+ f->store_line("[*]");
+ f->store_line("charset = utf-8");
+ f->close();
+ } else {
+ ERR_PRINT("Failed to create file " + project_editorconfig_path.quote() + ".");
+ }
+ FileAccess::set_hidden_attribute(project_editorconfig_path, true);
+ }
+
Engine::get_singleton()->set_shader_cache_path(project_data_dir);
// Editor metadata dir.