#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. artDialog使用说明(弹窗API)

    Js代码 2. 传入HTMLElement    备注:1.元素不是复制而是完整移动到对话框中,所以原有的事件与属性都将会保留 2.如果隐藏元素被传入到对话框,会设置display:block属性显示 ...

  2. JSP页面无法使用EL导致"java.sql.SQLException: No suitable driver found for ${snapshot}"的问题

    使用JSTL来连接mysql,这个问题折腾了半天,老以为是Mysql驱动的问题,还好最后偶然发现了是EL表达式识别不了,报错: javax.servlet.ServletException: java ...

  3. python常用命令—查看模块所在位置

    环境:ipython3 交互式解释器 语法: import 模块名 模块名.__file__ 功能: 查看模块的所在位置 例:

  4. 文本分类-TextCNN

    简介 TextCNN模型是由 Yoon Kim提出的Convolutional Naural Networks for Sentence Classification一文中提出的使用卷积神经网络来处理 ...

  5. py3.6+anaconda下安装opencv3

    py3.6+anaconda下安装opencv3 首先声明-网上的方法大多数都是有毒的.也不知道给的什么鬼方法都不行. 我说下我的方法.去这个网站https://pypi.tuna.tsinghua. ...

  6. selenium识别登录验证码---基于python实现

    本文主要是通过PIL+pytesseract+Tesseract-OCR实现验证码的识别 其中PIL为Python Imaging Library,已经是Python平台事实上的图像处理标准库了.PI ...

  7. str和repr

    在Python2.6和Python3.0以及更早的版本中,在交互式模式下的输出本质上是使用repr,因此对于一些浮点数运算,会显示很多位: 4 / 5.0 #0.8000000000000004 但是 ...

  8. 关于char, wchar_t, TCHAR, _T(),L,宏 _T、TEXT,_TEXT、L

    char :单字节变量类型,最多表示256个字符, wchar_t :宽字节变量类型,用于表示Unicode字符, 它实际定义在<string.h>里:typedef unsigned s ...

  9. IOS开发NSBundle使用

    bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBu ...

  10. ZigBee设备入网流程之关联方式

    ZigBee设备入网流程 ZigBee设备入网有关联方式和直接方式两种,我所熟悉的是关联方式,这也是最常用的方式. 关联方式 step1 设备发出Beacon Request 设备会在预先设置的几个信 ...