배경 정보에 dirent.h를에 mbstowcs 함수에서 :"retsize <= sizeInWords"윈도우
내가 VS2013에 dirent.h를 (프로젝트 요구 사항)를 사용하여 창에서 파일 트리를 짓고 있어요. 나는 here에서 dirent.h를 얻었습니다. I 디버그 주장과 런타임에 충돌이 CRT에서 ("retsize < = sizeInWords")를 실패 \ crtw32 \ mbstowcs.c, 라인 283
이 dirent.h를 테스트하려면, 내가 사용했다
void printDir(std::string dir, std::string tab)
{
DIR* d = opendir(dir.c_str());
dirent* ent = nullptr;
while (ent = readdir(d)) {
if (ent->d_name[0] != '.') {
std::cout << tab << ent->d_name << std::endl;
if (ent->d_type == DT_DIR) {
printDir(dir + "/" + ent->d_name, tab + " ");
}
}
}
}
("."printDir (로 메인에서 호출, ""))
그래서 내 트리를 구축하기 위해 내가 가진 :
struct Dirf {
std::string getFullPath() {
if (out) {
return out->getFullPath() + "/" + ent.d_name;
}
else return ent.d_name;
}
Dirf(DIR* dir, Dirf* parent = nullptr)
: out(parent)
{
if (dir) {
dirent* d = readdir(dir);
if (d) {
ent = *d;
if (dir) {
next = std::make_shared<Dirf>(dir, parent);
}
if (ent.d_type == DT_DIR) {
DIR* inDir = opendir(getFullPath().c_str());
in = std::make_shared<Dirf>(inDir, this);
closedir(inDir);
}
}
}
}
private:
typedef std::shared_ptr<Dirf> point;
friend std::string to_string(Dirf, std::string);
dirent ent;
Dirf* out; // parent to this; in->out == this, out->in == this;
point in, // in != null iff car.d_type == DT_DIR
next; // next entry in the dir
};
std::string to_string(Dirf, std::string tab = "");
을하지만, ((했던 opendir Dirf를 호출은 ".")) 디버그 실패 주장 주장 d 위