[mapguide-commits] r7258 - in trunk/MgDev: Common/Foundation/System Server/src/Common/Manager Server/src/Services/Tile Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Dec 11 19:15:06 PST 2012


Author: hubu
Date: 2012-12-11 19:15:05 -0800 (Tue, 11 Dec 2012)
New Revision: 7258

Modified:
   trunk/MgDev/Common/Foundation/System/FileUtil.cpp
   trunk/MgDev/Common/Foundation/System/FileUtil.h
   trunk/MgDev/Server/src/Common/Manager/LogManager.cpp
   trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp
   trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.cpp
   trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.h
Log:
Submit on behalf of Andy Zhang
Integrate 7253 to trunk.

Fix ticket #2195 http://trac.osgeo.org/mapguide/ticket/2195

The behavior of system call _wstat in VC9 and VC10 is different when handling file which size is bigger than 2^31. In VC9, it returns 0. But in VC10, it returns -1. Then some checks will be failed when opening a big file. 
To fix this issue, we need to use _wstat64 instead of _wstat. 



Modified: trunk/MgDev/Common/Foundation/System/FileUtil.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/FileUtil.cpp	2012-12-12 01:16:42 UTC (rev 7257)
+++ trunk/MgDev/Common/Foundation/System/FileUtil.cpp	2012-12-12 03:15:05 UTC (rev 7258)
@@ -203,7 +203,7 @@
 /// </summary>
 ///----------------------------------------------------------------------------
 
-bool MgFileUtil::GetFileStatus(CREFSTRING pathname, struct _stat& statInfo,
+bool MgFileUtil::GetFileStatus(CREFSTRING pathname, struct _stat64& statInfo,
     bool strict)
 {
     bool success = false;
@@ -227,7 +227,7 @@
         ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, false));
 
 #ifdef _WIN32
-        success = ::_wstat(path.c_str(), &statInfo) == 0;
+        success = ::_wstat64(path.c_str(), &statInfo) == 0;
 #else
         success = ::stat(MgUtil::WideCharToMultiByte(path).c_str(), &statInfo) == 0;
 #endif
@@ -263,7 +263,7 @@
 
 bool MgFileUtil::PathnameExists(CREFSTRING pathname)
 {
-    struct _stat statInfo;
+    struct _stat64 statInfo;
 
     return GetFileStatus(pathname, statInfo);
 }
@@ -277,7 +277,7 @@
 bool MgFileUtil::IsDirectory(CREFSTRING pathname)
 {
     bool result = false;
-    struct _stat statInfo;
+    struct _stat64 statInfo;
 
     if (GetFileStatus(pathname, statInfo))
     {
@@ -744,7 +744,7 @@
 bool MgFileUtil::IsFile(CREFSTRING pathname)
 {
     bool result = false;
-    struct _stat statInfo;
+    struct _stat64 statInfo;
 
     if (GetFileStatus(pathname, statInfo))
     {
@@ -1145,7 +1145,7 @@
 ///
 MgDateTime MgFileUtil::GetFileCreationTime(CREFSTRING pathname)
 {
-    struct _stat statInfo;
+    struct _stat64 statInfo;
 
     if (GetFileStatus(pathname, statInfo, true))
     {
@@ -1161,7 +1161,7 @@
 ///
 MgDateTime MgFileUtil::GetFileModificationTime(CREFSTRING pathname)
 {
-    struct _stat statInfo;
+    struct _stat64 statInfo;
 
     if (GetFileStatus(pathname, statInfo, true))
     {
@@ -1177,7 +1177,7 @@
 ///
 INT64 MgFileUtil::GetFileSize(CREFSTRING pathname)
 {
-    struct _stat statInfo;
+    struct _stat64 statInfo;
 
     if (GetFileStatus(pathname, statInfo, true))
     {

Modified: trunk/MgDev/Common/Foundation/System/FileUtil.h
===================================================================
--- trunk/MgDev/Common/Foundation/System/FileUtil.h	2012-12-12 01:16:42 UTC (rev 7257)
+++ trunk/MgDev/Common/Foundation/System/FileUtil.h	2012-12-12 03:15:05 UTC (rev 7258)
@@ -28,7 +28,7 @@
     #include <sys/file.h>
 
     #define _rmdir rmdir
-    #define _stat stat
+    #define _stat64 stat
 #endif
 
 class MG_FOUNDATION_API ACE_Recursive_Thread_Mutex;
@@ -67,7 +67,7 @@
     static void AppendSlashToEndOfPath(REFSTRING path);
     static void RemoveSlashFromEndOfPath(REFSTRING path);
 
-    static bool GetFileStatus(CREFSTRING pathname, struct _stat& statInfo,
+    static bool GetFileStatus(CREFSTRING pathname, struct _stat64& statInfo,
         bool strict = false);
     static bool PathnameExists(CREFSTRING pathname);
 

Modified: trunk/MgDev/Server/src/Common/Manager/LogManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/LogManager.cpp	2012-12-12 01:16:42 UTC (rev 7257)
+++ trunk/MgDev/Server/src/Common/Manager/LogManager.cpp	2012-12-12 03:15:05 UTC (rev 7258)
@@ -2233,7 +2233,7 @@
     STRING path;
     int statResult;
 #ifdef _WIN32
-    struct _stat statBuf;
+    struct _stat64 statBuf;
 #else
     struct stat statBuf;
 #endif
@@ -2246,7 +2246,7 @@
         path = m_path + name;
 
 #ifdef _WIN32
-        statResult = ::_wstat(path.c_str(), &statBuf);
+        statResult = ::_wstat64(path.c_str(), &statBuf);
 #else
         statResult = ::stat(MgUtil::WideCharToMultiByte(path).c_str(),
             &statBuf);

Modified: trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp	2012-12-12 01:16:42 UTC (rev 7257)
+++ trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp	2012-12-12 03:15:05 UTC (rev 7258)
@@ -94,7 +94,7 @@
 bool MgServerTileService::DetectTileLockFile(CREFSTRING lockPathname)
 {
     bool found = false;
-    struct _stat lockFileInfo;
+    struct _stat64 lockFileInfo;
 
     // Check the lock file to see if another thread/process is writing the tile file.
     while (MgFileUtil::GetFileStatus(lockPathname, lockFileInfo))

Modified: trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.cpp	2012-12-12 01:16:42 UTC (rev 7257)
+++ trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.cpp	2012-12-12 03:15:05 UTC (rev 7258)
@@ -541,7 +541,7 @@
         CPPUNIT_ASSERT(updateCsdFileSize == csdFileSize);
 
         //the user CSD file now must exist
-        struct _stat fileStatus;
+        struct _stat64 fileStatus;
         bool fileExists = MgFileUtil::GetFileStatus(csCsdUserFile, fileStatus);
         CPPUNIT_ASSERT(fileExists && fileStatus.st_size);
 

Modified: trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.h
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.h	2012-12-12 01:16:42 UTC (rev 7257)
+++ trunk/MgDev/Server/src/UnitTesting/TestCoordinateSystem.h	2012-12-12 03:15:05 UTC (rev 7258)
@@ -503,7 +503,7 @@
         FileAutoBackup(const CREFSTRING filename, const CREFSTRING rotateSuffix, bool keepFile = false)
             : m_sFilename(filename), m_sRotateSuffix(rotateSuffix), m_bRotated(false), m_bKeepFile(keepFile)
         {
-            struct _stat fileStatus;
+            struct _stat64 fileStatus;
             bool fileExists = MgFileUtil::GetFileStatus(filename, fileStatus);
 
             this->m_sBackupFilename = (this->m_sFilename + this->m_sRotateSuffix);



More information about the mapguide-commits mailing list