home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / librarie / posix10.sit / POSIX / ThinkCPosix / utime.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-11  |  648 b   |  36 lines

  1. /* $Id: $ */
  2.  
  3. #include "ThinkCPosix.h"
  4.  
  5. int utime (char *filename,struct utimbuf *times)
  6. {
  7.     CInfoPBRec cipbr;
  8.     HFileInfo *fpb = (HFileInfo*)&cipbr;
  9.     DirInfo *dpb = (DirInfo*)&cipbr;
  10.     unsigned char pname[256];
  11.     short err;
  12.  
  13.     strcpy((char*)pname, filename);
  14.     c2pstr(pname);
  15.  
  16.     dpb->ioDrDirID = 0L;
  17.     fpb->ioNamePtr = pname;
  18.     fpb->ioVRefNum = 0;
  19.     fpb->ioFDirIndex = 0;
  20.     fpb->ioFVersNum = 0;
  21.     err = PBGetCatInfo(&cipbr, FALSE);
  22.     if (err != noErr) {
  23.         errno = ENOENT;
  24.         return -1;
  25.     }
  26.     fpb->ioFlMdDat = times->modtime;
  27.     fpb->ioFlCrDat = times->actime;
  28.     err = PBSetCatInfo(&cipbr, FALSE);
  29.     if (err != noErr) {
  30.         errno = EACCES;
  31.         return -1;
  32.     }
  33.     return 0;
  34. }
  35.  
  36.