HOpenDF not working on Leopard

Discussion in 'Mac Programming' started by pallavi0703, Jun 9, 2008.

  1. macrumors newbie

    pallavi0703

    Joined:
    Dec 12, 2007
    #1
    Hello All ,
    I am building my Xcode(2.4) Carbon project using universal binaries.
    I have used HOpenDF call for opening file for reading.
    StringPtr voln;
    Str255 temp;
    c2pstrcpy (temp,lpszfname);
    pstrcat(voln, "\p:prj Dir:");
    pstrcat(voln, temp);
    Err =HOpenDF (0,0,voln,fsRdPerm, &FileRefNo);

    It works on mac OS 10.4 but for mac OS 10.5 this api returns error code.
    Which is the suitable function call which will work on both OS 10.4 as well as 10.5.
    Or whether I need to have Xcode 2.5 version .
    Please Reply.

    Thanks & Regards ,
    Pallavi.
     
  2. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    When a function returns an error code, it is always helpful to tell us which one. But you are calling pstrcat without having initialized voln, so this is just asking for trouble.
     
  3. thread starter macrumors newbie

    pallavi0703

    Joined:
    Dec 12, 2007
    #3
    HOpenDF not working on Leopard

    Hello gnasher729 ,
    Thanks for reply.
    I have not send some part of my code .Here is the full code .
    OSErr Err;
    Str255 temp;
    c2pstrcpy (temp,lpszfname);//f1.txt
    Str255 VolumeName;
    StringPtr voln;
    pstrcopy(VolumeName,sPath);//sPath is global variable its current value is "Macintosh HD"
    voln = VolumeName;
    pstrcat(voln,"\p:prj Dir:");
    pstrcat(voln, temp);//temp is f1.txt
    //voln has value "Macintosh HD:prj Dir:f1.txt"
    Err =HOpenDF (0,0,voln,fsRdPerm, &FileRefNo);
    If file is not present it return Err = -43 else if 0 this is on Mac OS 10.4.
    Our customer is using Mac 10.5 .So I don't know which Err is Mac 10.5

    Ok.
    Thanks & Regards ,
    Pallavi.
     
  4. thread starter macrumors newbie

    pallavi0703

    Joined:
    Dec 12, 2007
    #4
    HOpenDF not working on Leopard

    Hello ,

    Now I am using FSOpenFork instead of HDOpenDF .
    Is it Ok for both OS X 10.4 and OS X 10.5.

    Please reply,
    Thanks,
    Pallavi.
     
  5. macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #5
    The headers usually point to when a function will stop working or be available:

    Code:
    /* This function is deprecated in Mac OS X 10.4. Use FSOpenFork instead.*/
    /*
     *  HOpenDF()   *** DEPRECATED ***
     *  
    So I'm guessing 10.5 drops this function and FSOpenFork is what you should use in 10.4 and 10.5.
     

Share This Page