Jelajahi Sumber

API add: os_path can now be used to query for the os-specific path of a file

Daniele Bartolini 12 tahun lalu
induk
melakukan
9bc7c3382a
2 mengubah file dengan 16 tambahan dan 0 penghapusan
  1. 10 0
      src/Filesystem.cpp
  2. 6 0
      src/Filesystem.h

+ 10 - 0
src/Filesystem.cpp

@@ -169,6 +169,16 @@ bool Filesystem::delete_dir(const char* relative_path)
 	return os::rmdir(os_path);
 }
 
+//-----------------------------------------------------------------------------
+const char* Filesystem::os_path(const char* relative_path)
+{
+	FilesystemEntry entry;
+
+	get_info(relative_path, entry);
+
+	return entry.os_path;
+}
+
 //-----------------------------------------------------------------------------
 FileStream* Filesystem::open(const char* relative_path, StreamOpenMode mode)
 {

+ 6 - 0
src/Filesystem.h

@@ -132,6 +132,12 @@ public:
 	/// Deletes the directory @relative_path
 	bool				delete_dir(const char* relative_path);
 
+	/// Returns the os-specific path which @relative_path refers to.
+	/// @note
+	/// In general, you typically do not want to use it for normal
+	/// file interactions. Prefer using the other methods whenever possible.
+	const char*			os_path(const char* relative_path);
+
 	/// Opens the file @relative_path with the specified access @mode
 	FileStream*			open(const char* relative_path, StreamOpenMode mode);