Daniele Bartolini 11 лет назад
Родитель
Сommit
8a91b26ea3

+ 14 - 14
engine/core/filesystem/apk_file.cpp

@@ -38,38 +38,38 @@ namespace crown
 
 ApkFile::ApkFile(AAssetManager* asset_manager, const char* path)
 	: File(FOM_READ)
-	, m_asset(NULL)
+	, _asset(NULL)
 {
-	m_asset = AAssetManager_open(asset_manager, path, AASSET_MODE_RANDOM);
-	CE_ASSERT(m_asset != NULL, "AAssetManager_open: failed to open %s", path);
+	_asset = AAssetManager_open(asset_manager, path, AASSET_MODE_RANDOM);
+	CE_ASSERT(_asset != NULL, "AAssetManager_open: failed to open %s", path);
 }
 
 ApkFile::~ApkFile()
 {
-	if (m_asset != NULL)
+	if (_asset != NULL)
 	{
-		AAsset_close(m_asset);
-		m_asset = NULL;
+		AAsset_close(_asset);
+		_asset = NULL;
 	}
 }
 
 void ApkFile::seek(size_t position)
 {
-	off_t seek_result = AAsset_seek(m_asset, (off_t)position, SEEK_SET);
+	off_t seek_result = AAsset_seek(_asset, (off_t)position, SEEK_SET);
 	CE_ASSERT(seek_result != (off_t) -1, "AAsset_seek: error");
 	CE_UNUSED(seek_result);
 }
 
 void ApkFile::seek_to_end()
 {
-	off_t seek_result = AAsset_seek(m_asset, 0, SEEK_END);
+	off_t seek_result = AAsset_seek(_asset, 0, SEEK_END);
 	CE_ASSERT(seek_result != (off_t) -1, "AAsset_seek: error");
 	CE_UNUSED(seek_result);
 }
 
 void ApkFile::skip(size_t bytes)
 {
-	off_t seek_result = AAsset_seek(m_asset, (off_t) bytes, SEEK_CUR);
+	off_t seek_result = AAsset_seek(_asset, (off_t) bytes, SEEK_CUR);
 	CE_ASSERT(seek_result != (off_t) -1, "AAsset_seek: error");
 	CE_UNUSED(seek_result);
 }
@@ -77,7 +77,7 @@ void ApkFile::skip(size_t bytes)
 void ApkFile::read(void* buffer, size_t size)
 {
 	CE_ASSERT_NOT_NULL(buffer);
-	size_t bytes_read = (size_t) AAsset_read(m_asset, buffer, size);
+	size_t bytes_read = (size_t) AAsset_read(_asset, buffer, size);
 	CE_ASSERT(bytes_read == size, "AAsset_read: requested: %lu, read: %lu", size, bytes_read);
 	CE_UNUSED(bytes_read);
 }
@@ -100,22 +100,22 @@ void ApkFile::flush()
 
 bool ApkFile::is_valid()
 {
-	return m_asset != NULL;
+	return _asset != NULL;
 }
 
 bool ApkFile::end_of_file()
 {
-	return AAsset_getRemainingLength(m_asset) == 0;
+	return AAsset_getRemainingLength(_asset) == 0;
 }
 
 size_t ApkFile::size()
 {
-	return AAsset_getLength(m_asset);
+	return AAsset_getLength(_asset);
 }
 
 size_t ApkFile::position()
 {
-	return (size_t) (AAsset_getLength(m_asset) - AAsset_getRemainingLength(m_asset));
+	return (size_t) (AAsset_getLength(_asset) - AAsset_getRemainingLength(_asset));
 }
 
 bool ApkFile::can_read() const

+ 1 - 1
engine/core/filesystem/apk_file.h

@@ -85,7 +85,7 @@ public:
 
 private:
 
-	AAsset* m_asset;
+	AAsset* _asset;
 };
 
 } // namespace crown

+ 21 - 21
engine/core/filesystem/disk_file.cpp

@@ -33,50 +33,50 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-DiskFile::DiskFile(FileOpenMode mode, const char* filename) :
-	File(mode),
-	m_file(filename, mode),
-	m_last_was_read(true)
+DiskFile::DiskFile(FileOpenMode mode, const char* filename)
+	: File(mode)
+	, _file(filename, mode)
+	, _last_was_read(true)
 {
 }
 
 DiskFile::~DiskFile()
 {
-	m_file.close();
+	_file.close();
 }
 
 void DiskFile::seek(size_t position)
 {
 	check_valid();
 
-	m_file.seek(position);
+	_file.seek(position);
 }
 
 void DiskFile::seek_to_end()
 {
 	check_valid();
 
-	m_file.seek_to_end();
+	_file.seek_to_end();
 }
 
 void DiskFile::skip(size_t bytes)
 {
 	check_valid();
 
-	m_file.skip(bytes);
+	_file.skip(bytes);
 }
 
 void DiskFile::read(void* buffer, size_t size)
 {
 	check_valid();
 
-	if (!m_last_was_read)
+	if (!_last_was_read)
 	{
-		m_last_was_read = true;
-		m_file.seek(0);
+		_last_was_read = true;
+		_file.seek(0);
 	}
 
-	/*size_t bytes_read =*/ m_file.read(buffer, size);
+	/*size_t bytes_read =*/ _file.read(buffer, size);
 	//CE_ASSERT(bytes_read == size, "Failed to read from file: requested: %llu, read: %llu", size, bytes_read);
 }
 
@@ -84,13 +84,13 @@ void DiskFile::write(const void* buffer, size_t size)
 {
 	check_valid();
 
-	if (m_last_was_read)
+	if (_last_was_read)
 	{
-		m_last_was_read = false;
-		m_file.seek(0);
+		_last_was_read = false;
+		_file.seek(0);
 	}
 
-	/*size_t bytes_written =*/ m_file.write(buffer, size);
+	/*size_t bytes_written =*/ _file.write(buffer, size);
 	//CE_ASSERT(bytes_written == size, "Failed to write to file: requested: %llu, written: %llu", size, bytes_written);
 }
 
@@ -109,11 +109,11 @@ bool DiskFile::copy_to(File& file, size_t size)
 		size_t read_bytes;
 		size_t expected_read_bytes = math::min(size - tot_read_bytes, chunksize);
 
-		read_bytes = m_file.read(buff, expected_read_bytes);
+		read_bytes = _file.read(buff, expected_read_bytes);
 
 		if (read_bytes < expected_read_bytes)
 		{
-			if (m_file.eof())
+			if (_file.eof())
 			{
 				if (read_bytes != 0)
 				{
@@ -141,7 +141,7 @@ bool DiskFile::end_of_file()
 
 bool DiskFile::is_valid()
 {
-	return m_file.is_open();
+	return _file.is_open();
 }
 
 void DiskFile::flush()
@@ -155,14 +155,14 @@ size_t DiskFile::position()
 {
 	check_valid();
 
-	return m_file.position();
+	return _file.position();
 }
 
 size_t DiskFile::size()
 {
 	check_valid();
 
-	return m_file.size();
+	return _file.size();
 }
 
 bool DiskFile::can_read() const

+ 3 - 3
engine/core/filesystem/disk_file.h

@@ -88,14 +88,14 @@ public:
 
 protected:
 
-	OsFile m_file;
-	bool m_last_was_read;
+	OsFile _file;
+	bool _last_was_read;
 
 protected:
 
 	inline void check_valid() const
 	{
-		CE_ASSERT(m_file.is_open(), "File is not open");
+		CE_ASSERT(_file.is_open(), "File is not open");
 	}
 };
 

+ 3 - 3
engine/core/filesystem/disk_filesystem.cpp

@@ -35,13 +35,13 @@ namespace crown
 
 DiskFilesystem::DiskFilesystem()
 {
-	os::getcwd(m_root_path, MAX_PATH_LENGTH);
+	os::getcwd(_root_path, MAX_PATH_LENGTH);
 }
 
 DiskFilesystem::DiskFilesystem(const char* root_path)
 {
 	CE_ASSERT_NOT_NULL(root_path);
-	string::strncpy(m_root_path, root_path, MAX_PATH_LENGTH);
+	string::strncpy(_root_path, root_path, MAX_PATH_LENGTH);
 }
 
 File* DiskFilesystem::open(const char* path, FileOpenMode mode)
@@ -159,7 +159,7 @@ void DiskFilesystem::get_absolute_path(const char* path, DynamicString& os_path)
 		return;
 	}
 
-	os_path += m_root_path;
+	os_path += _root_path;
 	os_path += PATH_SEPARATOR;
 	os_path += path;
 }

+ 1 - 1
engine/core/filesystem/disk_filesystem.h

@@ -90,7 +90,7 @@ public:
 
 private:
 
-	char m_root_path[MAX_PATH_LENGTH];
+	char _root_path[MAX_PATH_LENGTH];
 };
 
 } // namespace crown

+ 2 - 2
engine/core/filesystem/file.h

@@ -53,7 +53,7 @@ class File
 public:
 
 	/// Opens the file with the given @a mode
-	File(FileOpenMode mode) : m_open_mode(mode) {}
+	File(FileOpenMode mode) : _open_mode(mode) {}
 	virtual ~File() {};
 
 	/// Sets the position indicator of the file to position.
@@ -110,7 +110,7 @@ public:
 
 protected:
 
-	FileOpenMode m_open_mode;
+	FileOpenMode _open_mode;
 };
 
 } // namespace crown

+ 17 - 17
engine/core/filesystem/network_file.cpp

@@ -41,32 +41,32 @@ namespace crown
 
 NetworkFile::NetworkFile(const NetAddress& addr, uint16_t port, const char* filename)
 	: File(FOM_READ)
-	, m_address(addr)
-	, m_port(port)
-	, m_position(0)
+	, _address(addr)
+	, _port(port)
+	, _position(0)
 {
-	string::strncpy(m_filename, filename, MAX_PATH_LENGTH);
-	m_socket.connect(addr, port);
+	string::strncpy(_filename, filename, MAX_PATH_LENGTH);
+	_socket.connect(addr, port);
 }
 
 NetworkFile::~NetworkFile()
 {
-	m_socket.close();
+	_socket.close();
 }
 
 void NetworkFile::seek(size_t position)
 {
-	m_position = position;
+	_position = position;
 }
 
 void NetworkFile::seek_to_end()
 {
-	m_position = size();
+	_position = size();
 }
 
 void NetworkFile::skip(size_t bytes)
 {
-	m_position += bytes;
+	_position += bytes;
 }
 
 void NetworkFile::read(void* buffer, size_t size)
@@ -78,15 +78,15 @@ void NetworkFile::read(void* buffer, size_t size)
 
 	// Request the file
 	command << "{\"type\":\"filesystem\",\"filesystem\":\"read\",";
-	command << "\"file\":\"" << m_filename << "\",";
-	command << "\"position\":" << m_position << ",";
+	command << "\"file\":\"" << _filename << "\",";
+	command << "\"position\":" << _position << ",";
 	command << "\"size\":" << size << "}";
 
-	network_filesystem::send(m_socket, c_str(command));
+	network_filesystem::send(_socket, c_str(command));
 
 	// Wait for response
 	Array<char> response(default_allocator());
-	network_filesystem::read_response(m_socket, response);
+	network_filesystem::read_response(_socket, response);
 
 	// Parse the response
 	JSONParser json(array::begin(response));
@@ -128,7 +128,7 @@ void NetworkFile::flush()
 
 size_t NetworkFile::position()
 {
-	return m_position;
+	return _position;
 }
 
 size_t NetworkFile::size()
@@ -140,13 +140,13 @@ size_t NetworkFile::size()
 
 	// Request the file
 	command << "{\"type\":\"filesystem\",\"filesystem\":\"size\",";
-	command << "\"file\":\"" << m_filename << "\"}";
+	command << "\"file\":\"" << _filename << "\"}";
 
-	network_filesystem::send(m_socket, c_str(command));
+	network_filesystem::send(_socket, c_str(command));
 
 	// Wait for response
 	Array<char> response(default_allocator());
-	network_filesystem::read_response(m_socket, response);
+	network_filesystem::read_response(_socket, response);
 
 	JSONParser parser(array::begin(response));
 	JSONElement root = parser.root();

+ 5 - 5
engine/core/filesystem/network_file.h

@@ -89,11 +89,11 @@ public:
 
 private:
 
-	char m_filename[MAX_PATH_LENGTH];
-	NetAddress m_address;
-	uint16_t m_port;
-	TCPSocket m_socket;
-	size_t m_position;
+	char _filename[MAX_PATH_LENGTH];
+	NetAddress _address;
+	uint16_t _port;
+	TCPSocket _socket;
+	size_t _position;
 };
 
 } // namespace crown

+ 4 - 4
engine/core/filesystem/network_filesystem.cpp

@@ -40,14 +40,14 @@ NetworkFilesystem::NetworkFilesystem()
 }
 
 NetworkFilesystem::NetworkFilesystem(const NetAddress& addr, uint16_t port)
-	: m_address(addr)
-	, m_port(port)
+	: _address(addr)
+	, _port(port)
 {
 }
 
 File* NetworkFilesystem::open(const char* path, FileOpenMode mode)
 {
-	return CE_NEW(default_allocator(), NetworkFile)(m_address, m_port, path);
+	return CE_NEW(default_allocator(), NetworkFile)(_address, _port, path);
 }
 
 void NetworkFilesystem::close(File* file)
@@ -99,7 +99,7 @@ void NetworkFilesystem::get_absolute_path(const char* path, DynamicString& os_pa
 TCPSocket NetworkFilesystem::new_connection()
 {
 	TCPSocket socket;
-	socket.connect(m_address, m_port);
+	socket.connect(_address, _port);
 	return socket;
 }
 

+ 2 - 2
engine/core/filesystem/network_filesystem.h

@@ -119,8 +119,8 @@ private:
 
 private:
 
-	NetAddress m_address;
-	uint16_t m_port;
+	NetAddress _address;
+	uint16_t _port;
 };
 
 } // namespace crown

+ 17 - 17
engine/core/filesystem/reader_writer.h

@@ -39,7 +39,7 @@ class TextReader
 {
 public:
 
-	TextReader(File& file) : m_file(file) {}
+	TextReader(File& file) : _file(file) {}
 
 	/// Reads characters from file and stores them as a C string
 	/// into string until (size-1) characters have been read or
@@ -54,9 +54,9 @@ public:
 		char current_char;
 		size_t bytes_read = 0;
 
-		while(!m_file.end_of_file() && bytes_read < size - 1)
+		while(!_file.end_of_file() && bytes_read < size - 1)
 		{
-			m_file.read(&current_char, 1);
+			_file.read(&current_char, 1);
 			string[bytes_read] = current_char;
 
 			bytes_read++;
@@ -74,7 +74,7 @@ public:
 
 private:
 
-	File& m_file;
+	File& _file;
 };
 
 /// A reader that offers a convenient way to write text to a File
@@ -84,7 +84,7 @@ class TextWriter
 {
 public:
 
-	TextWriter(File& file) : m_file(file) {}
+	TextWriter(File& file) : _file(file) {}
 
 	/// Writes the string pointed by string to the file.
 	/// The function begins copying from the address specified (string)
@@ -92,12 +92,12 @@ public:
 	/// The final null character is not copied to the file.
 	void write_string(const char* string)
 	{
-		m_file.write(string, string::strlen(string));
+		_file.write(string, string::strlen(string));
 	}
 
 private:
 
-	File& m_file;
+	File& _file;
 };
 
 /// A writer that offers a convenient way to write to a File
@@ -107,27 +107,27 @@ class BinaryWriter
 {
 public:
 
-	BinaryWriter(File& file) : m_file(file) {}
+	BinaryWriter(File& file) : _file(file) {}
 
 	void write(const void* data, size_t size)
 	{
-		m_file.write(data, size);
+		_file.write(data, size);
 	}
 
 	template <typename T>
 	void write(const T& data)
 	{
-		m_file.write(&data, sizeof(T));
+		_file.write(&data, sizeof(T));
 	}
 
 	void skip(size_t bytes)
 	{
-		m_file.skip(bytes);
+		_file.skip(bytes);
 	}
 
 private:
 
-	File& m_file;
+	File& _file;
 };
 
 /// A reader that offers a convenient way to read from a File
@@ -137,27 +137,27 @@ class BinaryReader
 {
 public:
 
-	BinaryReader(File& file) : m_file(file) {}
+	BinaryReader(File& file) : _file(file) {}
 
 	void read(void* data, size_t size)
 	{
-		m_file.read(data, size);
+		_file.read(data, size);
 	}
 
 	template <typename T>
 	void read(T& data)
 	{
-		m_file.read(&data, sizeof(T));
+		_file.read(&data, sizeof(T));
 	}
 
 	void skip(size_t bytes)
 	{
-		m_file.skip(bytes);
+		_file.skip(bytes);
 	}
 
 private:
 
-	File& m_file;
+	File& _file;
 };
 
 } // namespace crown