PDA

View Full Version : HOpenDF not working on Leopard




pallavi0703
Jun 9, 2008, 02:12 AM
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.



gnasher729
Jun 9, 2008, 05:45 AM
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.

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.

pallavi0703
Jun 10, 2008, 02:09 AM
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.

pallavi0703
Jun 19, 2008, 05:24 AM
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.

Sayer
Jun 19, 2008, 09:02 AM
The headers usually point to when a function will stop working or be available:

/* 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.