Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

itayKinnrot

macrumors newbie
Original poster
Oct 15, 2007
3
0
hi,
i'm trying to open a file dialog box with defualt path on the begining (which i or the user will choose...)
i'm having problem with this function :
////code:
switch (callBackSelector) // 2

{
case kNavCBStart:
status = NavCustomControl(MyDialogRef,

kNavCtlSetLocation,

&fileN);
1. fileN is from the type AEDesc but i'm having problems with it
Thank you very much
itay
 

itayKinnrot

macrumors newbie
Original poster
Oct 15, 2007
3
0
Thanks, i already tried it - i need full example with this code

i'm having problems with the Desc i think - it's just not working
Thank you
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Show the code you are using to create the AEDesc then, otherwise we have no clue what it is you are doing, or doing wrong as the case may be.

Are you using an FSSpec or FSRef in the AEDesc? Is the path a folder (directory, *blech*)?

It is virtually impossible to fix your problem when you haven't fully explained what you are doing.
 

itayKinnrot

macrumors newbie
Original poster
Oct 15, 2007
3
0
here is the code -- Thanks...

OSStatus PathToFSSpec(const char *path, FSSpec spec)
{
OSStatus err;
FSRef ref;
if ((err = FSPathMakeRef((const UInt8*)path, &ref, NULL)) != noErr) {
return(err);
}
// FSRef -> FSSpec
if ((err = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec,
NULL)) != noErr) {
return(err);
}
return(noErr);
}

in the event handler function:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

pathname = malloc(200*sizeof(char));
strcpy(pathname,"/Users/");


FSSpec spec;
err = PathToFSSpec(pathname, spec);


AEDesc desc;
err = AECreateDesc(typeFSS, &spec, sizeof(FSSpec),&desc);





switch (callBackSelector) // 2
{
case kNavCBStart:
status = NavCustomControl(MyDialogRef,
kNavCtlSetLocation,
&desc);
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Since you are already using Carbon you might as well use FindFolder() to locate the Users folder. Despite what certain Mac OS X Developers may say, using literal paths is a Bad Idea™. For one thing the name of the Users folder may be localized on non-English systems, or it may be in a mounted network volume at a different path than local Users.

So FindFolder is the best choice here. In fact we can use a "modern" variant that returns a FSRef which we can convert down to an FSSpec:

FSFindFolder(
short vRefNum,
OSType folderType,
Boolean createFolder,
FSRef * foundRef)

To find the Users folder you just use:

Code:
FSRef   theUsersFolderRef;
OSStatus   result;

result = FSFindFolder(
  kOnAppropriateDisk,
  kUsersFolderType,
  FALSE,
  &theUsersFolderRef);

Then you can convert that to an FSSpec:

Code:
FSSpec theUsersFolderSpec;

FSGetCatalogInfo(theUsersFolderRef,
0,
NULL,
NULL,
&theUsersFolderSpec,
NULL);
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.