Bläddra i källkod

core: cleanup

Daniele Bartolini 1 år sedan
förälder
incheckning
f98a2ee8f3
4 ändrade filer med 35 tillägg och 35 borttagningar
  1. 5 5
      src/core/filesystem/filesystem_apk.cpp
  2. 6 6
      src/core/filesystem/filesystem_disk.cpp
  3. 20 20
      src/core/os.cpp
  4. 4 4
      src/core/os.h

+ 5 - 5
src/core/filesystem/filesystem_apk.cpp

@@ -137,11 +137,11 @@ Stat FilesystemApk::stat(const char *path)
 {
 	CE_UNUSED(path);
 
-	Stat info;
-	info.file_type = Stat::REGULAR;
-	info.size = 0;
-	info.mtime = UINT64_MAX;
-	return info;
+	Stat st;
+	st.file_type = Stat::REGULAR;
+	st.size = 0;
+	st.mtime = UINT64_MAX;
+	return st;
 }
 
 bool FilesystemApk::exists(const char *path)

+ 6 - 6
src/core/filesystem/filesystem_disk.cpp

@@ -93,9 +93,9 @@ struct FileDisk : public File
 #if CROWN_PLATFORM_WINDOWS
 		return GetFileSize(_file, NULL);
 #else
-		Stat stat;
-		os::stat(stat, fileno(_file));
-		return (u32)stat.size;
+		Stat st;
+		os::stat(st, fileno(_file));
+		return (u32)st.size;
 #endif
 	}
 
@@ -264,9 +264,9 @@ Stat FilesystemDisk::stat(const char *path)
 	DynamicString abs_path(ta);
 	absolute_path(abs_path, path);
 
-	Stat info;
-	os::stat(info, abs_path.c_str());
-	return info;
+	Stat st;
+	os::stat(st, abs_path.c_str());
+	return st;
 }
 
 bool FilesystemDisk::exists(const char *path)

+ 20 - 20
src/core/os.cpp

@@ -95,11 +95,11 @@ namespace os
 	}
 
 #if CROWN_PLATFORM_POSIX
-	void stat(Stat &info, int fd)
+	void stat(Stat &st, int fd)
 	{
-		info.file_type = Stat::NO_ENTRY;
-		info.size = 0;
-		info.mtime = 0;
+		st.file_type = Stat::NO_ENTRY;
+		st.size = 0;
+		st.mtime = 0;
 
 		struct stat buf;
 		memset(&buf, 0, sizeof(buf));
@@ -108,20 +108,20 @@ namespace os
 			return;
 
 		if (S_ISREG(buf.st_mode) == 1)
-			info.file_type = Stat::REGULAR;
+			st.file_type = Stat::REGULAR;
 		else if (S_ISDIR(buf.st_mode) == 1)
-			info.file_type = Stat::DIRECTORY;
+			st.file_type = Stat::DIRECTORY;
 
-		info.size  = buf.st_size;
-		info.mtime = buf.st_mtim.tv_sec * s64(1000000000) + buf.st_mtim.tv_nsec;
+		st.size  = buf.st_size;
+		st.mtime = buf.st_mtim.tv_sec * s64(1000000000) + buf.st_mtim.tv_nsec;
 	}
 #endif // if CROWN_PLATFORM_POSIX
 
-	void stat(Stat &info, const char *path)
+	void stat(Stat &st, const char *path)
 	{
-		info.file_type = Stat::NO_ENTRY;
-		info.size  = 0;
-		info.mtime = 0;
+		st.file_type = Stat::NO_ENTRY;
+		st.size  = 0;
+		st.mtime = 0;
 
 #if CROWN_PLATFORM_WINDOWS
 		WIN32_FIND_DATAA wfd;
@@ -131,19 +131,19 @@ namespace os
 		FindClose(fh);
 
 		if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
-			info.file_type = Stat::DIRECTORY;
+			st.file_type = Stat::DIRECTORY;
 		else // Assume regular file.
-			info.file_type = Stat::REGULAR;
+			st.file_type = Stat::REGULAR;
 
 		ULARGE_INTEGER fs = {};
 		fs.LowPart  = wfd.nFileSizeLow;
 		fs.HighPart = wfd.nFileSizeHigh;
-		info.size = fs.QuadPart;
+		st.size = fs.QuadPart;
 
 		ULARGE_INTEGER lwt = {};
 		lwt.LowPart  = wfd.ftLastWriteTime.dwLowDateTime;
 		lwt.HighPart = wfd.ftLastWriteTime.dwHighDateTime;
-		info.mtime = lwt.QuadPart * u64(100); // See https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
+		st.mtime = lwt.QuadPart * u64(100); // See https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
 #else
 		struct stat buf;
 		memset(&buf, 0, sizeof(buf));
@@ -152,12 +152,12 @@ namespace os
 			return;
 
 		if (S_ISREG(buf.st_mode) == 1)
-			info.file_type = Stat::REGULAR;
+			st.file_type = Stat::REGULAR;
 		else if (S_ISDIR(buf.st_mode) == 1)
-			info.file_type = Stat::DIRECTORY;
+			st.file_type = Stat::DIRECTORY;
 
-		info.size  = buf.st_size;
-		info.mtime = buf.st_mtim.tv_sec * s64(1000000000) + buf.st_mtim.tv_nsec;
+		st.size  = buf.st_size;
+		st.mtime = buf.st_mtim.tv_sec * s64(1000000000) + buf.st_mtim.tv_nsec;
 #endif // if CROWN_PLATFORM_WINDOWS
 	}
 

+ 4 - 4
src/core/os.h

@@ -102,12 +102,12 @@ namespace os
 	void log(const char *msg);
 
 #if CROWN_PLATFORM_POSIX
-	/// Returns information about @a fd.
-	void stat(Stat &info, int fd);
+	/// Returns the status of the file descriptor @a fd.
+	void stat(Stat &st, int fd);
 #endif
 
-	/// Returns information about @a path.
-	void stat(Stat &info, const char *path);
+	/// Returns the status of the file at @a path.
+	void stat(Stat &st, const char *path);
 
 	/// Deletes the file at @a path.
 	DeleteResult delete_file(const char *path);