Преглед изворни кода

implement set_root_path, Constructor is empty right now

mikymod пре 12 година
родитељ
комит
a7bcff3f5c
2 измењених фајлова са 22 додато и 12 уклоњено
  1. 15 8
      engine/core/filesystem/DiskMountPoint.cpp
  2. 7 4
      engine/core/filesystem/DiskMountPoint.h

+ 15 - 8
engine/core/filesystem/DiskMountPoint.cpp

@@ -28,18 +28,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Assert.h"
 #include "DiskFile.h"
 #include "StringUtils.h"
+#include "Allocator.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-DiskMountPoint::DiskMountPoint(const char* root_path) :
-	MountPoint(DISK_TYPE)
+DiskMountPoint::DiskMountPoint() : MountPoint(DISK_TYPE)
 {
-	CE_ASSERT(root_path != NULL, "Root path must be != NULL");
-	CE_ASSERT(os::is_absolute_path(root_path), "Root path must be absolute");
-
-	string::strncpy(m_root_path, root_path, MAX_PATH_LENGTH);
 }
 
 //-----------------------------------------------------------------------------
@@ -48,15 +44,24 @@ File* DiskMountPoint::open(const char* relative_path, FileOpenMode mode)
 	CE_ASSERT(exists(relative_path), "File does not exist: %s", relative_path);
 	CE_ASSERT(is_file(relative_path), "File is not a regular file: %s", relative_path);
 
-	return CE_NEW(m_allocator, DiskFile)(mode, os_path(relative_path));
+	return CE_NEW(default_allocator(), DiskFile)(mode, os_path(relative_path));
 }
 
 //-----------------------------------------------------------------------------
 void DiskMountPoint::close(File* file)
 {
-	CE_DELETE(m_allocator, file);
+	CE_DELETE(default_allocator(), file);
 }
 
+void DiskMountPoint::set_root_path(const char* root_path)
+{
+	CE_ASSERT(root_path != NULL, "Root path must be != NULL");
+	CE_ASSERT(os::is_absolute_path(root_path), "Root path must be absolute");
+
+	string::strncpy(m_root_path, root_path, MAX_PATH_LENGTH);
+}
+
+
 //-----------------------------------------------------------------------------
 const char*	DiskMountPoint::root_path() const
 {
@@ -78,6 +83,8 @@ bool DiskMountPoint::get_info(const char* relative_path, MountPointEntry& info)
 
 	const char* os_path = build_os_path(m_root_path, relative_path);
 
+	Log::d("path : %s", os_path);
+
 	string::strncpy(info.os_path, os_path, MAX_PATH_LENGTH);
 	string::strncpy(info.relative_path, relative_path, MAX_PATH_LENGTH);
 

+ 7 - 4
engine/core/filesystem/DiskMountPoint.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "MountPoint.h"
-#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -35,15 +34,21 @@ namespace crown
 class DiskMountPoint : public MountPoint
 {
 public:
-						DiskMountPoint(const char* root_path);
+						DiskMountPoint();
 
+	/// Opens file @a relative_path in specified @a mode
 	File*				open(const char* relative_path, FileOpenMode mode);
 
+	/// Closes @a file
 	void				close(File* file);
 
+	/// Sets @a root_path
+	void				set_root_path(const char* root_path);
+
 	/// Returns the root path of the mount point
 	const char*			root_path() const;
 
+	/// Returns true if file @a relative_path exists
 	bool				exists(const char* relative_path);
 
 	/// Returns whether the @a relative_path exists and fills @a info with
@@ -81,8 +86,6 @@ protected:
 
 protected:
 
-	HeapAllocator		m_allocator;
-
 	char				m_root_path[MAX_PATH_LENGTH];
 };