home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!gumby!destroyer!ncar!roke.rap.ucar.edu!tres
- From: tres@roke.rap.ucar.edu (Tres Hofmeister)
- Subject: File Manager Question
- Message-ID: <1992Sep15.210718.25918@ncar.ucar.edu>
- Keywords: PBGetCatInfo, PBSetCatInfo
- Sender: news@ncar.ucar.edu (USENET Maintenance)
- Organization: National Center for Atmospheric Research / RAP
- Distribution: usa
- Date: Tue, 15 Sep 1992 21:07:18 GMT
- Lines: 103
-
-
- I'm having trouble understanding why a call to PBSetCatInfo is
- failing. I'm a beginning Macintosh programmer, and would appreciate
- any help offered, especially suggestions on more effective solutions
- to this problem, or improvements.
-
- What I'm trying to do here is to update the modification time
- of the parent directory of a file. As this will eventually be
- converted into an XCMD, I'm using the full pathname of the file,
- which is easy to come by in HyperCard. In this test program the
- filename is a constant, but later it will be passed in as an argument
- to the XCMD.
-
- Rather than parsing the pathname, I thought I could grab the
- parent directory's directory ID from the ioDrParID field of the
- parameter block, call PBGetCatInfo again to get information on the
- parent, then set the parent's modification date with PBSetCatInfo.
-
- The problem is that the call to PBSetCatInfo is failing with a
- "file not found" error. I'm not sure why this should be when prior
- and subsequent calls to PBGetCatInfo using the same parameter block
- work fine. Everything else seems to work fine.
-
- Here's the code:
-
- #include <string.h>
- #include <stdio.h>
-
- main()
- {
- CInfoPBRec info;
- long parDirID;
- Str255 name;
-
- /* Zero struct */
- memset(&info, 0, sizeof(info));
-
- info.dirInfo.ioNamePtr =
- CtoPstr("Quantum 105:Desktop Folder:/tmp:Junk");
-
- /* Get file information */
- printf("PBGetCatInfo result: file: %i\n",
- PBGetCatInfo(&info, FALSE));
- printf("Filename: \"%#s\"\n", info.dirInfo.ioNamePtr);
-
- /* Save parent directory ID */
- parDirID = info.dirInfo.ioDrParID;
-
- /* Reset the CInfoPBRec struct for the parent directory */
- memset(&info, 0, sizeof(info));
- info.dirInfo.ioNamePtr = name;
- info.dirInfo.ioDrDirID = parDirID;
- info.dirInfo.ioFDirIndex = -1;
-
- /* Get parent directory information */
- printf("PBGetCatInfo result: folder: %i\n",
- PBGetCatInfo(&info, FALSE));
- printf("Folder Name: \"%#s\"\n", info.dirInfo.ioNamePtr);
-
- printf("Modification date before: %lu\n",
- info.dirInfo.ioDrMdDat);
-
- /* Set modification time to current time */
- GetDateTime(&info.dirInfo.ioDrMdDat);
-
- /* Set folder information */
- printf("PBSetCatInfo result = %i\n",
- PBSetCatInfo(&info, FALSE));
-
- /* Try again */
- printf("PBGetCatInfo result: file: %i\n",
- PBGetCatInfo(&info, FALSE));
-
- printf("Modification date after: %lu\n",
- info.dirInfo.ioDrMdDat);
- }
-
-
- And here's the output from the program:
-
- PBGetCatInfo result: file: 0
- Filename: "Quantum 105:Desktop Folder:/tmp:Junk"
- PBGetCatInfo result: folder: 0
- Folder Name: "/tmp"
- Modification date before: 2799405218
- PBSetCatInfo result = -43
- PBGetCatInfo result: file: 0
- Modification date after: 2799405218
-
-
- Error -43 is the "file not found" error. What am I doing
- wrong? Also, is there an "official" Macintosh way to zero a struct,
- rather than using memset()?
-
- I'm using THINK C 5.x. The entire point of this exercise is
- to get the Finder to update the icon on a file who's creator has been
- changed.
-
- Many thanks, in advance.
-
- --
- Tres Hofmeister
- tres@ncar.ucar.edu
-