C++ 文件系统操作 File System Operation
2013-05-20 11:54
302 查看
Create Directory
Using Windows api, include <windows.h>if (0 == ::CreateDirectoryA(_root.c_str(), nullptr)) { DWORD errcode = ::GetLastError(); if (errcode == ERROR_ALREADY_EXISTS) { return 0; } throw ISATGrabberException(CUtility::GetSysErrInfomation(errcode), errcode, __FILE__, __FUNCTION__, __LINE__); }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Using C api in windows, include <direct.h>
int ret = _mkdir(_root.c_str()); if (ret != 0 && errno == ENOENT) { printf("%s, %d", strerror(errno), errno); return ret; }
Check Direcotry exist
Using Windows apiUsing C api in windows, include <sys/stat.h> and <sys/types.h>
struct _stat buf; int ret = _stat(_root.c_str(), &buf); CPPUNIT_ASSERT(0 == ret); CPPUNIT_ASSERT((buf.st_mode & _S_IFDIR) > 0);
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Using boost library
ASSERT(boost::filesystem::status(_root).type() == boost::filesystem::directory_file);
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Remove Directory
Using Windows API
Using C api in windows, include <direct.h>
_rmdir(dir.c_str());
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Using boost library
相关文章推荐
- nodejs File System 文件系统操作函数分类
- JavaScript-网页客户端系统文件操作-FileSystemObject 对象
- 监控文件服务器上操作的利器--File System Auditor配置全解
- linux kernel文件系统数据结构file_system_type
- File System Object 文件系统
- HTML5 本地文件操作之FileSystemAPI整理(一)
- FileSystemObject,ADODB.Stream 能否操作UTF-8格式的文件
- C# System.IO.Directory、System.IO.File文件操作
- HTML5之本地文件系统API - File System API
- C/C++学习笔记27:(二)C文件系统操作
- The Synchronous FileSystem API for Workers-工作者的同步文件系统应用程序接口
- 【2016/1】文件操作 file_IO 系统调用与库函数
- 用JavaScript封装下FileSystemObject,做下文件操作!
- 文件系统不同步问题resource is out of sync with the file system的解决办法
- 【已解决】Windows Service 问题System.IO.FileNotFoundException: 未能加载文件或程序集“file:///”或它 的某一个依赖项。系统找不到指定的文件。。
- adb remount 系统提示只读文件系统Read-only file system
- Oracle Application File System(应用文件系统)
- C++ Boost filesystem 路径操作
- Linux Filesystem: 解析 Linux 中的 VFS 文件系统机制
- Scripting.FileSystemObject 文件操作