YSTest
PreAlpha_b400_20130424
The YSLib Test Project
|
文件基类。 更多...
#include <yfile.h>
Public 成员函数 | |
File () | |
构造。 | |
File (const_path_t, const char *="rb") | |
构造:使用指定文件路径初始化对象。 | |
File (const_path_t, std::ios_base::openmode) | |
File (const String &, const ucs2_t *=u"rb") | |
File (const String &, std::ios_base::openmode) | |
virtual | ~File () |
析构。 | |
bool | operator! () const ynothrow |
判断无效性。 | |
operator bool () const ynothrow | |
判断有效性。 | |
FILE * | GetPtr () const ynothrow |
取文件指针。 | |
size_t | GetSize () const ynothrow |
取文件大小。 | |
ptrdiff_t | GetPosition () const ynothrow |
取文件指针的位置,返回值语义同 std::ftell 。 | |
int | Seek (ptrdiff_t offset, int whence) const |
设置文件指针位置。 | |
int | CheckEOF () const |
检测文件结束符。 | |
void | Close () |
关闭文件。 | |
int | Flush () const |
刷新流。 | |
size_t | Read (void *ptr, size_t size=1U, size_t nmemb=1U) const |
连续读 nmemb 个大小为 size 文件块到 ptr 中。 | |
void | Rewind () const |
文件指针返回到文件头,语义同 std::rewind 。 | |
virtual bool | Truncate (size_t) const |
截断文件。 | |
size_t | Write (void *ptr, size_t size=1U, size_t nmemb=1U) const |
连续写 nmemb 个大小为 size 文件块到 ptr 中。 | |
bool | Open (const_path_t, const char *="rb") |
以指定方式打开指定路径的文件。 | |
bool | Open (const_path_t, std::ios_base::openmode) |
bool | Open (const String &, const ucs2_t *=u"rb") |
bool | Open (const String &, std::ios_base::openmode) |
Private 成员函数 | |
void | CheckSize () |
检查文件有效长度后读位置返回文件起始。 | |
![]() | |
noncopyable (const noncopyable &)=delete | |
禁止复制构造。 | |
noncopyable & | operator= (const noncopyable &)=delete |
禁止赋值复制。 | |
noncopyable ()=default | |
protected 构造:默认实现。 | |
~noncopyable ()=default | |
protected 析构:默认实现。 | |
Private 属性 | |
std::FILE * | fp |
size_t | fsize |
文件大小。 | |
|
explicit |
构造:使用指定文件路径初始化对象。
YSLib::File::File | ( | const_path_t | , |
std::ios_base::openmode | |||
) |
|
explicit |
YSLib::File::File | ( | const String & | , |
std::ios_base::openmode | |||
) |
|
inline |
|
private |
void File::Close | ( | ) |
|
inline |
|
inline |
|
inline |
取文件指针。
参考自 YSLib::TextFile::GetBOM(),YSLib::Text::TextFileBuffer::GetIterator(),YSLib::Text::TextFileBuffer::GetPosition(),YSLib::operator<<(),YSLib::operator>>(),YSLib::Text::TextFileBuffer::operator[](),YSLib::TextFile::ReadChar(),Session::Session(),YSLib::TextFile::SkipChar() , 以及 Truncate().
|
inline |
bool YSLib::File::Open | ( | const_path_t | , |
const char * | = "rb" |
||
) |
以指定方式打开指定路径的文件。
std::fopen
。 openmode
,使用 ystdex::openmode_conv 转换。 bool YSLib::File::Open | ( | const_path_t | , |
std::ios_base::openmode | |||
) |
bool YSLib::File::Open | ( | const String & | , |
const ucs2_t * | = u"rb" |
||
) |
bool YSLib::File::Open | ( | const String & | , |
std::ios_base::openmode | |||
) |
|
inline |
连续读 nmemb
个大小为 size
文件块到 ptr
中。
std::fread
。 参考自 YSLib::TextFile::CheckBOM().
|
inline |
|
inline |
设置文件指针位置。
std::fseek
。 参考自 CheckSize(),YSLib::TextFile::Locate() , 以及 YSLib::TextFile::Rewind().
|
virtual |
截断文件。
被 YSLib::TextFile 重载.
参考 GetPtr() , 以及 platform::truncate().
参考自 YSLib::TextFile::Truncate().
|
inline |
|
private |