-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathread.cpp
More file actions
50 lines (50 loc) · 988 Bytes
/
read.cpp
File metadata and controls
50 lines (50 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <io.h>
#include <direct.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <vector>
#include <conio.h>
using namespace std;
void getJustCurrentFile( string path, vector<string>& files)
{
//Îļþ¾ä±ú
long hFile = 0;
//ÎļþÐÅÏ¢
struct _finddata_t fileinfo;
string p;
if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1)
{
do
{
if((fileinfo.attrib & _A_SUBDIR))
{
;
}
else
{
files.push_back(fileinfo.name);
}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
int main()
{
char buffer[MAX_PATH];
getcwd(buffer, MAX_PATH);
char * filePath = buffer;
vector<string> files;
char * distAll = "ALL.txt";
getJustCurrentFile(filePath, files);
ofstream ofn(distAll);
int size = files.size();
ofn<<size<<endl;
for (int i = 0;i<size;i++)
{
ofn<<files[i]<<endl;
}
ofn.close();
getch();
}