[matroska] r1085 - trunk/mkxuncat

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-03-04 23:30:39 +0300 (Fri, 04 Mar 2005)
New Revision: 1085

Modified:
   trunk/mkxuncat/mkxuncat.cpp
Log:
mkxuncat: now actually put the data in the various output files

Modified: trunk/mkxuncat/mkxuncat.cpp
===================================================================
--- trunk/mkxuncat/mkxuncat.cpp	2005-03-04 20:20:24 UTC (rev 1084)
+++ trunk/mkxuncat/mkxuncat.cpp	2005-03-04 20:30:39 UTC (rev 1085)
@@ -88,10 +88,11 @@
 
 	unsigned int u_OuputFileIndex = 0;
 	char t_IndexBuffer[8];
-	int64 i_SizeToCopy;
+	int64 i_DataSize, i_SizeToCopy;
 	string OutputFilename;
 	int i_Level = 0;
 	IOclass *p_OutputFile = NULL;
+	char *ReadBuff = new char[8*1024];
 
 	EbmlElement * ElementLevel0;
 
@@ -114,14 +115,29 @@
 		}
 
 		p_InputFile.setFilePointer( ElementLevel0->GetElementPosition() );
-		i_SizeToCopy = ElementLevel0->ElementSize();
+		i_DataSize = i_SizeToCopy = ElementLevel0->ElementSize();
 		
-		// TODO copy data
+		// copy data
+		while ( i_SizeToCopy )
+		{
+			if ( i_SizeToCopy >= 8*1024 )
+			{
+				p_OutputFile->write( ReadBuff, p_InputFile.read( ReadBuff, 8*1024 ) );
+				i_SizeToCopy -= 8*1024;
+			}
+			else
+			{
+				p_OutputFile->write( ReadBuff, p_InputFile.read( ReadBuff, i_SizeToCopy ) );
+				i_SizeToCopy = 0;
+			}
+		}
 
-		p_InputFile.setFilePointer( ElementLevel0->GetElementPosition() + i_SizeToCopy );
+		p_InputFile.setFilePointer( ElementLevel0->GetElementPosition() + i_DataSize );
 
 		ElementLevel0 = aStream.FindNextElement( KaxAll_Context, i_Level, 0xFFFFFFFFL, false, 1 );
 	}
 
+	delete ReadBuff;
+
 	return 0;
 }
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.