Replace File/Directory with FileAccess/DirAccess
This commit is contained in:
@@ -69,51 +69,41 @@ namespace GodotTools.Build
|
||||
|
||||
private void LoadIssuesFromFile(string csvFile)
|
||||
{
|
||||
using (var file = new Godot.File())
|
||||
using var file = FileAccess.Open(csvFile, FileAccess.ModeFlags.Read);
|
||||
|
||||
if (file == null)
|
||||
return;
|
||||
|
||||
while (!file.EofReached())
|
||||
{
|
||||
try
|
||||
string[] csvColumns = file.GetCsvLine();
|
||||
|
||||
if (csvColumns.Length == 1 && string.IsNullOrEmpty(csvColumns[0]))
|
||||
return;
|
||||
|
||||
if (csvColumns.Length != 7)
|
||||
{
|
||||
Error openError = file.Open(csvFile, Godot.File.ModeFlags.Read);
|
||||
|
||||
if (openError != Error.Ok)
|
||||
return;
|
||||
|
||||
while (!file.EofReached())
|
||||
{
|
||||
string[] csvColumns = file.GetCsvLine();
|
||||
|
||||
if (csvColumns.Length == 1 && string.IsNullOrEmpty(csvColumns[0]))
|
||||
return;
|
||||
|
||||
if (csvColumns.Length != 7)
|
||||
{
|
||||
GD.PushError($"Expected 7 columns, got {csvColumns.Length}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var issue = new BuildIssue
|
||||
{
|
||||
Warning = csvColumns[0] == "warning",
|
||||
File = csvColumns[1],
|
||||
Line = int.Parse(csvColumns[2]),
|
||||
Column = int.Parse(csvColumns[3]),
|
||||
Code = csvColumns[4],
|
||||
Message = csvColumns[5],
|
||||
ProjectFile = csvColumns[6]
|
||||
};
|
||||
|
||||
if (issue.Warning)
|
||||
WarningCount += 1;
|
||||
else
|
||||
ErrorCount += 1;
|
||||
|
||||
_issues.Add(issue);
|
||||
}
|
||||
GD.PushError($"Expected 7 columns, got {csvColumns.Length}");
|
||||
continue;
|
||||
}
|
||||
finally
|
||||
|
||||
var issue = new BuildIssue
|
||||
{
|
||||
file.Close(); // Disposing it is not enough. We need to call Close()
|
||||
}
|
||||
Warning = csvColumns[0] == "warning",
|
||||
File = csvColumns[1],
|
||||
Line = int.Parse(csvColumns[2]),
|
||||
Column = int.Parse(csvColumns[3]),
|
||||
Code = csvColumns[4],
|
||||
Message = csvColumns[5],
|
||||
ProjectFile = csvColumns[6]
|
||||
};
|
||||
|
||||
if (issue.Warning)
|
||||
WarningCount += 1;
|
||||
else
|
||||
ErrorCount += 1;
|
||||
|
||||
_issues.Add(issue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ using namespace godot;
|
||||
// Headers for building as built-in module.
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/core_bind.h"
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/object/worker_thread_pool.h"
|
||||
#include "core/string/print_string.h"
|
||||
@@ -53,8 +52,6 @@ using namespace godot;
|
||||
|
||||
#include "modules/modules_enabled.gen.h" // For freetype, msdfgen.
|
||||
|
||||
using namespace core_bind;
|
||||
|
||||
#endif
|
||||
|
||||
// Built-in ICU data.
|
||||
@@ -408,13 +405,12 @@ bool TextServerAdvanced::load_support_data(const String &p_filename) {
|
||||
if (!icu_data_loaded) {
|
||||
String filename = (p_filename.is_empty()) ? String("res://") + _MKSTR(ICU_DATA_NAME) : p_filename;
|
||||
|
||||
Ref<File> f;
|
||||
f.instantiate();
|
||||
if (f->open(filename, File::READ) != OK) {
|
||||
Ref<FileAccess> f = FileAccess::open(filename, FileAccess::READ);
|
||||
if (f.is_null()) {
|
||||
return false;
|
||||
}
|
||||
uint64_t len = f->get_length();
|
||||
PackedByteArray icu_data = f->get_buffer(len);
|
||||
PackedByteArray icu_data = f->_get_buffer(len);
|
||||
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
udata_setCommonData(icu_data.ptr(), &err);
|
||||
@@ -455,16 +451,15 @@ bool TextServerAdvanced::save_support_data(const String &p_filename) const {
|
||||
|
||||
// Store data to the res file if it's available.
|
||||
|
||||
Ref<File> f;
|
||||
f.instantiate();
|
||||
if (f->open(p_filename, File::WRITE) != OK) {
|
||||
Ref<FileAccess> f = FileAccess::open(p_filename, FileAccess::WRITE);
|
||||
if (f.is_null()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PackedByteArray icu_data;
|
||||
icu_data.resize(U_ICUDATA_SIZE);
|
||||
memcpy(icu_data.ptrw(), U_ICUDATA_ENTRY_POINT, U_ICUDATA_SIZE);
|
||||
f->store_buffer(icu_data);
|
||||
f->_store_buffer(icu_data);
|
||||
|
||||
return true;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user