Quote:
Originally Posted by smithdale87
This should get you on the right track. Mix and match pseudo code
Code:
-(void) concatFiles( NSString* path1, NSString* path2, NSString* combinedPath )
{
NSFileHandle * f1Handle = [NSFileHandle fileHandleForReadingAtPath: path1];
NSFileHandle *f2Handle = [NSFileHandle fielHandleForReadingAtPath: path2];
//might need to check if file exists first, if not create it using NSFileManager's createFileAtPath
NSFileHandle * combinedHandle = [NSFileHandle fileHandleForWritingAtPath: combinedPath];
// read data in small chunks to avoid hogging memory.
NSData* read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
while( length of read != 0 )
{
[combineHandle writeData: read];
read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
}
[f1Handle close];
//now do the same for f2Handle
//might need to ignore a few bytes in the front of file2 that isnt audio
[f2Handle readDataOfLength: HEADER_LENGTH];
NSData* read = [f2Handle readDataOfLength: CHUNK_SIZE] ;
while (... )
{
}
[f2Handle close];
[combineHandle close];
}
|
Wow thank you so much that will probably do it. That is so awesome! I haven't done anything with the NSFileHandle yet so I didn't know about it and it's methods. What do you recommend for the values of CHUNK_SIZE and HEADER_LENGTH?
Also in reference to me not being here for a while I have been very busy making tons of apps for the app store with various companies. I am also involved with the creation of highly developed new tutorial website that will be ready soon. Also busy finishing high school =P.
Nick