]> Creatis software - gdcm.git/commitdiff
* Improve the error message
authorregrain <regrain>
Tue, 13 Dec 2005 13:37:50 +0000 (13:37 +0000)
committerregrain <regrain>
Tue, 13 Dec 2005 13:37:50 +0000 (13:37 +0000)
   -- BeNours

src/gdcmDirList.cxx

index caa8d7d52152ec2aa857ba188b9e7be55715d1a3..c0a9feda473503536eadf2ae8fc2bde204dae925 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 17:21:34 $
-  Version:   $Revision: 1.56 $
+  Date:      $Date: 2005/12/13 13:37:50 $
+  Version:   $Revision: 1.57 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -122,10 +122,20 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
       }
    }
    DWORD dwError = GetLastError();
-   if (hFile != INVALID_HANDLE_VALUE) FindClose(hFile);
+   if (hFile != INVALID_HANDLE_VALUE) 
+      FindClose(hFile);
    if (dwError != ERROR_NO_MORE_FILES) 
    {
-      gdcmErrorMacro("FindNextFile error. Error is " << dwError);
+      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;
    }