RT,组合之前做的工作
#include <iostream>
#include <string>
#include <io.h>
#include <vector>
using namespace std;
bool getDirFilesPath( string folderPath, vector<string>& files);
string getChinese(string inputStr);
int main()
{
string path;
vector<string> files,chineseFiles;
cin >> path;
getDirFilesPath(path,files);
for (int i=0;i<files.size();i++)
{
//cout<<files.at(i)<<"\n";
chineseFiles.push_back( getChinese(files.at(i)) );
}
system("pause");
return 0;
}
//获得某文件夹下的所有文件的绝对路径
bool getDirFilesPath( string folderPath, vector<string>& files)
{
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
if((hFile = _findfirst(p.assign(folderPath).append("\\*").c_str(),&fileinfo)) != -1)
{
do
{
//如果是目录,继续
if((fileinfo.attrib & _A_SUBDIR))
{
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0)
{
//去掉父目录和当前目录
files.push_back( fileinfo.name );
}
}
else
{
files.push_back( fileinfo.name );
}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}else{
return false;
}
return true;
}
string getChinese(string inputStr)
{
string result;
for (int i=0;i<inputStr.size();i++)
{
if ( (int)(inputStr.at(i))<0 )
{
result.append(&inputStr.at(i),2);
i++;
}
}
return result;
}