Page 1 of 1

Setting the tmp-path in OgreDeflate

Posted: Mon Dec 05, 2011 7:43 pm
by Doc_QuicknDirty
Hi there,

I had some massive problems with OgreDeflate under Windows 7.

At line 118 it creates a temporary file by using std::tmpname(). tmpname() will retrun something like "/s03g.". But in windows / is the disk volume root directory. When running Ogre from my D: partition Deflate could create temporary files, but could not delete them. When running Ogre from C: Windows blocked creating files in C:/ generally and my app crashed.

My workaround was to add the following:

Code: Select all

117	// Write to temp file
118	char tmpname[L_tmpnam];
119	tmpnam(tmpname);
120	#ifdef _WIN32
121	if(tmpname[0] == '\\')
122	{
123	   for(int i = 1; i < L_tmpnam; i++)
124	      {
125	         tmpname[i - 1] = tmpname[i];
126	     }
127	     tmpname[L_tmpnam - 1] = -52;
128	 }
129	#endif
130	mTempFileName = tmpname;
131	std::fstream *f = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
132	f->open(tmpname, std::ios::binary | std::ios::out);
133	...
Now it writes the temporary files to the working directory.

My suggestion is to add a possibility to specify a path for the temporary files. If you work a lot with deflate you could than use a RAM-disk e.g.

Best wishes

Ralf

Re: Setting the tmp-path in OgreDeflate

Posted: Fri Jun 29, 2012 6:09 am
by arcanemartz
In case other end up here after encountering that problem, I posted a patch on the bug tracker:

http://sourceforge.net/tracker/?func=de ... tid=302997

Re: Setting the tmp-path in OgreDeflate

Posted: Fri Jun 29, 2012 11:28 pm
by jacmoe
Okay, why does the existing patch not work?
It was committed to v1-8 at April 24th this year:
-> https://bitbucket.org/sinbad/ogre/chang ... 046cb4439c
Sinbad merged it into 'default' 3 days ago. :)

Re: Setting the tmp-path in OgreDeflate

Posted: Fri Jul 20, 2012 6:14 am
by arcanemartz
The patch on April 24th allows the caller to specify the temporary file.

The problem is still there when you don't specify the file.

Edit: The new submitted patch is more about that problem:
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=70625
but I though some would end up in this post (as I did) when looking for a solution.