ソースを参照

-made get_space_left() return values more homogenous, also for script, converted to mb, closes #4617

Juan Linietsky 9 年 前
コミット
e3905a084e

+ 1 - 1
core/bind/core_bind.cpp

@@ -1913,7 +1913,7 @@ bool _Directory::dir_exists(String p_dir) {
 int _Directory::get_space_left(){
 int _Directory::get_space_left(){
 
 
 	ERR_FAIL_COND_V(!d,0);
 	ERR_FAIL_COND_V(!d,0);
-	return d->get_space_left();
+	return d->get_space_left()/1024*1024; //return value in megabytes, given binding is int
 }
 }
 
 
 Error _Directory::copy(String p_from,String p_to){
 Error _Directory::copy(String p_from,String p_to){

+ 1 - 1
drivers/unix/dir_access_unix.cpp

@@ -321,7 +321,7 @@ size_t DirAccessUnix::get_space_left() {
 	struct statvfs vfs;
 	struct statvfs vfs;
 	if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
 	if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
 
 
-		return -1;
+		return 0;
 	};
 	};
 
 
 	return vfs.f_bfree * vfs.f_bsize;
 	return vfs.f_bfree * vfs.f_bsize;

+ 2 - 1
drivers/windows/dir_access_windows.cpp

@@ -359,7 +359,8 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const {
 size_t  DirAccessWindows::get_space_left() {
 size_t  DirAccessWindows::get_space_left() {
 
 
 	uint64_t bytes = 0;
 	uint64_t bytes = 0;
-	GetDiskFreeSpaceEx(NULL,(PULARGE_INTEGER)&bytes,NULL,NULL);
+	if (!GetDiskFreeSpaceEx(NULL,(PULARGE_INTEGER)&bytes,NULL,NULL))
+		return 0;
 
 
 	//this is either 0 or a value in bytes.
 	//this is either 0 or a value in bytes.
 	return (size_t)bytes;
 	return (size_t)bytes;