Przeglądaj źródła

Rename a bunch of filesystem related OS-specific functions

Daniele Bartolini 12 lat temu
rodzic
commit
bf57d88cc3

+ 28 - 10
engine/os/OS.h

@@ -74,15 +74,27 @@ bool			is_absolute_path(const char* path);
 //-----------------------------------------------------------------------------
 // File management
 //-----------------------------------------------------------------------------
-bool			exists(const char* path);		//!< Returns whether the path is a file or directory on the disk
 
-bool			is_dir(const char* path);		//!< Returns whether the path is a directory. (May not resolve symlinks.)
-bool			is_reg(const char* path);		//!< Returns whether the path is a regular file. (May not resolve symlinks.)
+/// Returns whether the path is a file or directory on the disk
+bool			exists(const char* path);
 
-bool			mknod(const char* path);		//! Creates a regular file. Returns true if success, false if not
-bool			unlink(const char* path);		//! Deletes a regular file. Returns true if success, false if not
-bool			mkdir(const char* path);		//! Creates a directory. Returns true if success, false if not
-bool			rmdir(const char* path);		//! Deletes a directory. Returns true if success, false if not
+/// Returns whether the path is a directory. (May not resolve symlinks.)
+bool			is_directory(const char* path);
+
+/// Returns whether the path is a regular file. (May not resolve symlinks.)
+bool			is_file(const char* path);
+
+/// Creates a regular file. Returns true if success, false if not
+bool			create_file(const char* path);
+
+/// Deletes a regular file. Returns true if success, false if not
+bool			delete_file(const char* path);
+
+/// Creates a directory. Returns true if success, false if not
+bool			create_directory(const char* path);
+
+/// Deletes a directory. Returns true if success, false if not
+bool			delete_directory(const char* path);
 
 /// Returns the list of @a files in the given @a dir directory. Optionally walks into
 /// subdirectories whether @a recursive is true.
@@ -93,9 +105,15 @@ void			list_files(const char* path, bool recursive, Vector<DynamicString>& files
 //-----------------------------------------------------------------------------
 // OS ambient variables
 //-----------------------------------------------------------------------------
-const char*		get_cwd();						//! Fills ret with the path of the current working directory. Returns true if success, false if not 
-const char*		get_home();						//! Fills ret with the path of the user home directory
-const char*		get_env(const char* env);		//! Returns the content of the 'env' environment variable or the empty string
+
+/// Fills ret with the path of the current working directory. Returns true if success, false if not 
+const char*		get_cwd();
+
+/// Fills ret with the path of the user home directory
+const char*		get_home();
+
+/// Returns the content of the 'env' environment variable or the empty string
+const char*		get_env(const char* env);
 
 //-----------------------------------------------------------------------------
 // Render window and input management

+ 6 - 6
engine/os/android/AndroidOS.cpp

@@ -128,7 +128,7 @@ bool exists(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool is_dir(const char* path)
+bool is_directory(const char* path)
 {
 	struct stat info;
 	memset(&info, 0, sizeof(struct stat));
@@ -137,7 +137,7 @@ bool is_dir(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool is_reg(const char* path)
+bool is_file(const char* path)
 {
 	struct stat info;
 	memset(&info, 0, sizeof(struct stat));
@@ -146,27 +146,27 @@ bool is_reg(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool mknod(const char* path)
+bool create_file(const char* path)
 {
 	// Permission mask: rw-r--r--
 	return ::mknod(path, S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, 0) == 0;
 }
 
 //-----------------------------------------------------------------------------
-bool unlink(const char* path)
+bool delete_file(const char* path)
 {
 	return (::unlink(path) == 0);
 }
 
 //-----------------------------------------------------------------------------
-bool mkdir(const char* path)
+bool create_directory(const char* path)
 {
 	// rwxr-xr-x permission mask
 	return (::mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0);
 }
 
 //-----------------------------------------------------------------------------
-bool rmdir(const char* path)
+bool delete_directory(const char* path)
 {
 	return (::rmdir(path) == 0);
 }

+ 6 - 6
engine/os/linux/LinuxOS.cpp

@@ -136,7 +136,7 @@ bool exists(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool is_dir(const char* path)
+bool is_directory(const char* path)
 {
 	struct stat info;
 	memset(&info, 0, sizeof(struct stat));
@@ -145,7 +145,7 @@ bool is_dir(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool is_reg(const char* path)
+bool is_file(const char* path)
 {
 	struct stat info;
 	memset(&info, 0, sizeof(struct stat));
@@ -154,27 +154,27 @@ bool is_reg(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool mknod(const char* path)
+bool create_file(const char* path)
 {
 	// Permission mask: rw-r--r--
 	return ::mknod(path, S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, 0) == 0;
 }
 
 //-----------------------------------------------------------------------------
-bool unlink(const char* path)
+bool delete_file(const char* path)
 {
 	return (::unlink(path) == 0);
 }
 
 //-----------------------------------------------------------------------------
-bool mkdir(const char* path)
+bool create_directory(const char* path)
 {
 	// rwxr-xr-x permission mask
 	return (::mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0);
 }
 
 //-----------------------------------------------------------------------------
-bool rmdir(const char* path)
+bool delete_directory(const char* path)
 {
 	return (::rmdir(path) == 0);
 }

+ 6 - 6
engine/os/win/WinOS.cpp

@@ -129,7 +129,7 @@ bool exists(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool is_dir(const char* path)
+bool is_direcotry(const char* path)
 {
 	DWORD fileAttr;
 	fileAttr = GetFileAttributes(path);
@@ -137,13 +137,13 @@ bool is_dir(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool is_reg(const char* path)
+bool is_file(const char* path)
 {
 	return !is_dir(path);
 }
 
 //-----------------------------------------------------------------------------
-bool mknod(const char* path)
+bool create_file(const char* path)
 {
 	HANDLE hFile = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 	if (hFile == INVALID_HANDLE_VALUE)
@@ -154,19 +154,19 @@ bool mknod(const char* path)
 }
 
 //-----------------------------------------------------------------------------
-bool unlink(const char* path)
+bool delete_file(const char* path)
 {
 	return DeleteFile(path) == TRUE;
 }
 
 //-----------------------------------------------------------------------------
-bool mkdir(const char* path)
+bool create_directory(const char* path)
 {
 	return CreateDirectory(path, NULL) == TRUE;
 }
 
 //-----------------------------------------------------------------------------
-bool rmdir(const char* path)
+bool delete_directory(const char* path)
 {
 	return RemoveDirectory(path) == TRUE;
 }