[mapserver-commits] r10900 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Jan 24 10:39:06 EST 2011


Author: aboudreault
Date: 2011-01-24 07:39:06 -0800 (Mon, 24 Jan 2011)
New Revision: 10900

Modified:
   trunk/mapserver/mapserver.h
   trunk/mapserver/maputil.c
Log:
Created msTmpPath() function

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-01-23 13:46:40 UTC (rev 10899)
+++ trunk/mapserver/mapserver.h	2011-01-24 15:39:06 UTC (rev 10900)
@@ -2263,6 +2263,7 @@
 
 MS_DLL_EXPORT char **msGetAllGroupNames(mapObj* map, int *numTok);
 MS_DLL_EXPORT char *msTmpFile(mapObj *map, const char *mappath, const char *tmppath, const char *ext);
+MS_DLL_EXPORT char *msTmpPath(mapObj *map, const char *mappath, const char *tmppath);
 MS_DLL_EXPORT char *msTmpFilename(const char *ext);
 MS_DLL_EXPORT void msForceTmpFileBase( const char *new_base );
 

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2011-01-23 13:46:40 UTC (rev 10899)
+++ trunk/mapserver/maputil.c	2011-01-24 15:39:06 UTC (rev 10900)
@@ -1252,7 +1252,34 @@
     char szPath[MS_MAXPATHLEN];
     const char *fullFname;
     char *tmpFileName; /* big enough for time + pid + ext */
-    const char *tmpBase = NULL;
+    char *tmpBase = NULL;
+
+    tmpBase = msTmpPath(map, mappath, tmppath);
+    tmpFileName = msTmpFilename(ext);
+
+    fullFname = msBuildPath(szPath, tmpBase, tmpFileName);
+
+    free(tmpFileName);
+    free(tmpBase);
+
+    if (fullFname)
+        return msStrdup(fullFname);
+
+    return NULL;
+}
+
+/**********************************************************************
+ *                          msTmpPath()
+ *
+ * Return the temporary path based on the platform.
+ * 
+ * Returns char* which must be freed by caller.
+ **********************************************************************/
+char *msTmpPath(mapObj *map, const char *mappath, const char *tmppath)
+{
+    char szPath[MS_MAXPATHLEN];
+    const char *fullPath;
+    const char *tmpBase;
 #ifdef _WIN32
     DWORD dwRetVal = 0;
     TCHAR lpTempPathBuffer[MAX_PATH];
@@ -1279,21 +1306,13 @@
         } 
         else
         {
-            tmpBase = (char*)lpTempPathBuffer; /* NOT SURE HOW TO CAST a TCHAR to char* */
+            tmpBase = (char*)lpTempPathBuffer;
         }
 #endif
     }
 
-    tmpFileName = msTmpFilename(ext);
-
-    fullFname = msBuildPath3(szPath, mappath, tmpBase, tmpFileName);
-
-    free(tmpFileName);
-    
-    if (fullFname)
-        return msStrdup(fullFname);
-
-    return NULL;
+    fullPath = msBuildPath(szPath, mappath, tmpBase);
+    return strdup(fullPath);
 }
 
 /**********************************************************************



More information about the mapserver-commits mailing list