받기 : 상대 디렉토리 ./test/*
에 각 파일의 이름을 인쇄WIN32_FIND_DATA -이 같은 것을 사용하고 절대 경로
std::string tempDirectory = "./test/*";
WIN32_FIND_DATA directoryHandle;
memset(&directoryHandle, 0, sizeof(WIN32_FIND_DATA));//perhaps redundant???
std::wstring wideString = std::wstring(tempDirectory.begin(), tempDirectory.end());
LPCWSTR directoryPath = wideString.c_str();
//iterate over all files
HANDLE handle = FindFirstFile(directoryPath, &directoryHandle);
while(INVALID_HANDLE_VALUE != handle)
{
//skip non-files
if (!(directoryHandle.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
//convert from WCHAR to std::string
size_t size = wcslen(directoryHandle.cFileName);
char * buffer = new char [2 * size + 2];
wcstombs(buffer, directoryHandle.cFileName, 2 * size + 2);
std::string file(buffer);
delete [] buffer;
std::cout << file;
}
if(FALSE == FindNextFile(handle, &directoryHandle)) break;
}
//close the handle
FindClose(handle);
합니다.
realpath()
과 같이 BOOST와 같은 타사 라이브러리를 사용하지 않고이 디렉토리의 절대 경로를 확인할 방법이 있습니까? 각 파일의 절대 경로를 인쇄하고 싶습니다.
[UNC] (http://en.wikipedia.org/wiki/Uniform_Naming_Convention#Uniform_Naming_Convention) 경로를 요청합니까? –
나는 그런 일반적인 해결책이 필요하다고 생각하지 않는다. 로컬 경로는 C : \ bla \ blabla \ etc와 같이 지금은 정상적으로 수행되어야합니다. –
로컬 경로가 있다는 보장이 없습니다. –