/* * Copyright 1993, 1995 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ # include "jam.h" # include "filesys.h" # ifdef macintosh #include <Files.h> #include <TextUtils.h> #ifdef __MWERKS__ #include <time.mac.h> // for _mac_msl_epoch_offset_ #else #define _mac_msl_epoch_offset_ 0 #endif /* * filemac.c - manipulate file names and scan directories on macintosh * * External routines: * * file_dirscan() - scan a directory for files * file_time() - get timestamp of file, if not done by file_dirscan() * file_archscan() - scan an archive for files * * File_dirscan() and file_archscan() call back a caller provided function * for each file found. A flag to this callback function lets file_dirscan() * and file_archscan() indicate that a timestamp is being provided with the * file. If file_dirscan() or file_archscan() do not provide the file's * timestamp, interested parties may later call file_time(). * * 04/08/94 (seiwald) - Coherent/386 support added. * 12/19/94 (mikem) - solaris string table insanity support * 02/14/95 (seiwald) - parse and build /xxx properly * 05/03/96 (seiwald) - split into pathunix.c * 11/21/96 (peterk) - BEOS does not have Unix-style archives * 05/20/00 (grantg) - use MacOS native APIs instead of GUSI */ /* * file_dirscan() - scan a directory for files */ void file_dirscan( dir, func ) char *dir; void (*func)(); { FILENAME f; char fullname[ MAXJPATH ]; OSErr err; StringPtr pdir; CInfoPBRec dirinfo; CInfoPBRec fileinfo; Str31 filename; short i; /* First enter directory itself */ memset( (char *)&f, '\0', sizeof( f ) ); f.f_dir.ptr = dir; f.f_dir.len = strlen(dir); /* If no ":", append one */ if (!strchr(dir, ':')) { dir[f.f_dir.len++] = ':'; dir[f.f_dir.len] = 0; } if( DEBUG_BINDSCAN ) printf( "scan directory %s\n", dir ); /* Special case ":" - enter it */ if( f.f_dir.len == 1 && f.f_dir.ptr[0] == ':' ) (*func)( dir, 0 /* not stat()'ed */, (time_t)0 ); /* Now enter contents of directory */ /* Get info for the directory */ pdir = c2pstr(dir); dirinfo.dirInfo.ioCompletion = NULL; dirinfo.dirInfo.ioNamePtr = pdir; dirinfo.dirInfo.ioVRefNum = 0; dirinfo.dirInfo.ioFDirIndex = 0; dirinfo.dirInfo.ioDrDirID = 0; err = PBGetCatInfoSync(&dirinfo); p2cstr(pdir); /* Exit if an error, or if it is not a directory! */ if (err != noErr || !(dirinfo.dirInfo.ioFlAttrib & ioDirMask)) { return; } /* There are dirinfo.dirInfo.ioDrNmFls files, indexed from 1. * filename is a buffer that will be filled in by PBGetCatInfo * (it does not need to be cleared at every iteration because * PBGetCatInfo ignores the contents when ioFDirIndex is positive) * fileinfo.hFileInfo.ioDirID must be reset at every iteration * (PBGetCatInfo sets it to the file ID of the requested file) */ fileinfo.hFileInfo.ioCompletion = NULL; fileinfo.hFileInfo.ioNamePtr = filename; fileinfo.hFileInfo.ioVRefNum = dirinfo.dirInfo.ioVRefNum; for (i = 1; i <= dirinfo.dirInfo.ioDrNmFls; i++) { fileinfo.hFileInfo.ioFDirIndex = i; fileinfo.hFileInfo.ioDirID = dirinfo.dirInfo.ioDrDirID; err = PBGetCatInfoSync(&fileinfo); p2cstr(filename); if (err != noErr) break; f.f_base.ptr = (char *)filename; f.f_base.len = strlen( f.f_base.ptr ); file_build( &f, fullname, 0 ); (*func)( fullname, 1 /* stat()'ed */, (time_t)fileinfo.hFileInfo.ioFlMdDat + _mac_msl_epoch_offset_ ); } } /* * file_time() - get timestamp of file, if not done by file_dirscan() */ int file_time( filename, time ) char *filename; time_t *time; { StringPtr pfname; CInfoPBRec catinfo; OSErr err; char filename2[ MAXJPATH ]; /* Fill out the param block for PBGetCatInfo */ pfname = c2pstr(filename); catinfo.hFileInfo.ioCompletion = NULL; catinfo.hFileInfo.ioNamePtr = pfname; catinfo.hFileInfo.ioVRefNum = 0; catinfo.hFileInfo.ioFDirIndex = 0; catinfo.hFileInfo.ioDirID = 0; /* Call PBGetCatInfoSync to get the file info */ err = PBGetCatInfoSync(&catinfo); p2cstr(pfname); if (err != noErr) { /* try appending a ':' to find volume names*/ strcpy(filename2, filename); strcat(filename2, ":"); pfname = c2pstr(filename2); catinfo.hFileInfo.ioNamePtr = pfname; catinfo.hFileInfo.ioVRefNum = 0; catinfo.hFileInfo.ioFDirIndex = 0; catinfo.hFileInfo.ioDirID = 0; err = PBGetCatInfoSync(&catinfo); p2cstr(pfname); if (err != noErr) { /* file/directory not found */ return -1; } } *time = catinfo.hFileInfo.ioFlMdDat + _mac_msl_epoch_offset_; return 0; } /* * file_archscan() - scan an archive for files */ void file_archscan( archive, func ) char *archive; void (*func)(); { } # endif /* macintosh */
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 553 | Grant Glouser | Integrate Jam 2.3 changes. | ||
#3 | 425 | Grant Glouser |
Revamped Mac build to use MPW Interfaces&Libraries. In particular, the bootstrap script and the default Jambase settings use the standard MPW tools, headers and libraries (this package is available from Apple's developer website). The Jambase also retains some support for the CodeWarrior tools - this can be enabled by passing -sMETROWERKS=true on the jam command line. The bootstrap script should also work with the CodeWarrior MPW package, although it uses only the standard MPW tools/headers/libs. Also added SubDirHook to the Jambase. |
||
#2 | 352 | Grant Glouser |
Use MacOS native APIs instead of GUSI. And additional Mac path handling improvements. filemac.c - rewrote file_dirscan and file_time to use MacOS native API (PBGetCatInfo). This means GUSI is no longer needed, which should make Jam more stable and ever so slightly faster under MacOS. pathmac.c - no trailing colons on directories. This has the effect of allowing rules to recursively process paths under MacOS (which makes MacOS just like every other platform in this respect). timestamp.c - extra timestamp check for possible volume names under MacOS - case-sensitivity OFF for MacOS Jamfile and Build.mpw - altered to remove GUSI header search paths and libraries. This complicates the Jamfile - perhaps these changes should be merged into the Jambase. |
||
#1 | 300 | Grant Glouser | Branching jam sources to my guest directory. |