Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / January 2006



Tip: Looking for answers? Try searching our database.

Directory Listing, C++, OSX 10.4

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JammyOne - 06 Jan 2006 13:02 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.