【文件属性】:
文件名称:层次路径递归创建文件实例
文件大小:20KB
文件格式:CPP
更新时间:2016-01-19 04:30:17
层次路径 递归创建 删除路径 路径有效检测 上一层路径
//
// FilePath.h
//
/** \file FilePath.h */
#pragma once
#include "vtString.h"
#include
#include
/**
* A portable class for reading directory contents.
*
* Example of use:
\code
for (dir_iter it("C:/temp"); it != dir_iter(); ++it)
{
if (it.is_hidden())
continue;
if (it.is_directory())
printf("Directory: '%s'\n", it.filename().c_str());
else
printf("File: '%s'\n", it.filename().c_str());
}
\endcode
*/
class dir_iter
{
public:
dir_iter();
dir_iter(const char*dirname);
dir_iter(const wchar_t*dirname);
~dir_iter();
/// Returns true if the current object is a directory.
bool is_directory();
/// Returns true if the current object is hidden.
bool is_hidden();
/// Get the filename fo the current object.
std::string filename();
std::wstring wfilename();
// Iterate the object to the next file/directory.
void operator++();
// Test for inequality useful to test when iteration is finished.
bool operator!=(const dir_iter ⁢);
long m_handle;
private:
struct _wfinddata_t m_data;
};
//MBCS string 或者 Wide string
vtString vtFindFileOnPaths(const vtStringArray &paths;, const char *filename);
vtString2 vtFindFileOnPaths(const vtStringArray2 &paths;, const wchar_t *filename);
bool vtCreateDir(const char *dirname);
bool vtCreateDir(const wchar_t *dirname);
void vtDestroyDir(const char *dirname);
void vtDestroyDir(const wchar_t *dirname);
int vtDeleteFile(const char *filename);
int vtDeleteFile(const wchar_t *filename);
const char *vtStartOfFileName(const char *szFullPath);
const wchar_t *vtStartOfFileName(const wchar_t *szFullPath);
vtString vtExtractPath(const char *szFullPath, bool bTrailingSlash);
vtString2 vtExtractPath(const wchar_t *szFullPath, bool bTrailingSlash);
bool vtPathIsAbsolute(const char *szPath);
bool vtPathIsAbsolute(const wchar_t *szPath);
vtString vtPathLevelUp(const char *src);
vtString2 vtPathLevelUp(const wchar_t *src);
vtString get_line_from_stream(std::ifstream &input;);
vtString2 get_line_from_stream(std::wifstream &input;);
//bFull为ture包括所有扩展名;否则最后一个扩展名
void vtRemoveFileExtensions(vtString& fname,bool bFull = false);
void vtRemoveFileExtensions(vtString2& fname,bool bFull = false);
//bFull为ture包括所有扩展名;否则最后一个扩展名
vtString vtGetExtensions(const vtString &fname;, bool bFull = false);
vtString2 vtGetExtensions(const vtString2 &fname;, bool bFull = false);
bool vtChangeFileExtension(vtString& input, const char *extension);
bool vtChangeFileExtension(vtString2& input, const wchar_t *extension);
bool vtFileExists(const char *fname);
bool vtFileExists(const wchar_t *fname);
#pragma comment(lib, "shell32.lib")
bool vtCopyFile( const char* from,const char * to, bool bFailIfExists=true);
bool vtCopyFile( const wchar_t* from,const wchar_t * to, bool bFailIfExists=true);
bool vtCopyTree(const char* from,const char * to);
bool vtCopyTree(const wchar_t* from,const wchar_t * to);
bool vtFolderExists(const char *fname);
bool vtFolderExists(const wchar_t *fname);
bool vtFilePathExists(const char *fname);
bool vtFilePathExists(const wchar_t *fname);
int vtGetFileSize(const char *fname);
int vtGetFileSize(const wchar_t *fname);
void vtSetEnvironmentVar(const char* var, const char*value);
void vtSetEnvironmentVar(const wchar_t* var, const wchar_t*value);
#include "windows.h"
bool vtGetModuleFullPath(const char* modulename,vtString& fullpath);
bool vtGetModuleFullPath(const wchar_t* modulename,vtString2& fullpath);
/////////////////////////////////////////////
// Open a file using a UTF-8 or wide character filename.
FILE *vtFileOpen(const char *fname_mbcs, const char *mode);
FILE *vtFileOpen(const wchar_t *fname_wide, const wchar_t *mode);
vtString vtChooseFolder(HWND hWnd =NULL);
vtString2 vtChooseFolder2(HWND hWnd=NULL);