Poco::File

基於入門的環境及makefile。ios

#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; 將該文件複製到某個目錄,將文件內容複製到指定文件。spa

void createDirectories();   建立全部的目錄,即便目錄的父目錄不存在code

bool createDirectory();   在已存在的目錄下建立目錄。對象

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

bool createFile(); 建立空文件get

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

Timestamp created() const;  這個返回類型還不知道怎麼顯示時間。it

  Returns the creation date of the file.io

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;
    }
}

 6main.cppbina.txtmain.oMakefileddddd

本站公眾號
   歡迎關注本站公眾號,獲取更多信息