Poco::Path 和 DirectoryIterator
#include<iostream>
#include<typeinfo>
#include<Poco/Path.h>
using namespace std;
using namespace Poco;
int main(){
Path my_path ("/media/ygy/KINGSTON");
Path path1 = my_path.absolute();
cout<< Path::current()<<endl;
cout <<my_path.depth()<<endl; for(int i=0;i<=path1.depth();i++){
cout<<my_path.directory(i)<<endl;
cout<<my_path[i]<<endl;
}
} root@goodjob:~/work/poco/path# ./test
root@goodjob:~/work/poco/path# ./test
/home/ygy/work/poco/path/
2
media
media
ygy
ygy
KINGSTON
KINGSTON
static std::string current(); Returns the current working directory.
int depth() const; Returns the number of directories in the directory list.
const std::string & directory(int n) const; Returns the n'th directory in the directory list. If n == depth(), returns the filename.
bool isDirectory() const;Returns true if and only if the path references a directory (the filename part is empty).
只有路径字符串末尾是/的时候,判断为真,其余都是假。
bool isFile() const; Returns true if and only if the path references a file (the filename part is not empty).
路径字符串末尾不是/的时候,为真。
Path & makeDirectory();
If the path contains a filename, the filename is appended to the directory list and cleared. Thus the resulting path always refers to a directory.
Path & makeFile();
If the path contains no filename, the last directory becomes the filename.
Path & makeParent();
Makes the path refer to its parent.
Path parent() const;
Returns a path referring to the path's directory.
std::string toString() const;
Returns a string containing the path in native format.
#include<iostream>
#include<typeinfo>
#include<Poco/Path.h>
#include <Poco/DirectoryIterator.h>
using namespace std;
using namespace Poco; int main(){
Path my_path ("/media/ygy/YGY");
cout<< Path::current()<<endl;
DirectoryIterator end;
DirectoryIterator it(my_path);
cout<<"-------"<<endl;
Path path2;
for(;it!=end;++it){
cout<<it.name()<<endl;
// path2 = it.path();
// cout<<path2.getFileName()<<endl;
}
} root@goodjob:~/work/poco/path# ./test
/home/ygy/work/poco/path/
-------
desaydata
$TXRAJNL.DAT
text
libTextData.so
update.zip
update.zip.md5
music
DS03H_Common.kzb
bin
lib
radio
libsvp_appfw.so
lns-pic
global-menu
picture
1
System Volume Information
svp.test.mediafw.plugin.native
动态规划
2叉树
排序
libControls.so
3.1.3
3.1.10.2
libPictureData.so
svp.svc.appmgr
svp.svc.media.indexing
new folder
libsvp_mediafw-plugin-native-db.so
lns-pic-0
lns-pic-1
lns-pic-2
genivi
Creates the end iterator.
DirectoryIterator( const std::string & path);
Creates a directory iterator for the given path.
const Path & path() const;
Returns the current path.
const std::string & name() const;
最新文章
- MI卡UID
- 如何用Eclipse进行单元测试
- YII 的基本CURL操作
- Eclipse 导入 Hadoop 源码
- Nexus Root Toolkit教程—— 解锁与Root
- javascript中对象的不同创建方法
- [转]How to create an anonymous IDA PRO database (.IDB)
- 在cmd模式下对mysql的操作语句
- 微信授权登录mock(在没有真实微信账号的情况下测试大量微信账户授权登录的情况)
- [模板]Min_25筛
- 打包maven后出现jar包丢失
- Java知多少(30)多态和动态绑定
- Android Studio 修改Logcat的颜色
- 团队作业Beta冲刺-第三天
- virtIO之VHOST工作原理简析
- 流媒体协议之JRTPLIB的使用20170919
- Java使用 VelocityEngine模板引擎快速生成HTML等各种代码
- vue-cli使用swiper4在ie以及safari报错
- ZOJ1937:Addition Chains——题解
- CodeFores 665D Simple Subset(贪心)