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;
Poco::Path 和 DirectoryIterator的更多相关文章
- Poco::URI
#include<iostream> #include<typeinfo> #include<Poco/Path.h> #include <Poco/Dire ...
- POCO文档翻译:POCO C++库入门指南
内容目录 介绍 Foundation库 XML库 Util库 Net库 将这些东西组合到一起 介绍 POCO C++库是一组开源C++类库的集合,它们简化及加速了用C++来开发以网络功能为核心的可移植 ...
- Poco库网络模块例子解析1-------字典查询
Poco的网络模块在Poco::Net名字空间下定义 下面是字典例子解析 #include "Poco/Net/StreamSocket.h" //流式套接字 #include ...
- resque 遍历加载job目录下的类
<?php class resqueTest { public function actionWork() { #require dirname(__DIR__).'/commands/Test ...
- Clickhouse v18编译记录
简介 ClickHouse是"战斗民族"俄罗斯搜索巨头Yandex公司开源的一个极具"战斗力"的实时数据分析数据库,是面向 OLAP 的分布式列式DBMS,圈内 ...
- The Shortest Path in Nya Graph
Problem Description This is a very easy problem, your task is just calculate el camino mas corto en ...
- Poco之ftp目录切换与创建
TEMPLATE = app QT += qml quick widgets#LIBS += -lPocoFoundation -lPocoXML -lPocoNetSOURCES += main.c ...
- [poco] HttpRequest之post方法
转自 http://www.cnblogs.com/yuanxiaoping_21cn_com/archive/2012/06/10/2544032.html #import <iostream ...
- POCO C++ lib开发环境构建
Welcome Thank you for downloading the POCO C++ Libraries and welcome to the growing community of POC ...
随机推荐
- linux服务器操作小技巧
python程序后台一直运行,并将打印信息输出到文件中 nohup -u test.py > out.txt & -u 表示无缓冲,直接将打印信息输出带文件中 &表示程序后台运行
- 小程序之web-view打开外部链接
小程序之web-view - 传送门 web-view 组件是一个可以用来承载网页的容器,会自动铺满整个小程序页面.个人类型与海外类型的小程序暂不支持使用. 一:小程序使用web-view打开链接的前 ...
- 《安装ubuntu及VMware以及相关问题汇总》
一.VMware Ubuntu安装详细过程 http://blog.csdn.net/u013142781/article/details/50529030 二.VMware Tools (ubunt ...
- 条款03 尽可能使用const
一.概述 使用const约束对象:可以获得编译器的帮助(指出相关出错的地方) const与成员函数:const重载.转型.避免代码重复 二.细节 1. 为什么有些函数要返回const对象(看上去没必要 ...
- 2017-2018-2 20172323 『Java程序设计』课程 结对编程练习_四则运算 2
相关过程截图 关键代码解释 将运算式分开的代码 String[] result = num.split("\\s"); 将输入的num以空格为间隔符号分开,将每一个间隔开的字符存入 ...
- Linux GCC编译
.a 静态库(打包文件 由多个.o文件打包而成) .c 未经过预处理的C源码 .h C头文件 .i 经过预处理的C源码(将头文件内容加载到c文件中) .o 编译之后产生的目标文件 .s 生成的汇编语言 ...
- 让我们一起来做最漂亮的Android界面吧!
让我们一起来做最漂亮的Android界面吧! AndroidiOS产品设计 摘要:如何为Android设备量身定制以打造出最为完美的应用?这是让诸多开发者很是头疼的问题.不同于iOS,Android设 ...
- C++课堂作业2016.05.04
GitHub/object-oriented 作业题目 开课后的第一次作业,简单地写了一个类,用成员函数来实现计算圆的面积. [代码] main.cpp #include "Area.h&q ...
- 关于GenericJDBCException的问题
在spring和hibernate整合的初步阶段,还没有编辑hibernate.cfg.xml这个文件,只有一个beans.xml文件.此时遇到了一个bug. Exception in thread ...
- scrapy(1)——scrapy介绍
Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中.所谓网络爬虫,就是一个在网上到处或定向抓取数据的程序,当然,这种说 ...