Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6092673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:28:14+00:00 2026-05-23T12:28:14+00:00

I’m attempting to convert an old chunk of code containing the obsolete Carbon functions

  • 0

I’m attempting to convert an old chunk of code containing the obsolete Carbon functions FSWrite, FSRead, etc. One experiment we want to try is replacing these with their POSIX equivalents, the functions defined in stdio.h, e.g. replacing FSRead() with fread(). But I’m not sure what to do about the first arg given to the Carbon functions:

SetFPos(gFormatRecord->dataFork, fsFromStart, 0);

gFormatRecord is a pointer to a FormatRecord. Is the dataFork just a plain regular unixy file handle suitable to shove into fread(), fprintf() and such? (I don’t know much about file “forks” in any case.)

(This is a follow-up to my earlier question, On a Mac, where are FSRead, FSWrite, SetFPos et al defined, and should I even be using them?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:28:15+00:00Added an answer on May 23, 2026 at 12:28 pm

    From gFormatRecord->dataFork, it sounds like you’re trying to write a Photoshop plugin. That’s not going to work so well.

    Photoshop (and presumably most Mac Adobe software) is full of a lot of Carbon code, which was designed to be largely identical to existing 8.5 APIs while also being API/ABI compatible with OS X (I don’t know if/when CFM Carbon support was dropped).

    According to the documentation, you’re supposed to use FSSetForkPosition() instead, which probably ends up being the same function call in the end. You almost certainly can’t use fseek()/fsetpos()/fseeko(), which expect a FILE *, while a Carbon file handle appears to be a SInt16 according to my header (the webdocs say it’s a FSIORefNum). [1]

    Also note that fopen() and friends are not POSIX; they’re standard C. The POSIX functions are generally the same without the leading f, except for seek which is lseek(). [2] The POSIX “file handle” is a file descriptor, which is just an int.

    Now, if you’re incredibly lucky, a FSIORefNum will just be a file descriptor which you can pass to read()/write()/lseek(). But this is ultimately for little benefit; if Photoshop’s still built on Carbon, what’s the point?


    Footnotes!

    1. It’s not impossible that fseek() special-cases pointers to the zero page, but I don’t think they’d pollute libc with that.)
    2. On Linux/x86, you’ll need to #define __FILE_OFFSET_BITS 64 or so to get largefile support, which is easy to forget. Shame it’s not easy to do so universally…
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.