+ }
+ else if ( fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) //directory?
+ {
+ if ( GDCM_NAME_SPACE::Util::GetName(fileName)[0] != '.' && recursive ) //we also skip hidden files
+ {
+ numberOfFiles += Explore( fileName, recursive);
+ }
+ }
+ else
+ {
+ gdcmErrorMacro( "Unexpected error" );
+ return -1;
+ }
+ }
+ }
+
+ DWORD dwError = GetLastError();
+ if (hFile != INVALID_HANDLE_VALUE)
+ FindClose(hFile);
+ if (dwError != ERROR_NO_MORE_FILES)
+ {
+ LPVOID lpMsgBuf;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
+ FORMAT_MESSAGE_FROM_SYSTEM|
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,0,NULL);
+
+ gdcmErrorMacro("FindNextFile error. Error is " << (char *)lpMsgBuf
+ <<" for the directory : "<<dirName);
+ return -1;