Commits

David Rogers committed 52046cb

Patch 3520598 - Fix for Deflate issue to allow using temp storage at any location, not just the current drive.

  • Participants
  • Parent commits 8ae0c95
  • Branches v1-8

Comments (0)

Files changed (2)

OgreMain/include/OgreDeflate.h

 		z_stream* mZStream;
 		size_t mCurrentPos;
 		
-		// Cache for read data in case skipping around
+		/// Cache for read data in case skipping around
 		StaticCache<16 * OGRE_STREAM_TEMP_SIZE> mReadCache;
 		
-		// Intermediate buffer for read / write
+		/// Intermediate buffer for read / write
 		unsigned char *mTmp;
 		
-		// Whether the underlying stream is valid compressed data
+		/// Whether the underlying stream is valid compressed data
 		bool mIsCompressedValid;
 		
 		
 		/** Constructor for creating unnamed stream wrapping another stream.
 		 @param compressedStream The stream that this stream will use when reading / 
 			writing compressed data. The access mode from this stream will be matched.
+		 @param tmpFileName Path/Filename to be used for temporary storage of incoming data
 		*/
-        DeflateStream(const DataStreamPtr& compressedStream);
+        DeflateStream(const DataStreamPtr& compressedStream, const String& tmpFileName = "");
 		/** Constructor for creating named stream wrapping another stream.
 		 @param name The name to give this stream
 		 @param compressedStream The stream that this stream will use when reading / 
 			writing compressed data. The access mode from this stream will be matched.
+		 @param tmpFileName Path/Filename to be used for temporary storage of incoming data
 		 */
-		DeflateStream(const String& name, const DataStreamPtr& compressedStream);	
+		DeflateStream(const String& name, const DataStreamPtr& compressedStream, const String& tmpFileName="");	
 		
 		~DeflateStream();
 		

OgreMain/src/OgreDeflate.cpp

 	}
 	#define OGRE_DEFLATE_TMP_SIZE 16384
     //---------------------------------------------------------------------
-	DeflateStream::DeflateStream(const DataStreamPtr& compressedStream)
+	DeflateStream::DeflateStream(const DataStreamPtr& compressedStream, const String& tmpFileName)
 	: DataStream(compressedStream->getAccessMode())
 	, mCompressedStream(compressedStream)
+    , mTempFileName(tmpFileName)
 	, mZStream(0)
 	, mCurrentPos(0)
 	, mTmp(0)
 		init();
 	}
     //---------------------------------------------------------------------
-	DeflateStream::DeflateStream(const String& name, const DataStreamPtr& compressedStream)		
+	DeflateStream::DeflateStream(const String& name, const DataStreamPtr& compressedStream, const String& tmpFileName)		
 	: DataStream(name, compressedStream->getAccessMode())
 	, mCompressedStream(compressedStream)
+    , mTempFileName(tmpFileName)
 	, mZStream(0)
 	, mCurrentPos(0)
 	, mTmp(0)
 		}
 		else 
 		{
-			// Write to temp file
-			char tmpname[L_tmpnam];
-			tmpnam(tmpname);
-			mTempFileName = tmpname;
+            if(mTempFileName.empty())
+            {
+                // Write to temp file
+                char tmpname[L_tmpnam];
+                tmpnam(tmpname);
+                mTempFileName = tmpname;
+            }
+
 			std::fstream *f = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
-			f->open(tmpname, std::ios::binary | std::ios::out);
+			f->open(mTempFileName.c_str(), std::ios::binary | std::ios::out);
 			mTmpWriteStream = DataStreamPtr(OGRE_NEW FileStreamDataStream(f));
 			
 		}