#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

DirectoryIterator();

  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;

  Returns the current filename.

const File & operator * () const;

const File * operator-> () const;

    cout<<(*it).canRead()<<endl;
cout<< it->canRead()<<endl;

Poco::Path 和 DirectoryIterator的更多相关文章

  1. Poco::URI

    #include<iostream> #include<typeinfo> #include<Poco/Path.h> #include <Poco/Dire ...

  2. POCO文档翻译:POCO C++库入门指南

    内容目录 介绍 Foundation库 XML库 Util库 Net库 将这些东西组合到一起 介绍 POCO C++库是一组开源C++类库的集合,它们简化及加速了用C++来开发以网络功能为核心的可移植 ...

  3. Poco库网络模块例子解析1-------字典查询

    Poco的网络模块在Poco::Net名字空间下定义   下面是字典例子解析 #include "Poco/Net/StreamSocket.h" //流式套接字 #include ...

  4. resque 遍历加载job目录下的类

    <?php class resqueTest { public function actionWork() { #require dirname(__DIR__).'/commands/Test ...

  5. Clickhouse v18编译记录

    简介 ClickHouse是"战斗民族"俄罗斯搜索巨头Yandex公司开源的一个极具"战斗力"的实时数据分析数据库,是面向 OLAP 的分布式列式DBMS,圈内 ...

  6. The Shortest Path in Nya Graph

    Problem Description This is a very easy problem, your task is just calculate el camino mas corto en ...

  7. Poco之ftp目录切换与创建

    TEMPLATE = app QT += qml quick widgets#LIBS += -lPocoFoundation -lPocoXML -lPocoNetSOURCES += main.c ...

  8. [poco] HttpRequest之post方法

    转自 http://www.cnblogs.com/yuanxiaoping_21cn_com/archive/2012/06/10/2544032.html #import <iostream ...

  9. POCO C++ lib开发环境构建

    Welcome Thank you for downloading the POCO C++ Libraries and welcome to the growing community of POC ...

随机推荐

  1. lesson 17 The longest suspension bridge in the world

    lesson 17 The longest suspension bridge in the world agreeable adj. 令人愉快的:适合的 = pleasant be located ...

  2. 【shell 练习5】编写简单的多级菜单

    一.简单的多级菜单 [root@web129 ~]# cat menu.sh #!/bin/bash #shell菜单演示 function menu() { echo -e `date` cat & ...

  3. 特殊符号 & 以太坊

    &表示取二进制的末尾 &1表示如果末尾是奇数和偶数两种情况 0 偶数 1奇数 举例子: int a=1;int p=&a; 其中,p是指针,&a就是将a在内存中的实际地 ...

  4. 嵌入式码农的10年Bug调试经验,值得一看

    下面这些都是我经历过的会导致难点bug的问题: 1.事件顺序.在处理事件时,提出下列问题会很有成效:事件可以以不同的顺序到达吗?如果我们没有接收到此事件会怎么样?如果此事件接连发生两次会怎么样?哪怕通 ...

  5. Python中变量名里面的下划线

    1 变量名前后都有两个下划线(__X__),表示是系统级变量: 2 变量名前只有一个下划线(_X),表示该变量不是由from module import *导入进来的: 3 变量名前有两个下划线(__ ...

  6. js中斜杠转义

    js中“/”不需要转义. if(myPath.indexOf("/Upload/EmailFile/")!=-1){ alert("有附件!")}

  7. LintCode-73.前序遍历和中序遍历树构造二叉树

    前序遍历和中序遍历树构造二叉树 根据前序遍历和中序遍历树构造二叉树. 注意事项 你可以假设树中不存在相同数值的节点 样例 给出中序遍历:[1,2,3]和前序遍历:[2,1,3]. 返回如下的树:    ...

  8. RXSwift --UITableView之初探

    对于RXSwift中的一些基本概念和说明请参看其他文章,接下来我们使用RXSwift一步一步去构建TableView,从简单到复杂.iOS开发过程中tableView的使用率是最高的,他的一些代理方法 ...

  9. Java设计

    重构前 CustomDataChar | getConnection()findCustomers()createChar()displayChar() 重构后 CustomDataChar | da ...

  10. bootstrap 有些控件需要调用锚点,会与angular 路由 冲突

    最简单的方法 就是 在 #号前加/, 但有人说 在服务器上回失效,也不知道是什么原理.慎用 最靠谱的方法 就 是 使用bootstrap中的js控制控件, 比如轮播图的上一页 下一页,就可以在 ang ...