[matroska] r1092 - in trunk/libebml/src: . platform/win32

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-03-16 16:01:15 +0300 (Wed, 16 Mar 2005)
New Revision: 1092

Modified:
   trunk/libebml/src/StdIOCallback.cpp
   trunk/libebml/src/platform/win32/WinIOCallback.cpp
Log:
libebml: safer when seeking fails

Modified: trunk/libebml/src/StdIOCallback.cpp
===================================================================
--- trunk/libebml/src/StdIOCallback.cpp	2005-03-16 12:48:36 UTC (rev 1091)
+++ trunk/libebml/src/StdIOCallback.cpp	2005-03-16 13:01:15 UTC (rev 1092)
@@ -135,18 +135,22 @@
 		Msg<<"Failed to seek file "<<File<<" to offset "<<(unsigned long)Offset<<" in mode "<<Mode;
 		throw CRTError(Msg.str());
 #endif // GCC2
+		mCurrentPosition = ftell(File);
 	}
-	switch ( Mode )
+	else
 	{
-		case SEEK_CUR:
-			mCurrentPosition += Offset;
-			break;
-		case SEEK_END:
-			mCurrentPosition = ftell(File);
-			break;
-		case SEEK_SET:
-			mCurrentPosition = Offset;
-			break;
+		switch ( Mode )
+		{
+			case SEEK_CUR:
+				mCurrentPosition += Offset;
+				break;
+			case SEEK_END:
+				mCurrentPosition = ftell(File);
+				break;
+			case SEEK_SET:
+				mCurrentPosition = Offset;
+				break;
+		}
 	}
 }
 

Modified: trunk/libebml/src/platform/win32/WinIOCallback.cpp
===================================================================
--- trunk/libebml/src/platform/win32/WinIOCallback.cpp	2005-03-16 12:48:36 UTC (rev 1091)
+++ trunk/libebml/src/platform/win32/WinIOCallback.cpp	2005-03-16 13:01:15 UTC (rev 1092)
@@ -243,7 +243,16 @@
 
 	LONG High = LONG(Offset>>32);
 	mCurrentPosition = SetFilePointer(mFile, LONG(Offset & 0xffffffff), &High, Method);
-	mCurrentPosition += (High<<32);
+	if ( mCurrentPosition == INVALID_SET_FILE_POINTER )
+	{
+		High = 0;
+		DWORD Low = SetFilePointer(mFile, 0, &High, FILE_CURRENT);
+		mCurrentPosition = ((uint64(High)<<32) | Low);
+	}
+	else
+	{
+		mCurrentPosition |= uint64(High<<32);
+	}
 }
 
 uint32 WinIOCallback::read(void*Buffer,size_t Size)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.