Hi All,
Im trying to get a list of files within a specified directory and
keep getting a file not found error whenever I try to get the ID of th
directory. Any ideas anyone? Heres the code...
short vRefNum=0;
const unsigned char volname[] = ":WE SDE:";
const unsigned char dirname[] = "Tech Drawings";
Boolean isDirectory=true;
long theDirID=0;
OSErr err = kNoErr;
char szMsg[128];
err = DetermineVRefNum(volname, 0, &vRefNum);
// At this point err = kNoErr and vRefNum = -104
err = GetDirectoryID(vRefNum, 0, dirname, &theDirID, &isDirectory);
// Now err = fnfErr (File not found) and theDirID = 0.
Anyone know what im missing? DetermineVRefNum and GetDirectoryID can b
found in MoreFilesExtras.c
Thanks in advance.
Jamm
--
JammyOn
macosx.com - The Answer to Mac Support - http://www.macosx.co
David Phillip Oster - 06 Jan 2006 16:43 GMT
> Hi All,
>
[quoted text clipped - 20 lines]
> Anyone know what im missing? DetermineVRefNum and GetDirectoryID can be
> found in MoreFilesExtras.c
1.) You are passing a zero for the parent directory id in your call to
GetDirectoryID(). You must pass the dirID of the parent of "Tech
Drawings". If "Tech Drawings" is a child of the root, then you may use
the predefined constant for the root directory.
2.) your volname can't be right: volnames never start with colons.
3.) volname should be a pascal string. Your string constant is missing
the \p.
4.) ditto for dirname.
Also, you are using the old pre-OS 9 system calls. You should be using
calls from this century: FSGetCatalogInfo(), which needs an FSRef, that
you make with a Unix style path: FSMakeFSRefUnicode().
(If you don't want to deal with unicode, never need to handle
internationalized or long file and folder names, then you can call
FSMakeFSSpec(), followed by FSpMakeFSRef();)
JammyOne - 11 Jan 2006 11:43 GMT
Hi David,
Thank you for those. I'll give them a try and see where we get.
Best Regards,
Jamm
--
JammyOn
macosx.com - The Answer to Mac Support - http://www.macosx.co