• 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
File Manipulation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: File Manipulation
      • From: Oleg Svirgstin <email@hidden>
  • Prev by Date: Adding scripting support to Cocoa applications
  • Next by Date: Re: What the heck is going on here? :-)
  • Previous by thread: Re: Adding scripting support to Cocoa applications
  • Next by thread: Re: File Manipulation
  • Index(es):
    • Date
    • Thread