File Manipulation
File Manipulation
- Subject: File Manipulation
- From: Seth Willits <email@hidden>
- Date: Mon, 10 Mar 2003 00:05:30 -0800
I'm writing an app which will open two files and modify the contents of
one file based on the other (a simple patching utility). Everything is
going well so far, but I'm just now getting to the file manipulation.
It seems to me that I should open the patch file into an NSData object
and the original file into an NSMutableData object. I'm attempting to
read bytes from the NSData object using subdataFromRange and then set
some bytes in the NSMutableData object, but I wonder, if this is the
best way. Also, I'm trying to figure out how to get the integer value
of a specific range of bytes in the NSData object. If the three bytes
are "A9B" then I need to get the hex value which would be 2715. Would
it be easier to simply work with strings?
Also, another question. Can I open a file as stream and read as I go
along instead of reading it all into memory at once? Similarly, can I
write to a specific byte offset in a file (overwriting the given amount
of bytes) without having to open that file in memory, swap the data,
and then write the file out?
Thanks,
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software -
http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine -
http://www.rbdeveloper.com
"Standing up for what you believe in is never a waste of time."
-- Seth Willits
------------------------------------------------------------------------
---
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.