[mapguide-commits] r8535 - in trunk/MgDev/Common: Foundation/Data Foundation/System MapGuideCommon/Resources

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Feb 5 14:36:16 PST 2015


Author: jng
Date: 2015-02-05 14:36:16 -0800 (Thu, 05 Feb 2015)
New Revision: 8535

Modified:
   trunk/MgDev/Common/Foundation/Data/ByteSink.cpp
   trunk/MgDev/Common/Foundation/System/ByteSourceFileImpl.cpp
   trunk/MgDev/Common/Foundation/System/FileUtil.cpp
   trunk/MgDev/Common/Foundation/System/StreamReader.cpp
   trunk/MgDev/Common/Foundation/System/Util.h
   trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
Log:
#2534: Include errno and its string description in cases where it is the cause of the MgFileIoException being thrown

Modified: trunk/MgDev/Common/Foundation/Data/ByteSink.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/Data/ByteSink.cpp	2015-02-05 11:46:41 UTC (rev 8534)
+++ trunk/MgDev/Common/Foundation/Data/ByteSink.cpp	2015-02-05 22:36:16 UTC (rev 8535)
@@ -202,16 +202,17 @@
         {
             MgStringCollection arguments;
             arguments.Add(filename);
-
             if (errno == EEXIST)
             {
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileNotFoundException(L"MgByteSink.ToFile",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
             }
             else
             {
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileIoException(L"MgByteSink.ToFile",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
             }
         }
 

Modified: trunk/MgDev/Common/Foundation/System/ByteSourceFileImpl.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/ByteSourceFileImpl.cpp	2015-02-05 11:46:41 UTC (rev 8534)
+++ trunk/MgDev/Common/Foundation/System/ByteSourceFileImpl.cpp	2015-02-05 22:36:16 UTC (rev 8535)
@@ -122,13 +122,15 @@
 
         if(errno == ENOENT)
         {
+            MG_FILE_IO_EXCEPTION_ADD_ERRNO();
             throw new MgFileNotFoundException(L"ByteSourceFileImpl.LoadFile",
-                __LINE__, __WFILE__, &arguments, L"", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
         }
         else
         {
+            MG_FILE_IO_EXCEPTION_ADD_ERRNO();
             throw new MgFileIoException(L"ByteSourceFileImpl.LoadFile",
-                __LINE__, __WFILE__, &arguments, L"", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
         }
     }
 

Modified: trunk/MgDev/Common/Foundation/System/FileUtil.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/FileUtil.cpp	2015-02-05 11:46:41 UTC (rev 8534)
+++ trunk/MgDev/Common/Foundation/System/FileUtil.cpp	2015-02-05 22:36:16 UTC (rev 8535)
@@ -449,8 +449,9 @@
             case ENOENT:
             case EACCES:
             default:
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileIoException(L"MgFileUtil.MkDir",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
                 break;
         }
     }
@@ -495,8 +496,9 @@
             case ENOTEMPTY:
             case EACCES:
             default:
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileIoException(L"MgFileUtil.DeleteDirectory",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
                 break;
         }
     }
@@ -789,8 +791,9 @@
             case ENOENT: // PathnameExists is more reliable. It gets called above, so this error should not be detected.
             case EACCES:
             default:
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileIoException(L"MgFileUtil.DeleteFile",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
                 break;
         }
     }
@@ -970,8 +973,9 @@
                          // different path.
             default:
                 arguments.Add(newPathname);
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileIoException(L"MgFileUtil.RenameFile",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
                 break;
         }
     }

Modified: trunk/MgDev/Common/Foundation/System/StreamReader.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/StreamReader.cpp	2015-02-05 11:46:41 UTC (rev 8534)
+++ trunk/MgDev/Common/Foundation/System/StreamReader.cpp	2015-02-05 22:36:16 UTC (rev 8535)
@@ -414,13 +414,15 @@
 
             if (errno == EEXIST)
             {
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileNotFoundException(L"MgStreamReader.GetStream",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
             }
             else
             {
+                MG_FILE_IO_EXCEPTION_ADD_ERRNO();
                 throw new MgFileIoException(L"MgStreamReader.GetStream",
-                    __LINE__, __WFILE__, &arguments, L"", NULL);
+                    __LINE__, __WFILE__, &arguments, L"MgFileIoErrNo", &errNoArgs);
             }
         }
     }

Modified: trunk/MgDev/Common/Foundation/System/Util.h
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.h	2015-02-05 11:46:41 UTC (rev 8534)
+++ trunk/MgDev/Common/Foundation/System/Util.h	2015-02-05 22:36:16 UTC (rev 8535)
@@ -638,6 +638,17 @@
         }                                                                     \
     }                                                                         \
 
+#define MG_FILE_IO_EXCEPTION_ADD_ERRNO()                  \
+    MgStringCollection errNoArgs;                         \
+    std::string mbErrNoDesc;                              \
+    mbErrNoDesc += ACE_OS::strerror(errno);               \
+    STRING wErrNoDesc;                                    \
+    MgUtil::MultiByteToWideChar(mbErrNoDesc, wErrNoDesc); \
+    STRING wErrNo;                                        \
+    MgUtil::Int32ToString(errno, wErrNo);                 \
+    errNoArgs.Add(wErrNo);                                \
+    errNoArgs.Add(wErrNoDesc)
+
 #ifdef _WIN32
 #define MG_TCHAR_TO_WCHAR(x) ((wstring)x).c_str()
 #define MG_TCHAR_TO_CHAR(x) MgUtil::WideCharToMultiByte((wstring)x).c_str()

Modified: trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2015-02-05 11:46:41 UTC (rev 8534)
+++ trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2015-02-05 22:36:16 UTC (rev 8535)
@@ -235,6 +235,7 @@
 MgFeatureSourceFormatInnerExceptionMessage            = Error occurred in Feature Source (%1): %2 (Cause: %3, Root Cause: %4)
 MgFeatureReaderIdNotFound                             = The feature reader ID was not found.
 MgFilenamesIdentical                                  = The filenames cannot be the same.
+MgFileIoErrNo                                         = errno: %1 (%2)
 MgFormatAllExceptionDetail                            = - %1(%2)
 MgFormatAllExceptionStackTrace                        = - %1(%2) line %3 file %4
 MgFormatFdoExceptionMessage                           = %1 (Cause: %2, Root Cause: %3)



More information about the mapguide-commits mailing list