wxWidgets文件操作-file operation
wxWidgets的文件类或者方法比较散,用的时候要查的资料比较多。所以这里整理相关的操作
1、得到一个文件的修改时间
#include "wx/filename.h"
wxDateTime wxFileName::GetModificationTime();
2、创建文件
wxFile::Create()
3、打开文件
wxFile::Read()
4、读文件
wxFile::Read()
5、文件夹操作
wxDir dir;
dir.GetFirst()
6、判断是不是文件夹
wxFileName::IsDir(),这个似乎是从文件名字来判断是不是文件夹,具体使用的时候要当心。
笔者最后还是用了各个平台的文件属性来做。
7、文件属性
wxFileName::IsDirWritable()
wxFileName::IsDirReadable()
wxFileName::IsFileWritable()
wxFileName::IsFileReadable()
wxFileName::IsFileExecutable()
8、
wxDir::mkDir()
9、
static void SplitPath (const wxString &fullpath, wxString *volume, wxString *path, wxString *name, wxString *ext, bool *hasExt=NULL, wxPathFormat format=wxPATH_NATIVE)
10、测试wxFileName是不是一个目录,没有直接的,但是这样可以用。
wxFileName fileName(path);
bool isFile = fileName.FileExists();
if (!isFile)
{
}
else
{
}
但这么用还是有bug,按照测试,wxFileName还是不够的。
11、判断文件是否存在
wxFile::Exists(const char* filename);
参考:
1、http://docs.wxwidgets.org/2.9.4/classwx_file_name.html#a6a1908a872b80060af5ef46cdda6c0c1
2、http://docs.wxwidgets.org/2.8/wx_wxfile.html#wxfilecreate
3、http://docs.wxwidgets.org/2.9.4/group__group__funcmacro__file.html
4、http://docs.wxwidgets.org/2.9.4/group__group__class__file.html
5、http://docs.wxwidgets.org/2.9.3/classwx_file_system.html
6、http://docs.wxwidgets.org/2.9.4/classwx_dir.html