Skip to content

Commit

Permalink
Created msTmpPath() function
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/mapserver/trunk@10900 7532c77e-422f-0410-93f4-f0b67bdd69e2
  • Loading branch information
Alan Boudreault committed Jan 24, 2011
1 parent a58c9d4 commit ae26466
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions mapserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,7 @@ MS_DLL_EXPORT pointObj *msGetMeasureUsingPoint(shapeObj *shape, pointObj *point)

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 );

Expand Down
43 changes: 31 additions & 12 deletions maputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,34 @@ char *msTmpFile(mapObj *map, const char *mappath, const char *tmppath, const cha
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];
Expand All @@ -1279,21 +1306,13 @@ char *msTmpFile(mapObj *map, const char *mappath, const char *tmppath, const cha
}
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);
}

/**********************************************************************
Expand Down

0 comments on commit ae26466

Please sign in to comment.