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 ...
随机推荐
- APP上下左右滑动屏幕的处理
#获得机器屏幕大小x,y driver = self.driver def getSize(): x = driver.get_window_size()['width'] y = driver.ge ...
- Selenium(Python)页面对象+数据驱动测试框架
整个工程的目录结构: 常用方法类: class SeleniumMethod(object): # 封装Selenium常用方法 def __init__(self, driver): self.dr ...
- jdk从1.8换成1.7后,查看版本还是1.8解决方法
因学习需要,需将jdk从1.8更改到1.7,其中遇到了些小麻烦,如果你也遇到这种麻烦,可以借鉴一下我的解决方法. 1.jdk的安装及环境变量的配置,详见https://jingyan.baidu.co ...
- [CF106C]Buns
面包师Lavrenty打算用馅料做几个面包,然后把它们卖掉. Lavrenty有\(n\)克面团和\(m\)种不同的馅料.馅料种类的下标从\(1到m\),他知道他的第\(i\)种馅料剩下\(a_i\) ...
- Nginx与Ribbon的区别
服务器端负载均衡 Nginx Nginx 基于C语言,快速,性能高5w/s. Redis 5w/s,RibbatMQ 1.2w/s ApacheActiveMQ 0.6w/s 业务系统,kafka 2 ...
- [Clr via C#读书笔记]Cp4类型基础
Cp4类型基础 Object类型 Object是所有类型的基类,有Equals,GetHashCode,ToString,GetType四个公共方法,其中GetHashCode,ToString可以o ...
- ajax的$.get()方法和tomcat服务器的交互
AJAX AJAX = 异步 JavaScript 和 XML. AJAX 是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术. Ajax get()方法 定义和用法 $.get() 方法 ...
- [转载]Java集合框架的常见面试题
http://www.jfox.info/40-ge-java-ji-he-lei-mian-shi-ti-he-da-an 整理自上面链接: Java集合框架为Java编程语言的基础,也是Java面 ...
- Python3 Tkinter-Spinbox
1.创建 from tkinter import * root=Tk() Spinbox(root).pack() root.mainloop() 2.参数 from_ 最小值 to 最大 ...
- ffmpeg接收rtsp流问题
项目使用mingw环境g++5.3,C++调用ffmpeg接收rtsp流,再通过C#显示.结构上是C#调用C++的so文件,读取得到的视频帧(RGB888格式),通过图片控件显示. 一开始是使用ope ...