Skip to content

Commit

Permalink
Better handling of temporary files (#3354)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/mapserver/trunk@10883 7532c77e-422f-0410-93f4-f0b67bdd69e2
  • Loading branch information
Alan Boudreault committed Jan 21, 2011
1 parent e1edf26 commit 9109365
Show file tree
Hide file tree
Showing 18 changed files with 2,014 additions and 1,487 deletions.
2 changes: 2 additions & 0 deletions HISTORY.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ For a complete change history, please see the Subversion log comments.
Current Version (SVN trunk):
----------------------------

- Better handling of temporary files (#3354)

- Support curved features in PostGIS (#3621)

- NODATA values now excluded from autoscaling min/max for non-eight
Expand Down
2 changes: 1 addition & 1 deletion mapcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ int msLoadMapContextURL(mapObj *map, char *urlfilename, int unique_layer_names)
return MS_FAILURE;
}

pszTmpFile = msTmpFile(map->mappath, map->web.imagepath, "context.xml");
pszTmpFile = msTmpFile(map, map->mappath, NULL, "context.xml");
if (msHTTPGetFile(urlfilename, pszTmpFile, &status,-1, 0, 0) == MS_SUCCESS)
{
return msLoadMapContext(map, pszTmpFile, unique_layer_names);
Expand Down
6 changes: 6 additions & 0 deletions mapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4551,6 +4551,7 @@ void initWeb(webObj *web)
web->minscaledenom = web->maxscaledenom = -1;
web->log = NULL;
web->imagepath = msStrdup("");
web->temppath = NULL;
web->imageurl = msStrdup("");

initHashTable(&(web->metadata));
Expand All @@ -4573,6 +4574,7 @@ void freeWeb(webObj *web)
msFree(web->mintemplate);
msFree(web->log);
msFree(web->imagepath);
msFree(web->temppath);
msFree(web->imageurl);
msFree(web->queryformat);
msFree(web->legendformat);
Expand All @@ -4592,6 +4594,7 @@ static void writeWeb(FILE *stream, int indent, webObj *web)
writeString(stream, indent, "FOOTER", NULL, web->footer);
writeString(stream, indent, "HEADER", NULL, web->header);
writeString(stream, indent, "IMAGEPATH", "", web->imagepath);
writeString(stream, indent, "TEMPPATH", NULL, web->temppath);
writeString(stream, indent, "IMAGEURL", "", web->imageurl);
writeString(stream, indent, "LEGENDFORMAT", "text/html", web->legendformat);
writeString(stream, indent, "LOG", NULL, web->log);
Expand Down Expand Up @@ -4664,6 +4667,9 @@ int loadWeb(webObj *web, mapObj *map)
case(IMAGEPATH):
if(getString(&web->imagepath) == MS_FAILURE) return(-1);
break;
case(TEMPPATH):
if(getString(&web->temppath) == MS_FAILURE) return(-1);
break;
case(IMAGEURL):
if(getString(&web->imageurl) == MS_FAILURE) return(-1);
break;
Expand Down
4 changes: 4 additions & 0 deletions mapfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ enum MS_TOKEN_SOURCES {MS_FILE_TOKENS=0, MS_STRING_TOKENS, MS_URL_TOKENS};
/* rfc60 label collision detection */
#define MAXOVERLAPANGLE 1223

/* rfc66 temporary path */
#define TEMPPATH 1224

/* rfc59 bindvals objects */
#define BINDVALS 2000

#endif /* MAPFILE_H */
12 changes: 4 additions & 8 deletions mapgdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,14 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename )
!= NULL )
{
CleanVSIDir( "/vsimem/msout" );
filename = msTmpFile( NULL, "/vsimem/msout/", pszExtension );
filename = msTmpFile(map, NULL, "/vsimem/msout/", pszExtension );
}
#endif
if( filename == NULL && map != NULL && map->web.imagepath != NULL )
filename = msTmpFile(map->mappath,map->web.imagepath,pszExtension);
if( filename == NULL && map != NULL)
filename = msTmpFile(map, map->mappath,NULL,pszExtension);
else if( filename == NULL )
{
#ifndef _WIN32
filename = msTmpFile(NULL, "/tmp/", pszExtension );
#else
filename = msTmpFile(NULL, "C:\\", pszExtension );
#endif
filename = msTmpFile(map, NULL, NULL, pszExtension );
}

bFileIsTemporary = MS_TRUE;
Expand Down
10 changes: 5 additions & 5 deletions mapkmlrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int KmlRenderer::saveImage(imageObj *, FILE *fp, outputFormatObj *format)
char *zip_filename =NULL;
void *hZip=NULL;

zip_filename = msTmpFile( NULL, "/vsimem/kmlzip/", "kmz" );
zip_filename = msTmpFile(NULL, NULL, "/vsimem/kmlzip/", "kmz" );
hZip = CPLCreateZip( zip_filename, NULL );
CPLCreateFileInZip( hZip, "mapserver.kml", NULL );
for (int i=0; i<bufSize; i+=chunkSize)
Expand Down Expand Up @@ -422,7 +422,7 @@ int KmlRenderer::mergeRasterBuffer(imageObj *image, rasterBufferObj *rb) {
char *tmpUrl = NULL;
FILE *tmpFile = NULL;

tmpFileName = msTmpFile(MapPath, image->imagepath, "png");
tmpFileName = msTmpFile(NULL, MapPath, image->imagepath, "png");
tmpFile = fopen(tmpFileName,"wb");
if (tmpFile)
{
Expand Down Expand Up @@ -926,9 +926,9 @@ char* KmlRenderer::lookupSymbolUrl(imageObj *img, symbolObj *symbol, symbolStyle

if (img->imagepath)
{
char *tmpFileName = msTmpFile(MapPath, img->imagepath, "png");
snprintf(iconFileName, sizeof(iconFileName), "%s", tmpFileName);
msFree(tmpFileName);
char *tmpFileName = msTmpFile(NULL, MapPath, img->imagepath, "png");
snprintf(iconFileName, sizeof(iconFileName), "%s", tmpFileName);
msFree(tmpFileName);
}
else
{
Expand Down

0 comments on commit 9109365

Please sign in to comment.