You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Add function to obtain filesystem type from DirAccess.
Change EditorFileSystem to not use directory modification times on FAT32, fixes #20946
This commit is contained in:
@@ -490,6 +490,10 @@ size_t DirAccessPack::get_space_left() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String DirAccessPack::get_filesystem_type() const {
|
||||||
|
return "PCK";
|
||||||
|
}
|
||||||
|
|
||||||
DirAccessPack::DirAccessPack() {
|
DirAccessPack::DirAccessPack() {
|
||||||
|
|
||||||
current = PackedData::get_singleton()->root;
|
current = PackedData::get_singleton()->root;
|
||||||
|
|||||||
@@ -221,6 +221,9 @@ public:
|
|||||||
|
|
||||||
size_t get_space_left();
|
size_t get_space_left();
|
||||||
|
|
||||||
|
virtual String get_filesystem_type() const;
|
||||||
|
|
||||||
|
|
||||||
DirAccessPack();
|
DirAccessPack();
|
||||||
~DirAccessPack();
|
~DirAccessPack();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ public:
|
|||||||
virtual Error rename(String p_from, String p_to) = 0;
|
virtual Error rename(String p_from, String p_to) = 0;
|
||||||
virtual Error remove(String p_name) = 0;
|
virtual Error remove(String p_name) = 0;
|
||||||
|
|
||||||
|
virtual String get_filesystem_type() const=0 ;
|
||||||
static String get_full_path(const String &p_path, AccessType p_access);
|
static String get_full_path(const String &p_path, AccessType p_access);
|
||||||
static DirAccess *create_for_path(const String &p_path);
|
static DirAccess *create_for_path(const String &p_path);
|
||||||
|
|
||||||
|
|||||||
@@ -407,6 +407,10 @@ size_t DirAccessUnix::get_space_left() {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
String DirAccessUnix::get_filesystem_type() const {
|
||||||
|
return ""; //TODO this should be implemented
|
||||||
|
}
|
||||||
|
|
||||||
DirAccessUnix::DirAccessUnix() {
|
DirAccessUnix::DirAccessUnix() {
|
||||||
|
|
||||||
dir_stream = 0;
|
dir_stream = 0;
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ public:
|
|||||||
|
|
||||||
virtual size_t get_space_left();
|
virtual size_t get_space_left();
|
||||||
|
|
||||||
|
virtual String get_filesystem_type() const;
|
||||||
|
|
||||||
|
|
||||||
DirAccessUnix();
|
DirAccessUnix();
|
||||||
~DirAccessUnix();
|
~DirAccessUnix();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -346,6 +346,35 @@ size_t DirAccessWindows::get_space_left() {
|
|||||||
return (size_t)bytes;
|
return (size_t)bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String DirAccessWindows::get_filesystem_type() const {
|
||||||
|
String path = fix_path(const_cast<DirAccessWindows*>(this)->get_current_dir());
|
||||||
|
print_line("fixed path: "+path);
|
||||||
|
int unit_end = path.find(":");
|
||||||
|
ERR_FAIL_COND_V(unit_end==-1,String());
|
||||||
|
String unit = path.substr(0,unit_end+1) + "\\";
|
||||||
|
print_line("unit: "+unit);
|
||||||
|
|
||||||
|
TCHAR szVolumeName[100] = "";
|
||||||
|
TCHAR szFileSystemName[10] = "";
|
||||||
|
DWORD dwSerialNumber = 0;
|
||||||
|
DWORD dwMaxFileNameLength = 0;
|
||||||
|
DWORD dwFileSystemFlags = 0;
|
||||||
|
|
||||||
|
if(::GetVolumeInformation(unit.utf8().get_data(),
|
||||||
|
szVolumeName,
|
||||||
|
sizeof(szVolumeName),
|
||||||
|
&dwSerialNumber,
|
||||||
|
&dwMaxFileNameLength,
|
||||||
|
&dwFileSystemFlags,
|
||||||
|
szFileSystemName,
|
||||||
|
sizeof(szFileSystemName)) == TRUE) {
|
||||||
|
|
||||||
|
return String(szFileSystemName);
|
||||||
|
}
|
||||||
|
|
||||||
|
ERR_FAIL_V("");
|
||||||
|
}
|
||||||
|
|
||||||
DirAccessWindows::DirAccessWindows() {
|
DirAccessWindows::DirAccessWindows() {
|
||||||
|
|
||||||
p = memnew(DirAccessWindowsPrivate);
|
p = memnew(DirAccessWindowsPrivate);
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ public:
|
|||||||
//virtual FileType get_file_type() const;
|
//virtual FileType get_file_type() const;
|
||||||
size_t get_space_left();
|
size_t get_space_left();
|
||||||
|
|
||||||
|
virtual String get_filesystem_type() const;
|
||||||
|
|
||||||
|
|
||||||
DirAccessWindows();
|
DirAccessWindows();
|
||||||
~DirAccessWindows();
|
~DirAccessWindows();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -797,7 +797,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
|
|||||||
bool updated_dir = false;
|
bool updated_dir = false;
|
||||||
String cd = p_dir->get_path();
|
String cd = p_dir->get_path();
|
||||||
|
|
||||||
if (current_mtime != p_dir->modified_time) {
|
if (current_mtime != p_dir->modified_time || using_fat_32) {
|
||||||
|
|
||||||
updated_dir = true;
|
updated_dir = true;
|
||||||
p_dir->modified_time = current_mtime;
|
p_dir->modified_time = current_mtime;
|
||||||
@@ -1809,10 +1809,14 @@ EditorFileSystem::EditorFileSystem() {
|
|||||||
if (da->change_dir("res://.import") != OK) {
|
if (da->change_dir("res://.import") != OK) {
|
||||||
da->make_dir("res://.import");
|
da->make_dir("res://.import");
|
||||||
}
|
}
|
||||||
|
//this should probably also work on Unix and use the string it returns for FAT32
|
||||||
|
using_fat_32 = da->get_filesystem_type()=="FAT32";
|
||||||
memdelete(da);
|
memdelete(da);
|
||||||
|
|
||||||
scan_total = 0;
|
scan_total = 0;
|
||||||
update_script_classes_queued = false;
|
update_script_classes_queued = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorFileSystem::~EditorFileSystem() {
|
EditorFileSystem::~EditorFileSystem() {
|
||||||
|
|||||||
@@ -231,6 +231,8 @@ class EditorFileSystem : public Node {
|
|||||||
|
|
||||||
static Error _resource_import(const String &p_path);
|
static Error _resource_import(const String &p_path);
|
||||||
|
|
||||||
|
bool using_fat_32; //workaround for projects in FAT32 filesystem (pendrives, most of the time)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|||||||
@@ -212,6 +212,12 @@ Error DirAccessJAndroid::remove(String p_name) {
|
|||||||
ERR_FAIL_V(ERR_UNAVAILABLE);
|
ERR_FAIL_V(ERR_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String DirAccessJAndroid::get_filesystem_type() const {
|
||||||
|
|
||||||
|
return "APK";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//FileType get_file_type() const;
|
//FileType get_file_type() const;
|
||||||
size_t DirAccessJAndroid::get_space_left() {
|
size_t DirAccessJAndroid::get_space_left() {
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ public:
|
|||||||
virtual Error rename(String p_from, String p_to);
|
virtual Error rename(String p_from, String p_to);
|
||||||
virtual Error remove(String p_name);
|
virtual Error remove(String p_name);
|
||||||
|
|
||||||
|
virtual String get_filesystem_type() const;
|
||||||
|
|
||||||
//virtual FileType get_file_type() const;
|
//virtual FileType get_file_type() const;
|
||||||
size_t get_space_left();
|
size_t get_space_left();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user