Poco::File

基于入门的环境及makefile。

#include<iostream>
#include<Poco/File.h>

using namespace std;
using namespace Poco;
int main(){
    File *myfile = new File("/home/ygy/work/poco/file/b.txt");

    myfile->createFile();

    cout<<"canRead():"<<myfile->canRead()<<endl;
    cout<<"canWrite():"<<myfile->canWrite()<<endl;
    myfile->copyTo("/home/ygy/work/poco/file/bin");

    cout<<"end"<<endl;
}

void copyTo(const std::string & path)const; 将该文件复制到某个目录,将文件内容复制到指定文件。

void createDirectories();   创建所有的目录,即使目录的父目录不存在

bool createDirectory();   在已存在的目录下创建目录。

  Returns true if the directory has been created and false if it already exists

bool createFile(); 创建空文件

  Returns true if the file has been created and false if the file already exists

Timestamp created() const;  这个返回类型还不知道怎么显示时间。

  Returns the creation date of the file.

bool exists() const;

Timestamp getLastModified() const;  上次修改时间

FileSize getSize() const;  返回文件字节数,目录是4096

bool isDevice() const;

  Returns true if and only if the file is a device.

bool isDirectory() const;

   Returns true if and only if the file is a directory.

bool isFile() const;

  Returns true if and only if the file is a regular file.

bool isHidden() const;

bool isLink() const;

  Returns true if and only if the file is a symbolic link

void moveTo( const std::string & path);

void list( std::vector < File > & files) const;    获得所有的File对象

void list( std::vector < std::string > & files) const;  获得所有的name

#include<iostream>
#include<Poco/File.h>

using namespace std;
using namespace Poco;
int main(){
    File *myfile1 = new File("/home/ygy/work/poco/file");
    vector<string>files;
    vector<File>Files;
    myfile1->list(files);
    myfile1->list(Files);
    cout<<Files.size()<<endl;
    for(auto file:files ){
        cout<<file<<endl;
    }
}

 6
main.cpp
bin
a.txt
main.o
Makefile
ddddd

原文链接: https://www.cnblogs.com/yuguangyuan/p/6743604.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    Poco::File

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/397830

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年4月11日 上午9:47
下一篇 2023年4月11日 上午9:47

相关推荐