• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to split a big file ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to split a big file ?


  • Subject: How to split a big file ?
  • From: MichaĆ«l Parrot <email@hidden>
  • Date: Mon, 20 Mar 2006 17:30:38 +0100

Hi,


I would like split file with 10MB (or more) segment. But, when split 250MB or more datas, OS X swap and use more RAM. Also, I try it with split command.

How I can reduce this memory usage ?

Thanks for all info about this.

Michael Parrot


NSInputStream *R=[[NSInputStream alloc] initWithFileAtPath:path]; [R open]; int i=0; unsigned long long offset=0; unsigned int r,dec=(10*1024*1024); void *data=(void*)malloc(dec);

	offset=dec;
	while (r=[R read:data maxLength:dec])
	{
		NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
	

		NSString *pFile=[path stringByAppendingFormat:@"%d",++i];
		offset+=dec;

// NSOutputStream...
NSOutputStream *W=[[NSOutputStream alloc] initToFileAtPath:pFile append:NO];
[W open];
[W write:data maxLength:r];
[W close];
[W release];


/*
// NSFileHandle...
int Wd=open ([pFile fileSystemRepresentation],O_WRONLY | O_CREAT | O_EXCL, S_IREAD | S_IWRITE);

NSData *theData=[[NSData alloc] initWithBytes:data length:r];
NSFileHandle *W=[[NSFileHandle alloc] initWithFileDescriptor:Wd closeOnDealloc:YES];

[W seekToFileOffset:0];
[W writeData:theData];
[W synchronizeFile];
[W closeFile];

[theData release];
[W release];
*/


/*
		// FWrite
		FILE *W=fopen([pFile fileSystemRepresentation],"w");
		fwrite(data,1,r,W);
		fclose(W);
*/

/*		// NSData
		NSData *W=[[NSData alloc] initWithBytes:data length:r];
		[W writeToFile:pFile atomically:NO];
		[W release];
*/

		NSLog(@"write r:%d - i:%d",r,i);

		[pool release];
	}


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: How to split a big file ?
      • From: Martin Wierschin <email@hidden>
    • Re: How to split a big file ?
      • From: Dirk Stegemann <email@hidden>
    • Re: How to split a big file ?
      • From: "Paul J. Lucas" <email@hidden>
  • Prev by Date: Re: White caret cursor, how to do it?
  • Next by Date: Re: How to split a big file ?
  • Previous by thread: launching my app breaks command-tab
  • Next by thread: Re: How to split a big file ?
  • Index(es):
    • Date
    • Thread