基本的に、私がやろうとしているのは、ファイルの最終アクセス時刻を確認し、それを文字列と比較することです。関連するブロックは次のとおりです。
struct stat file;
char timeStr[ 100 ];
stat(nodes.at(0), &file);
strftime(timeStr, 100, "%H:%M:%S-%m/%d/%y", localtime(&file.st_atime)); /* problem */
nodes
ファイルパスのベクトルです。関連性があるかどうかはわかりませんが、設定に使用しているコードを含めますnodes
。
vector<char*> nodes;
DIR *dir;
struct dirent *cur
if((dir = opendir(searchPath.c_str())) == NULL) {
cout << "Error opening search path. Are you sure '"
<< searchPath.c_str() << "' is a valid search path?" << endl;
return 0;
}
while((cur = readdir(dir)) != NULL) {
if(string(cur->d_name) == "." || string(cur->d_name) == "..") continue;
nodes.push_back(cur->d_name);
}
closedir(dir);
searchPath
ユーザーが入力した文字列はどこにありますか。
問題:「問題」行が実行されると、そこからnodes
ゴミのベクトルが発生します。nodes
ゴミにならずにこの仕事ができるのかしら。
これは宿題であり、おそらくC ++に慣れていないことがわかるように、正しい方向への確実なプッシュには「受け入れ」が与えられます。
ありがとうございました。