diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1996-09-15 22:11:25 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1996-09-15 22:11:25 (GMT) |
commit | 0bdf979af726cafc4d3b473115f85ce3cf52a32f (patch) | |
tree | bdec4febcba73b29ac172aabd5e3b927bd6ae2b5 /Mac/Modules/macfsmodule.c | |
parent | a39a25e5ec335baf6ab53b889bd460e8575159e2 (diff) | |
download | cpython-0bdf979af726cafc4d3b473115f85ce3cf52a32f.zip cpython-0bdf979af726cafc4d3b473115f85ce3cf52a32f.tar.gz cpython-0bdf979af726cafc4d3b473115f85ce3cf52a32f.tar.bz2 |
Added [GS]etDates methods to get and set creation, modification and
backup times.
Diffstat (limited to 'Mac/Modules/macfsmodule.c')
-rw-r--r-- | Mac/Modules/macfsmodule.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Mac/Modules/macfsmodule.c b/Mac/Modules/macfsmodule.c index 9bcdf62..831fd65 100644 --- a/Mac/Modules/macfsmodule.c +++ b/Mac/Modules/macfsmodule.c @@ -347,6 +347,54 @@ mfs_GetFSSpecFSSpec(self) return NULL; } +/* +** Two generally useful routines +*/ +static OSErr +PyMac_GetFileDates(fss, crdat, mddat, bkdat) + FSSpec *fss; + unsigned long *crdat, *mddat, *bkdat; +{ + CInfoPBRec pb; + OSErr error; + + pb.dirInfo.ioNamePtr = fss->name; + pb.dirInfo.ioFDirIndex = 0; + pb.dirInfo.ioVRefNum = fss->vRefNum; + pb.dirInfo.ioDrDirID = fss->parID; + error = PBGetCatInfoSync(&pb); + if ( error ) return error; + *crdat = pb.hFileInfo.ioFlCrDat; + *mddat = pb.hFileInfo.ioFlMdDat; + *bkdat = pb.hFileInfo.ioFlBkDat; + return 0; +} + +static OSErr +PyMac_SetFileDates(fss, crdat, mddat, bkdat) + FSSpec *fss; + unsigned long crdat, mddat, bkdat; +{ + CInfoPBRec pb; + OSErr error; + + pb.dirInfo.ioNamePtr = fss->name; + pb.dirInfo.ioFDirIndex = 0; + pb.dirInfo.ioVRefNum = fss->vRefNum; + pb.dirInfo.ioDrDirID = fss->parID; + error = PBGetCatInfoSync(&pb); + if ( error ) return error; + pb.dirInfo.ioNamePtr = fss->name; + pb.dirInfo.ioFDirIndex = 0; + pb.dirInfo.ioVRefNum = fss->vRefNum; + pb.dirInfo.ioDrDirID = fss->parID; + pb.hFileInfo.ioFlCrDat = crdat; + pb.hFileInfo.ioFlMdDat = mddat; + pb.hFileInfo.ioFlBkDat = bkdat; + error = PBSetCatInfoSync(&pb); + return error; +} + static object * mfss_as_pathname(self, args) mfssobject *self; @@ -507,6 +555,44 @@ mfss_SetFInfo(self, args) return None; } +static object * +mfss_GetDates(self, args) + mfssobject *self; + object *args; +{ + OSErr err; + unsigned long crdat, mddat, bkdat; + + if (!newgetargs(args, "")) + return NULL; + err = PyMac_GetFileDates(&self->fsspec, &crdat, &mddat, &bkdat); + if ( err ) { + PyErr_Mac(ErrorObject, err); + return NULL; + } + return mkvalue("ddd", (double)crdat, (double)mddat, (double)bkdat); +} + +static object * +mfss_SetDates(self, args) + mfssobject *self; + object *args; +{ + OSErr err; + double crdat, mddat, bkdat; + + if (!newgetargs(args, "ddd", &crdat, &mddat, &bkdat)) + return NULL; + err = PyMac_SetFileDates(&self->fsspec, (unsigned long)crdat, + (unsigned long)mddat, (unsigned long)bkdat); + if ( err ) { + PyErr_Mac(ErrorObject, err); + return NULL; + } + INCREF(None); + return None; +} + static struct methodlist mfss_methods[] = { {"as_pathname", (method)mfss_as_pathname, 1}, {"as_tuple", (method)mfss_as_tuple, 1}, @@ -516,6 +602,8 @@ static struct methodlist mfss_methods[] = { {"SetCreatorType", (method)mfss_SetCreatorType, 1}, {"GetFInfo", (method)mfss_GetFInfo, 1}, {"SetFInfo", (method)mfss_SetFInfo, 1}, + {"GetDates", (method)mfss_GetDates, 1}, + {"SetDates", (method)mfss_SetDates, 1}, {NULL, NULL} /* sentinel */ }; |