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 ...
随机推荐
- FU-A方式分包
当 NALU 的长度超过 MTU 时, 就必须对 NALU 单元进行分片封包. 也称为 Fragmentation Units (FUs). 0 1 2 3 0 1 2 3 4 5 6 7 8 9 ...
- JavaScript基本概念(1)-声明提升
声明提升: function > var > other var提升的时候,只是声明提升,但是赋值还是会在原来的位置. Javascript Hoisting:In javascript, ...
- Learning Spatial-Temporal Regularized Correlation Filters for Visual Tracking---随笔
Learning Spatial-Temporal Regularized Correlation Filters for Visual Tracking DCF跟踪算法因边界效应,鲁棒性较差.SRD ...
- APUE学习笔记3_文件IO
APUE学习笔记3_文件IO Unix中的文件IO函数主要包括以下几个:open().read().write().lseek().close()等.这类I/O函数也被称为不带缓冲的I/O,标准I/O ...
- sql随机数
) as P_jsnews_id ) as P_jsnews_id) * from P_jsnews order by newid()
- POJ 1741 Tree(树的分治)
Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Def ...
- VUE中组件的使用
关于vue组件引用 使用Nodejs的方法 被引用的组件要暴露 module.exports={}; 引用时 用 var abc= require("组件的路径") 然后 就可以用 ...
- 软件工程 part4 评价3作品
作品1 抢答器 地址: https://modao.cc/app/ylGTXobcMU7ePNi6tY53gG4iraLl0md评价: 挺好玩,但是字体大小是个缺陷,简单大方. 作品2:连连看 软件工 ...
- NIO初探
NIO的前世今生 NIO又叫NonBlockingI/O,即非阻塞I/O.以此对应的,有一个更常见的IO(BIO),又叫Blocking I/O,即阻塞IO,两种都为Java的IO实现方案. NIO/ ...
- 第三次寒假作业 sketch 了解
什么是sketch? sketch 是一种基于散列的数据结构,可以在高速网络环境中,实时地存储流量特征信息,只占用较小的空间资源,并且具备在理论上可证明的估计精度与内存的平衡特性. 通过设置散列函数, ...