MFile

(Difference between revisions)
Jump to: navigation, search
(API reference for MFile, file I/O wrapper)
 
Line 1: Line 1:
==MFile==
+
File I/O class. This interface can be used manually, but will usually be used from the [[MFileTools]] interface, to more closely match standard C file I/O.
  
===Code===
+
==Code==
 
<pre>
 
<pre>
 
class M_CORE_EXPORT MFile
 
class M_CORE_EXPORT MFile
Line 24: Line 24:
 
};</pre>
 
};</pre>
  
===API===
+
==API==
====open====
+
===open===
 
Opens a file stream with the name specified by ''path''. The argument ''mode'' should be a string containing one of the following modes:
 
Opens a file stream with the name specified by ''path''. The argument ''mode'' should be a string containing one of the following modes:
  
Line 42: Line 42:
 
see also:[[MFileTools#M_fopen|M_fopen]], [http://www.cplusplus.com/reference/clibrary/cstdio/fopen/ fopen]
 
see also:[[MFileTools#M_fopen|M_fopen]], [http://www.cplusplus.com/reference/clibrary/cstdio/fopen/ fopen]
  
====close====
+
===close===
 
Close a file stream, if open.
 
Close a file stream, if open.
  
 
see also:[[MFileTools#M_fclose|M_fclose]], [http://www.cplusplus.com/reference/clibrary/cstdio/fclose/ fclose]
 
see also:[[MFileTools#M_fclose|M_fclose]], [http://www.cplusplus.com/reference/clibrary/cstdio/fclose/ fclose]
  
====read====
+
===read===
  
 
see also:[[MFileTools#M_fread|M_fread]], [http://www.cplusplus.com/reference/clibrary/cstdio/fread/ fread]
 
see also:[[MFileTools#M_fread|M_fread]], [http://www.cplusplus.com/reference/clibrary/cstdio/fread/ fread]

Revision as of 15:50, 9 April 2012

File I/O class. This interface can be used manually, but will usually be used from the MFileTools interface, to more closely match standard C file I/O.

Contents

Code

class M_CORE_EXPORT MFile
{
public:
	
	// destructor
	virtual ~MFile(void){}
	
	virtual void	open(const char* path, const char* mode) = 0;
	virtual int		close() = 0;
	virtual size_t	read(void* dest, size_t size, size_t count) = 0;
	virtual size_t	write(const void* str, size_t size, size_t count) = 0;
	virtual int		print(const char* format, ...) = 0;
	virtual int		print(const char* format, va_list args) = 0;
	virtual int		seek(long offset, int whence) = 0;
	virtual long	tell() = 0;
	virtual void	rewind() = 0;
	
	virtual bool 	isOpen() = 0;
	virtual void	destroy() = 0;
};

API

open

Opens a file stream with the name specified by path. The argument mode should be a string containing one of the following modes:

mode description
"r" read only, start at the beginning of the file
"w" write only, erase existing file and start at the beginning

see also:M_fopen, fopen

close

Close a file stream, if open.

see also:M_fclose, fclose

read

see also:M_fread, fread

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox