漪綿 清烛
b3f90d1023
|
5 years ago | |
---|---|---|
.. | ||
README.md | 5 years ago |
README.md
Class ovo::file
file.get_files_info() [windows only]
Use this function to get information of files.
Params
- string path The path to search (Necessary)
- string format The file format to search e.g.
*.png
(Default: '*') - int isSearchSubfolders Is the subfolders be searched. (Default: 0)
file.num()
- Use this function to get the number of found files in
file.get_file_info()
.
How to get files infomaition?
- file.file[].name The file name.
- file.file[].path The file path.
- file.file[].size The file size in byte.
- file.file[].attrib The file attribute in int.
- file.file[].time_create The file created time in time stamp.
- file.file[].time_access The file last accessed time.
- file.file[].time_write The file last writen time.
Example
#include <iostream>
#include "ovo.h"
int main()
{
ovo::file f;
f.get_files_info(".\\");
for(int i = 0; i < f.num(); i++)
std::cout << "FileName: " << f.file[i].name << endl;
return 0;
}
This will show all the files in current position. Such as:
FileName: README.md
FileName: LICENSE
Advanced Example
#include <iostream>
#include <time.h>
#include "ovo.h"
int main()
{
ovo::file f;
f.get_files_info(".\\","*.md",1);//In Windows
for(int i = 0; i < f.num(); i++){
std::cout << "FileName: " << f.file[i].name << endl;
std::cout << "FileName: " << f.file[i].path << endl;
std::cout << "Size: " << f.file[i].size << endl;
std::cout << "Attribute: " << f.file[i].attrib << endl;
std::cout << "Create Time: " << ctime(&f.file[i].time_create);
std::cout << "Last Access Time: " << ctime(&f.file[i].time_access);
std::cout << "Last Write Time: " << ctime(&f.file[i].time_write) << endl;
}
return 0;
}
This will show all the .md files with a path in current and all subfolders.
FileName: README.md
Path: .\README.md
Size: 28
Attribute: 32
Create Time: Sat Mar 02 16:35:26 2019
Last Access Time: Sat Mar 02 16:35:26 2019
Last Write Time: Sat Mar 02 16:35:26 2019
FileName: README.md
Path: .\docs\ovo_file\README.md
Size: 2578
Attribute: 32
Create Time: Sat Mar 02 23:50:44 2019
Last Access Time: Tue Mar 05 11:40:18 2019
Last Write Time: Tue Mar 05 11:40:18 2019
FileName: README.md
Path: .\docs\ovo_info\README.md
Size: 1211
Attribute: 32
Create Time: Sat Mar 02 17:55:06 2019
Last Access Time: Tue Mar 05 11:40:18 2019
Last Write Time: Tue Mar 05 11:40:18 2019FileName: README.md
Path: .\docs\ovo_math\README.md
Size: 2603
Attribute: 32
Create Time: Sun Mar 03 20:09:49 2019
Last Access Time: Mon Mar 04 21:38:31 2019
Last Write Time: Mon Mar 04 21:38:31 2019FileName: README.md
Path: .\docs\ovo_string\README.md
Size: 2067
Attribute: 32
Create Time: Sat Mar 02 18:14:52 2019
Last Access Time: Mon Mar 04 19:12:56 2019
Last Write Time: Mon Mar 04 19:12:56 2019FileName: README.md
Path: .\docs\ovo_Timer\README.md
Size: 2268
Attribute: 32
Create Time: Mon Mar 04 21:37:45 2019
Last Access Time: Mon Mar 04 22:11:50 2019
Last Write Time: Mon Mar 04 22:11:50 2019