2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|
|
|
|
#include "acl_cpp/stream/istream.hpp"
|
|
|
|
|
#include "acl_cpp/stream/ostream.hpp"
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class string;
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API fstream
|
|
|
|
|
: public istream
|
|
|
|
|
, public ostream
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
fstream(void);
|
|
|
|
|
virtual ~fstream(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ķ<EFBFBD>ʽ
|
|
|
|
|
* @param path {const char*} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
2015-12-03 17:00:07 +08:00
|
|
|
|
* @param oflags {unsigned int} <EFBFBD><EFBFBD>־λ, We're assuming that
|
|
|
|
|
* O_RDONLY: 0x0000, O_WRONLY: 0x0001, O_RDWR: 0x0002,
|
|
|
|
|
* O_APPEND: 0x0008, O_CREAT: 0x0100, O_TRUNC: 0x0200,
|
|
|
|
|
* O_EXCL: 0x0400; just for win32, O_TEXT: 0x4000,
|
|
|
|
|
* O_BINARY: 0x8000, O_RAW: O_BINARY, O_SEQUENTIAL: 0x0020,
|
|
|
|
|
* O_RANDOM: 0x0010.
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param mode {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ģʽ(<EFBFBD><EFBFBD>: 0600)
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool open(const char* path, unsigned int oflags, int mode);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>Զ<EFBFBD>/д<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0700
|
|
|
|
|
* @param path {const char*} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool open_trunc(const char* path);
|
|
|
|
|
|
|
|
|
|
/**
|
2015-12-03 17:00:07 +08:00
|
|
|
|
* <EFBFBD>Զ<EFBFBD>/д<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0700, <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {bool} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool create(const char* path);
|
|
|
|
|
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> fstream <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param fh ϵͳ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param oflags <EFBFBD><EFBFBD>־λ
|
|
|
|
|
*/
|
|
|
|
|
void open(void* fh, unsigned int oflags);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ƶ<EFBFBD><EFBFBD>ļ<EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param offset {__int64} ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param whence {int} <EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SEEK_SET<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʼλ<EFBFBD>ú<EFBFBD><EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD>,
|
2015-12-03 17:00:07 +08:00
|
|
|
|
* SEEK_CUR(<EFBFBD>ӵ<EFBFBD>ǰ<EFBFBD>ļ<EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>), SEEK_END(<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>β<EFBFBD><EFBFBD>ǰ<EFBFBD>ƶ<EFBFBD>)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {acl_off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ >= 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
|
|
|
|
*/
|
|
|
|
|
__int64 fseek(__int64 offset, int whence);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰϵͳ<EFBFBD>ļ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>е<EFBFBD>ƫ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {acl_off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ >= 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
|
|
|
|
*/
|
|
|
|
|
__int64 ftell();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ߴ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @param length {acl_off_t} <EFBFBD>ļ<EFBFBD><EFBFBD>ضϺ<EFBFBD><EFBFBD>Ĵ<EFBFBD>С<EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool ftruncate(__int64 length);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD>ļ<EFBFBD><EFBFBD>Ĵ<EFBFBD>С
|
|
|
|
|
* @return {acl_off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ >= 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
|
|
|
|
*/
|
|
|
|
|
__int64 fsize(void) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return ϵͳ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_FILE_INVALID
|
|
|
|
|
*/
|
|
|
|
|
void* file_handle() const;
|
|
|
|
|
#else
|
|
|
|
|
void open(int fh, unsigned int oflags);
|
|
|
|
|
long long int fseek(long long int offset, int whence);
|
|
|
|
|
long long int ftell();
|
|
|
|
|
bool ftruncate(long long int length);
|
|
|
|
|
long long int fsize(void) const;
|
|
|
|
|
int file_handle() const;
|
|
|
|
|
#endif
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
const char* file_path() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|