Setting the tmp-path in OgreDeflate

What it says on the tin: a place to discuss proposed new features.
Post Reply
Doc_QuicknDirty
Gnoblar
Posts: 16
Joined: Mon Aug 30, 2010 4:48 pm
x 1

Setting the tmp-path in OgreDeflate

Post 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
User avatar
arcanemartz
Gnoblar
Posts: 6
Joined: Tue Jun 26, 2012 11:38 pm
x 3
Contact:

Re: Setting the tmp-path in OgreDeflate

Post 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
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Setting the tmp-path in OgreDeflate

Post 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. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
arcanemartz
Gnoblar
Posts: 6
Joined: Tue Jun 26, 2012 11:38 pm
x 3
Contact:

Re: Setting the tmp-path in OgreDeflate

Post 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.
Post Reply