Просмотр исходного кода

Promote Filesystem to core and rename Stream to File and also rename implementations accordingly

Daniele Bartolini 12 лет назад
Родитель
Сommit
b17c6efff6

+ 10 - 10
src/core/streams/BinaryReader.cpp → src/core/filesystem/BinaryReader.cpp

@@ -24,13 +24,13 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "BinaryReader.h"
-#include "Stream.h"
+#include "File.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-BinaryReader::BinaryReader(Stream& stream) : m_stream(stream)
+BinaryReader::BinaryReader(File& file) : m_file(file)
 {
 }
 
@@ -38,7 +38,7 @@ BinaryReader::BinaryReader(Stream& stream) : m_stream(stream)
 int8_t BinaryReader::read_byte()
 {
 	int8_t buffer;
-	m_stream.read(&buffer, sizeof(int8_t));
+	m_file.read(&buffer, sizeof(int8_t));
 	return buffer;
 }
 
@@ -46,7 +46,7 @@ int8_t BinaryReader::read_byte()
 int16_t BinaryReader::read_int16()
 {
 	int16_t buffer;
-	m_stream.read(&buffer, sizeof(int16_t));
+	m_file.read(&buffer, sizeof(int16_t));
 	return buffer;
 }
 
@@ -54,7 +54,7 @@ int16_t BinaryReader::read_int16()
 uint16_t BinaryReader::read_uint16()
 {
 	uint16_t buffer;
-	m_stream.read(&buffer, sizeof(uint16_t));
+	m_file.read(&buffer, sizeof(uint16_t));
 	return buffer;
 }
 
@@ -62,7 +62,7 @@ uint16_t BinaryReader::read_uint16()
 int32_t BinaryReader::read_int32()
 {
 	int32_t buffer;
-	m_stream.read(&buffer, sizeof(int32_t));
+	m_file.read(&buffer, sizeof(int32_t));
 	return buffer;
 }
 
@@ -70,7 +70,7 @@ int32_t BinaryReader::read_int32()
 uint32_t BinaryReader::read_uint32()
 {
 	uint32_t buffer;
-	m_stream.read(&buffer, sizeof(uint32_t));
+	m_file.read(&buffer, sizeof(uint32_t));
 	return buffer;
 }
 
@@ -78,7 +78,7 @@ uint32_t BinaryReader::read_uint32()
 int64_t BinaryReader::read_int64()
 {
 	int64_t buffer;
-	m_stream.read(&buffer, sizeof(int64_t));
+	m_file.read(&buffer, sizeof(int64_t));
 	return buffer;
 }
 
@@ -86,7 +86,7 @@ int64_t BinaryReader::read_int64()
 double BinaryReader::read_double()
 {
 	double buffer;
-	m_stream.read(&buffer, sizeof(double));
+	m_file.read(&buffer, sizeof(double));
 	return buffer;
 }
 
@@ -94,7 +94,7 @@ double BinaryReader::read_double()
 float BinaryReader::read_float()
 {
 	float buffer;
-	m_stream.read(&buffer, sizeof(float));
+	m_file.read(&buffer, sizeof(float));
 	return buffer;
 }
 

+ 4 - 4
src/core/streams/BinaryReader.h → src/core/filesystem/BinaryReader.h

@@ -28,14 +28,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Stream;
+class File;
 
-/// A reader that offers a convenient way to read from a Stream
+/// A reader that offers a convenient way to read from a File
 class BinaryReader
 {
 public:
 
-						BinaryReader(Stream& s);
+						BinaryReader(File& file);
 
 	int8_t				read_byte();
 	int16_t				read_int16();
@@ -48,7 +48,7 @@ public:
 
 private:
 
-	Stream&				m_stream;
+	File&				m_file;
 };
 
 } // namespace crown

+ 10 - 10
src/core/streams/BinaryWriter.cpp → src/core/filesystem/BinaryWriter.cpp

@@ -24,62 +24,62 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "BinaryWriter.h"
-#include "Stream.h"
+#include "File.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-BinaryWriter::BinaryWriter(Stream& stream) : m_stream(stream)
+BinaryWriter::BinaryWriter(File& file) : m_file(file)
 {
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_byte(int8_t buffer)
 {
-	m_stream.write(&buffer, sizeof(int8_t));
+	m_file.write(&buffer, sizeof(int8_t));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_int16(int16_t buffer)
 {
-	m_stream.write(&buffer, sizeof(int16_t));
+	m_file.write(&buffer, sizeof(int16_t));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_uint16(uint16_t buffer)
 {
-	m_stream.write(&buffer, sizeof(uint16_t));
+	m_file.write(&buffer, sizeof(uint16_t));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_int32(int32_t buffer)
 {
-	m_stream.write(&buffer, sizeof(int32_t));
+	m_file.write(&buffer, sizeof(int32_t));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_uint32(uint32_t buffer)
 {
-	m_stream.write(&buffer, sizeof(uint32_t));
+	m_file.write(&buffer, sizeof(uint32_t));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_int64(int64_t buffer)
 {
-	m_stream.write(&buffer, sizeof(int64_t));
+	m_file.write(&buffer, sizeof(int64_t));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_double(double buffer)
 {
-	m_stream.write(&buffer, sizeof(double));
+	m_file.write(&buffer, sizeof(double));
 }
 
 //-----------------------------------------------------------------------------
 void BinaryWriter::write_float(float buffer)
 {
-	m_stream.write(&buffer, sizeof(float));
+	m_file.write(&buffer, sizeof(float));
 }
 
 } // namespace crown

+ 4 - 4
src/core/streams/BinaryWriter.h → src/core/filesystem/BinaryWriter.h

@@ -28,14 +28,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Stream;
+class File;
 
-/// A writer that offers a convenient way to write to a Stream
+/// A writer that offers a convenient way to write to a File
 class BinaryWriter
 {
 public:
 
-						BinaryWriter(Stream& s);
+						BinaryWriter(File& file);
 
 	void				write_byte(int8_t);
 	void				write_int16(int16_t);
@@ -48,7 +48,7 @@ public:
 
 private:
 
-	Stream&				m_stream;
+	File&				m_file;
 };
 
 } // namespace crown

+ 20 - 20
src/core/streams/FileStream.cpp → src/core/filesystem/DiskFile.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "FileStream.h"
+#include "DiskFile.h"
 #include "Types.h"
 #include "Log.h"
 #include "MathUtils.h"
@@ -32,21 +32,21 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-FileStream::FileStream(StreamOpenMode mode, const char* filename) :
-	Stream(mode),
+DiskFile::DiskFile(FileOpenMode mode, const char* filename) :
+	File(mode),
 	m_file(filename, mode),
 	m_last_was_read(true)
 {
 }
 
 //-----------------------------------------------------------------------------
-FileStream::~FileStream()
+DiskFile::~DiskFile()
 {
 	//m_file.close();
 }
 
 //-----------------------------------------------------------------------------
-void FileStream::seek(size_t position)
+void DiskFile::seek(size_t position)
 {
 	check_valid();
 
@@ -54,7 +54,7 @@ void FileStream::seek(size_t position)
 }
 
 //-----------------------------------------------------------------------------
-void FileStream::seek_to_end()
+void DiskFile::seek_to_end()
 {
 	check_valid();
 
@@ -62,7 +62,7 @@ void FileStream::seek_to_end()
 }
 
 //-----------------------------------------------------------------------------
-void FileStream::skip(size_t bytes)
+void DiskFile::skip(size_t bytes)
 {
 	check_valid();
 
@@ -70,7 +70,7 @@ void FileStream::skip(size_t bytes)
 }
 
 //-----------------------------------------------------------------------------
-void FileStream::read(void* buffer, size_t size)
+void DiskFile::read(void* buffer, size_t size)
 {
 	check_valid();
 
@@ -85,7 +85,7 @@ void FileStream::read(void* buffer, size_t size)
 }
 
 //-----------------------------------------------------------------------------
-void FileStream::write(const void* buffer, size_t size)
+void DiskFile::write(const void* buffer, size_t size)
 {
 	check_valid();
 
@@ -100,7 +100,7 @@ void FileStream::write(const void* buffer, size_t size)
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::copy_to(Stream& stream, size_t size)
+bool DiskFile::copy_to(File& file, size_t size)
 {
 	check_valid();
 
@@ -123,7 +123,7 @@ bool FileStream::copy_to(Stream& stream, size_t size)
 			{
 				if (read_bytes != 0)
 				{
-					stream.write(buff, read_bytes);
+					file.write(buff, read_bytes);
 				}
 			}
 
@@ -132,7 +132,7 @@ bool FileStream::copy_to(Stream& stream, size_t size)
 			return false;
 		}
 
-		stream.write(buff, read_bytes);
+		file.write(buff, read_bytes);
 		tot_read_bytes += read_bytes;
 	}
 
@@ -141,19 +141,19 @@ bool FileStream::copy_to(Stream& stream, size_t size)
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::end_of_stream() const
+bool DiskFile::end_of_file() const
 {
 	return position() == size();
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::is_valid() const
+bool DiskFile::is_valid() const
 {
 	return m_file.is_open();
 }
 
 //-----------------------------------------------------------------------------
-void FileStream::flush()
+void DiskFile::flush()
 {
 	check_valid();
 	
@@ -161,7 +161,7 @@ void FileStream::flush()
 }
 
 //-----------------------------------------------------------------------------
-size_t FileStream::position() const
+size_t DiskFile::position() const
 {
 	check_valid();
 
@@ -169,7 +169,7 @@ size_t FileStream::position() const
 }
 
 //-----------------------------------------------------------------------------
-size_t FileStream::size() const
+size_t DiskFile::size() const
 {
 	check_valid();
 	
@@ -177,7 +177,7 @@ size_t FileStream::size() const
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::can_read() const
+bool DiskFile::can_read() const
 {
 	check_valid();
 
@@ -185,7 +185,7 @@ bool FileStream::can_read() const
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::can_write() const
+bool DiskFile::can_write() const
 {
 	check_valid();
 
@@ -193,7 +193,7 @@ bool FileStream::can_write() const
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::can_seek() const
+bool DiskFile::can_seek() const
 {
 	return true;
 }

+ 21 - 24
src/core/streams/FileStream.h → src/core/filesystem/DiskFile.h

@@ -26,69 +26,66 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Assert.h"
-
-#include "Stream.h"
+#include "OsFile.h"
 #include "File.h"
 
 namespace crown
 {
 
-
-/// File stream.
 /// Provides common facilities to access files on disk.
-class FileStream: public Stream
+class DiskFile: public File
 {
 public:
 
 	/// Opens @filename with specified @mode
-					FileStream(StreamOpenMode mode, const char* filename);
-	virtual			~FileStream();
+					DiskFile(FileOpenMode mode, const char* filename);
+	virtual			~DiskFile();
 
-	/// @copydoc Stream::seek() 
+	/// @copydoc File::seek() 
 	void			seek(size_t position);
 
-	/// @copydoc Stream::seek_to_end() 
+	/// @copydoc File::seek_to_end() 
 	void			seek_to_end();
 
-	/// @copydoc Stream::skip() 
+	/// @copydoc File::skip() 
 	void			skip(size_t bytes);
 
-	/// @copydoc Stream::read() 
+	/// @copydoc File::read() 
 	void			read(void* buffer, size_t size);
 
-	/// @copydoc Stream::write() 
+	/// @copydoc File::write() 
 	void			write(const void* buffer, size_t size);
 
-	/// @copydoc Stream::copy_to() 
-	bool			copy_to(Stream& stream, size_t size = 0);
+	/// @copydoc File::copy_to() 
+	bool			copy_to(File& file, size_t size = 0);
 
-	/// @copydoc Stream::flush() 
+	/// @copydoc File::flush() 
 	void			flush();
 
-	/// @copydoc Stream::end_of_stream() 
-	bool			end_of_stream() const;
+	/// @copydoc File::end_of_file() 
+	bool			end_of_file() const;
 
-	/// @copydoc Stream::is_valid() 
+	/// @copydoc File::is_valid() 
 	bool			is_valid() const;
 
-	/// @copydoc Stream::size() 
+	/// @copydoc File::size() 
 	size_t			size() const;
 
-	/// @copydoc Stream::position() 
+	/// @copydoc File::position() 
 	size_t			position() const;
 
-	/// @copydoc Stream::can_read() 
+	/// @copydoc File::can_read() 
 	bool			can_read() const;
 
-	/// @copydoc Stream::can_write() 
+	/// @copydoc File::can_write() 
 	bool			can_write() const;
 
-	/// @copydoc Stream::can_seek() 
+	/// @copydoc File::can_seek() 
 	bool			can_seek() const;
 
 protected:
 
-	File			m_file;
+	OsFile			m_file;
 	bool			m_last_was_read;
 
 protected:

+ 9 - 9
src/core/streams/Stream.cpp → src/core/filesystem/File.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Stream.h"
+#include "File.h"
 #include "Types.h"
 #include "Compressor.h"
 #include "MallocAllocator.h"
@@ -32,7 +32,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-bool Stream::compress_to(Stream& stream, size_t size, size_t& zipped_size, Compressor& compressor)
+bool File::compress_to(File& file, size_t size, size_t& zipped_size, Compressor& compressor)
 {
 	MallocAllocator allocator;
 	void* in_buffer = (void*)allocator.allocate(size);
@@ -41,24 +41,24 @@ bool Stream::compress_to(Stream& stream, size_t size, size_t& zipped_size, Compr
 
 	void* compressed_buffer = compressor.compress(in_buffer, size, zipped_size);
 
-	stream.write(compressed_buffer, zipped_size);
+	file.write(compressed_buffer, zipped_size);
 
 	return true;
 }
 
 //-----------------------------------------------------------------------------
-bool Stream::uncompress_to(Stream& stream, size_t& unzipped_size, Compressor& compressor)
+bool File::uncompress_to(File& file, size_t& unzipped_size, Compressor& compressor)
 {
 	MallocAllocator allocator;
 
-	size_t stream_size = size();
-	void* in_buffer = (void*)allocator.allocate(stream_size);
+	size_t file_size = size();
+	void* in_buffer = (void*)allocator.allocate(file_size);
 
-	read(in_buffer, stream_size);
+	read(in_buffer, file_size);
 
-	void* uncompressed_buffer = compressor.uncompress(in_buffer, stream_size, unzipped_size);
+	void* uncompressed_buffer = compressor.uncompress(in_buffer, file_size, unzipped_size);
 
-	stream.write(uncompressed_buffer, unzipped_size);
+	file.write(uncompressed_buffer, unzipped_size);
 
 	return true;
 }

+ 34 - 34
src/core/streams/Stream.h → src/core/filesystem/File.h

@@ -30,90 +30,90 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-enum StreamOpenMode
+enum FileOpenMode
 {
-	SOM_READ		= 1,
-	SOM_WRITE		= 2
+	FOM_READ		= 1,
+	FOM_WRITE		= 2
 };
 
 class Compressor;
 
-/// An abstraction to access data streams.
+/// An abstraction to access data files.
 /// 
 /// It represents a flow of data attached to a 'file' which can be an archived file,
 /// a regular file, a location in memory or anything that can be read or wrote.
-/// A Stream is an abstraction to interact with these in an uniform way; every stream
+/// A File is an abstraction to interact with these in an uniform way; every file
 /// comes with a convenient set of methods to facilitate reading from it, writing to
 /// it and so on.
-class Stream
+class File
 {
 public:
 
-	/// Opens the stream with the given @mode
-						Stream(StreamOpenMode mode) : m_open_mode(mode) {}
-	virtual				~Stream() {};
+	/// Opens the file with the given @mode
+						File(FileOpenMode mode) : m_open_mode(mode) {}
+	virtual				~File() {};
 
-	/// Sets the position indicator of the stream to position.
+	/// Sets the position indicator of the file to position.
 	virtual void		seek(size_t position) = 0;
 
-	/// Sets the position indicator to the end of the stream
+	/// Sets the position indicator to the end of the file
 	virtual void		seek_to_end() = 0;
 
 	/// Sets the position indicator to bytes after current position
 	virtual void		skip(size_t bytes) = 0;
 
-	/// Reads a block of data from the stream.
+	/// Reads a block of data from the file.
 	virtual void		read(void* buffer, size_t size) = 0;
 
-	/// Writes a block of data to the stream.
+	/// Writes a block of data to the file.
 	virtual void		write(const void* buffer, size_t size) = 0;
 
-	/// Copies a chunk of 'size' bytes of data from this to another stream.
-	virtual bool		copy_to(Stream& stream, size_t size = 0) = 0;
+	/// Copies a chunk of 'size' bytes of data from this to another file.
+	virtual bool		copy_to(File& file, size_t size = 0) = 0;
 
-	/// Zips a chunk of 'size' bytes of data from this to another stream using compressor.
-	virtual bool		compress_to(Stream& stream, size_t size, size_t& compressed_size, Compressor& compressor);
+	/// Zips a chunk of 'size' bytes of data from this to another file using compressor.
+	virtual bool		compress_to(File& file, size_t size, size_t& compressed_size, Compressor& compressor);
 
-	/// Unzip a zipped stream of data from this to another stream using compressor.
-	virtual bool		uncompress_to(Stream& stream, size_t& uncompressed_size, Compressor& compressor);
+	/// Unzip a zipped file of data from this to another file using compressor.
+	virtual bool		uncompress_to(File& file, size_t& uncompressed_size, Compressor& compressor);
 
 	/// Forces the previouses write operations to complete.
-	/// Generally, when a Stream is attached to a file,
+	/// Generally, when a File is attached to a file,
 	/// write operations are not performed instantly, the output data
 	/// may be stored to a temporary buffer before making its way to
 	/// the file. This method forces all the pending output operations
-	/// to be written to the stream.
+	/// to be written to the file.
 	virtual void		flush() = 0;
 
-	/// Returns whether the stream is valid.
-	/// A stream is valid when the buffer where it operates
-	/// exists. (i.e. a file descriptor is attached to the stream, 
-	/// a memory area is attached to the stream etc.)
+	/// Returns whether the file is valid.
+	/// A file is valid when the buffer where it operates
+	/// exists. (i.e. a file descriptor is attached to the file, 
+	/// a memory area is attached to the file etc.)
 	virtual bool		is_valid() const = 0;
 
-	/// Returns whether the position is at end of stream.
-	virtual bool		end_of_stream() const = 0;
+	/// Returns whether the position is at end of file.
+	virtual bool		end_of_file() const = 0;
 
-	/// Returns the size of stream in bytes.
+	/// Returns the size of file in bytes.
 	virtual size_t		size() const = 0;
 
-	/// Returns the current position in stream.
+	/// Returns the current position in file.
 	/// Generally, for binary data, it means the number of bytes
-	/// from the beginning of the stream.
+	/// from the beginning of the file.
 	virtual size_t		position() const = 0;
 
-	/// Returns whether the stream can be read.
+	/// Returns whether the file can be read.
 	virtual bool		can_read() const = 0;
 
-	/// Returns whether the stream can be wrote.
+	/// Returns whether the file can be wrote.
 	virtual bool		can_write() const = 0;
 
-	/// Returns whether the stream can be sought.
+	/// Returns whether the file can be sought.
 	virtual bool		can_seek() const = 0;
 
 protected:
 
-	StreamOpenMode		m_open_mode;
+	FileOpenMode		m_open_mode;
 };
 
 } // namespace crown

+ 4 - 4
src/Filesystem.cpp → src/core/filesystem/Filesystem.cpp

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Filesystem.h"
 #include "Log.h"
 #include "OS.h"
-#include "FileStream.h"
+#include "DiskFile.h"
 
 namespace crown
 {
@@ -184,18 +184,18 @@ const char* Filesystem::os_path(const char* relative_path)
 }
 
 //-----------------------------------------------------------------------------
-FileStream* Filesystem::open(const char* relative_path, StreamOpenMode mode)
+DiskFile* Filesystem::open(const char* relative_path, FileOpenMode mode)
 {
 	FilesystemEntry info;
 
 	CE_ASSERT(get_info(relative_path, info), "File does not exist: %s", relative_path);
 	CE_ASSERT(info.type == FilesystemEntry::FILE, "File is not a regular file: %s", relative_path);
 
-	return new FileStream(mode, info.os_path);
+	return new DiskFile(mode, info.os_path);
 }
 
 //-----------------------------------------------------------------------------
-void Filesystem::close(FileStream* stream)
+void Filesystem::close(DiskFile* stream)
 {
 	delete stream;
 }

+ 4 - 4
src/Filesystem.h → src/core/filesystem/Filesystem.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "String.h"
 #include "OS.h"
-#include "Stream.h"
+#include "File.h"
 
 namespace crown
 {
@@ -49,7 +49,7 @@ struct FilesystemEntry
 	char			relative_path[os::MAX_PATH_LENGTH];	///< Relative path of the entry
 };
 
-class FileStream;
+class DiskFile;
 
 /// Provides a platform-independent way to access files and directories
 /// on the host filesystem.
@@ -139,10 +139,10 @@ public:
 	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);
+	DiskFile*			open(const char* relative_path, FileOpenMode mode);
 
 	/// Closes a previously opened file @stream
-	void				close(FileStream* stream);
+	void				close(DiskFile* stream);
 
 private:
 

+ 20 - 18
src/core/streams/MemoryStream.cpp → src/core/filesystem/MemoryFile.cpp

@@ -24,7 +24,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include <stdlib.h>
-#include "MemoryStream.h"
+
+#include "MemoryFile.h"
 #include "MathUtils.h"
 #include "Log.h"
 #include "Types.h"
@@ -100,33 +101,34 @@ void DynamicMemoryBuffer::allocate(size_t capacity)
 {
 	// FIXME
 }
+
 //-----------------------------------------------------------------------------
-MemoryStream::MemoryStream(MemoryBuffer* buffer, StreamOpenMode mode) :
-	Stream(mode),
+MemoryFile::MemoryFile(MemoryBuffer* buffer, FileOpenMode mode) :
+	File(mode),
 	m_memory(buffer),
 	m_memory_offset(0)
 {
 }
 
 //-----------------------------------------------------------------------------
-MemoryStream::~MemoryStream()
+MemoryFile::~MemoryFile()
 {
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::seek(size_t position)
+void MemoryFile::seek(size_t position)
 {
 	check_valid();
 	
 	m_memory_offset = position;
 
-	// Allow seek to m_memory->size() position, that means end of stream,
+	// Allow seek to m_memory->size() position, that means end of file,
 	// reading not allowed but you can write if it's dynamic
-	CE_ASSERT(m_memory_offset <= m_memory->size(), "Trying to seek beyond end of stream");
+	CE_ASSERT(m_memory_offset <= m_memory->size(), "Trying to seek beyond end of file");
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::seek_to_end()
+void MemoryFile::seek_to_end()
 {
 	check_valid();
 
@@ -134,18 +136,18 @@ void MemoryStream::seek_to_end()
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::skip(size_t bytes)
+void MemoryFile::skip(size_t bytes)
 {
 	check_valid();
 
 	m_memory_offset += bytes;
 
-	//Allow seek to m_memory->getSize() position, that means end of stream, reading not allowed but you can write if it's dynamic
-	CE_ASSERT(m_memory_offset <= m_memory->size(), "Trying to skip beyond end of stream");
+	//Allow seek to m_memory->getSize() position, that means end of file, reading not allowed but you can write if it's dynamic
+	CE_ASSERT(m_memory_offset <= m_memory->size(), "Trying to skip beyond end of file");
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::read(void* buffer, size_t size)
+void MemoryFile::read(void* buffer, size_t size)
 {
 	check_valid();
 	uint8_t* src = m_memory->data();
@@ -153,7 +155,7 @@ void MemoryStream::read(void* buffer, size_t size)
 
 	if (m_memory_offset + size > m_memory->size())
 	{
-		Log::e("Trying to read beyond the end of stream.");
+		Log::e("Trying to read beyond the end of file.");
 	}
 
 	for (size_t i = 0; i < size; i++)
@@ -165,17 +167,17 @@ void MemoryStream::read(void* buffer, size_t size)
 }
 
 //-----------------------------------------------------------------------------
-bool MemoryStream::copy_to(Stream& stream, size_t size)
+bool MemoryFile::copy_to(File& file, size_t size)
 {
 	check_valid();
 
-	stream.write(&(m_memory->data()[m_memory_offset]), math::min(m_memory->size()-m_memory_offset, size));
+	file.write(&(m_memory->data()[m_memory_offset]), math::min(m_memory->size()-m_memory_offset, size));
 
 	return true;
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::write(const void* buffer, size_t size)
+void MemoryFile::write(const void* buffer, size_t size)
 {
 	check_valid();
 	m_memory->write((uint8_t*)buffer, m_memory_offset, size);
@@ -183,13 +185,13 @@ void MemoryStream::write(const void* buffer, size_t size)
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::flush()
+void MemoryFile::flush()
 {
 	return;
 }
 
 //-----------------------------------------------------------------------------
-void MemoryStream::dump()
+void MemoryFile::dump()
 {
 	uint8_t* buff = m_memory->data();
 

+ 23 - 23
src/core/streams/MemoryStream.h → src/core/filesystem/MemoryFile.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Stream.h"
+#include "File.h"
 #include "Allocator.h"
 #include "Assert.h"
 
@@ -78,58 +78,58 @@ protected:
 	size_t				m_size;
 };
 
-/// Memory stream.
+/// Memory file.
 /// Access memory buffers.
-class MemoryStream: public Stream
+class MemoryFile: public File
 {
 public:
 
-	/// @copydoc Stream::Stream()
-						MemoryStream(MemoryBuffer* buffer, StreamOpenMode mode);
+	/// @copydoc File::File()
+						MemoryFile(MemoryBuffer* buffer, FileOpenMode mode);
 
-	/// @copydoc Stream::~Stream()
-	virtual				~MemoryStream();
+	/// @copydoc File::~File()
+	virtual				~MemoryFile();
 
-	/// @copydoc Stream::seek()
+	/// @copydoc File::seek()
 	void				seek(size_t position);
 
-	/// @copydoc Stream::seek_to_end()
+	/// @copydoc File::seek_to_end()
 	void				seek_to_end();
 
-	/// @copydoc Stream::skip()
+	/// @copydoc File::skip()
 	void				skip(size_t bytes);
 
-	/// @copydoc Stream::read()
+	/// @copydoc File::read()
 	void				read(void* buffer, size_t size);
 
-	/// @copydoc Stream::write()
+	/// @copydoc File::write()
 	void				write(const void* buffer, size_t size);
 
-	/// @copydoc Stream::copy_to()
-	bool				copy_to(Stream& stream, size_t size = 0);
+	/// @copydoc File::copy_to()
+	bool				copy_to(File& file, size_t size = 0);
 
-	/// @copydoc Stream::flush()
+	/// @copydoc File::flush()
 	void				flush();
 
-	/// @copydoc Stream::end_of_stream()
-	bool				end_of_stream() const { return size() == m_memory_offset; }
+	/// @copydoc File::end_of_file()
+	bool				end_of_file() const { return size() == m_memory_offset; }
 
-	/// @copydoc Stream::is_valid()
+	/// @copydoc File::is_valid()
 	bool				is_valid() const { CE_ASSERT(m_memory != NULL, "Memory is NULL"); return m_memory->is_valid(); }
 
-	/// @copydoc Stream::size()
+	/// @copydoc File::size()
 	size_t				size() const { CE_ASSERT(m_memory != NULL, "Memory is NULL"); return m_memory->size(); }
 
-	/// @copydoc Stream::position()
+	/// @copydoc File::position()
 	size_t				position() const { return m_memory_offset; }
 
-	/// @copydoc Stream::can_read()
+	/// @copydoc File::can_read()
 	bool				can_read() const { return true; }
 
-	/// @copydoc Stream::can_write()
+	/// @copydoc File::can_write()
 	bool				can_write() const { return true; }
 
-	/// @copydoc Stream::can_seek()
+	/// @copydoc File::can_seek()
 	bool				can_seek() const { return true; }
 
 	/// Dumps the data to the console.

+ 24 - 24
src/core/streams/NullStream.h → src/core/filesystem/NullFile.h

@@ -25,34 +25,34 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Stream.h"
+#include "File.h"
 
 namespace crown
 {
 
 
-/// Bit bucket stream.
+/// Bit bucket file.
 /// Discards all data written to it and provides null data reading from it; plain and simple.
-class NullStream: public Stream
+class NullFile: public File
 {
 public:
 
-	/// @copydoc Stream::Stream()
-				NullStream(StreamOpenMode mode) : Stream(mode) {}
+	/// @copydoc File::File()
+				NullFile(FileOpenMode mode) : File(mode) {}
 
-	/// @copydoc Stream::~Stream()
-	virtual		~NullStream() {}
+	/// @copydoc File::~File()
+	virtual		~NullFile() {}
 
-	/// @copydoc Stream::seek()
+	/// @copydoc File::seek()
 	void		seek(size_t position) { (void)position; }
 
-	/// @copydoc Stream::seek_to_end()
+	/// @copydoc File::seek_to_end()
 	void		seek_to_end() {}
 
-	/// @copydoc Stream::skip()
+	/// @copydoc File::skip()
 	void		skip(size_t bytes) { (void)bytes; }
 				
-	/// @copydoc Stream::read()
+	/// @copydoc File::read()
 	/// @note
 	///	Fills buffer with zeroes
 	void		read(void* buffer, size_t size)
@@ -63,53 +63,53 @@ public:
 		}
 	}
 
-	/// @copydoc Stream::write()
+	/// @copydoc File::write()
 	void		write(const void* buffer, size_t size) { (void)buffer; (void)size; }
 
-	/// @copydoc Stream::copy_to()
+	/// @copydoc File::copy_to()
 	/// @note
 	///	Returns always true
-	bool		copy_to(Stream& stream, size_t size = 0)
+	bool		copy_to(File& file, size_t size = 0)
 	{
 		char zero = 0;
-		stream.write(&zero, size);		
+		file.write(&zero, size);		
 		return true;
 	}
 
-	/// @copydoc Stream::flush()
+	/// @copydoc File::flush()
 	void		flush() {};
 				
-	/// @copydoc Stream::is_valid()
+	/// @copydoc File::is_valid()
 	/// @note
 	///	Returns always true
 	bool		is_valid() { return true; }
 				
-	/// @copydoc Stream::end_of_stream()
+	/// @copydoc File::end_of_file()
 	/// @note
 	///	Returns always false
-	bool		end_of_stream() { return false; }
+	bool		end_of_file() { return false; }
 				
-	/// @copydoc Stream::size()
+	/// @copydoc File::size()
 	/// @note
 	///	Returns always 0xFFFFFFFF
 	size_t		size() { return ~0; }
 				
-	/// @copydoc Stream::position()
+	/// @copydoc File::position()
 	/// @note
 	///	Returns always zero
 	size_t		position() { return 0; }
 				
-	/// @copydoc Stream::can_read()
+	/// @copydoc File::can_read()
 	/// @note
 	///	Returns always true
 	bool		can_read() { return true; }
 				
-	/// @copydoc Stream::can_write()
+	/// @copydoc File::can_write()
 	/// @note
 	///	Returns always true
 	bool		can_write() { return true; }
 				
-	/// @copydoc Stream::can_seek()
+	/// @copydoc File::can_seek()
 	/// @note
 	///	Returns always true
 	bool		can_seek() { return true; }

+ 4 - 4
src/core/streams/TextReader.cpp → src/core/filesystem/TextReader.cpp

@@ -24,14 +24,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "TextReader.h"
-#include "Stream.h"
+#include "File.h"
 #include "Types.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-TextReader::TextReader(Stream& stream) : m_stream(stream)
+TextReader::TextReader(File& file) : m_file(file)
 {
 }
 
@@ -41,9 +41,9 @@ size_t TextReader::read_string(char* string, size_t size)
 	char current_char;
 	size_t bytes_read = 0;
 
-	while(!m_stream.end_of_stream() && bytes_read < size - 1)
+	while(!m_file.end_of_file() && bytes_read < size - 1)
 	{
-		m_stream.read(&current_char, 1);
+		m_file.read(&current_char, 1);
 		string[bytes_read] = current_char;
 
 		bytes_read++;

+ 6 - 6
src/core/streams/TextReader.h → src/core/filesystem/TextReader.h

@@ -28,18 +28,18 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Stream;
+class File;
 
-/// A reader that offers a convenient way to read text from a Stream
+/// A reader that offers a convenient way to read text from a File
 class TextReader
 {
 public:
 
-						TextReader(Stream& s);
+						TextReader(File& file);
 
-	/// Reads characters from stream and stores them as a C string
+	/// Reads characters from file and stores them as a C string
 	/// into string until (size-1) characters have been read or
-	/// either a newline or the End-of-Stream is reached, whichever
+	/// either a newline or the End-of-File is reached, whichever
 	/// comes first.
 	/// A newline character makes fgets stop reading, but it is considered
 	/// a valid character and therefore it is included in the string copied to string.
@@ -49,7 +49,7 @@ public:
 
 private:
 
-	Stream&				m_stream;
+	File&				m_file;
 };
 
 } // namespace crown

+ 3 - 3
src/core/streams/TextWriter.cpp → src/core/filesystem/TextWriter.cpp

@@ -24,21 +24,21 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "TextWriter.h"
-#include "Stream.h"
+#include "File.h"
 #include "String.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-TextWriter::TextWriter(Stream& stream) : m_stream(stream)
+TextWriter::TextWriter(File& file) : m_file(file)
 {
 }
 
 //-----------------------------------------------------------------------------
 void TextWriter::write_string(const char* string)
 {
-	m_stream.write(string, string::strlen(string));
+	m_file.write(string, string::strlen(string));
 }
 
 } // namespace crown

+ 6 - 6
src/core/streams/TextWriter.h → src/core/filesystem/TextWriter.h

@@ -26,24 +26,24 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Stream;
+class File;
 
-/// A reader that offers a convenient way to write text to a Stream
+/// A reader that offers a convenient way to write text to a File
 class TextWriter
 {
 public:
 
-						TextWriter(Stream& s);
+						TextWriter(File& file);
 	
-	/// Writes the string pointed by string to the stream.
+	/// Writes the string pointed by string to the file.
 	/// The function begins copying from the address specified (string)
 	/// until it reaches the terminating null character ('\0').
-	/// The final null character is not copied to the stream.
+	/// The final null character is not copied to the file.
 	void				write_string(const char* string);
 
 private:
 
-	Stream&				m_stream;
+	File&				m_file;
 };
 
 } // namespace crown