diff -Naur osxutils-old/src/fileinfo.c osxutils-new/src/fileinfo.c --- osxutils-old/src/fileinfo.c 2004-12-19 17:57:45.000000000 -0500 +++ osxutils-new/src/fileinfo.c 2005-06-06 04:36:41.000000000 -0400 @@ -199,6 +199,15 @@ +OSErr RetrieveStatData (FileInfoStruct *file); +OSErr RetrieveFileInfo (FileInfoStruct *file); +OSErr ProcessFinderInfo (FileInfoStruct *file); +char* GetFileNameFromPath (char *name); +static OSStatus FSMakePath(FSRef fileRef, UInt8 *path, UInt32 maxPathSize); +static char* GetSizeString( UInt64 size, short sizeFormat); +OSErr GetDateTimeStringFromUTCDateTime (UTCDateTime *utcDateTime, char *dateTimeString); +static short GetLabelNumber (short flags); + void OutputFileInfo (char *path) { short i = 0; @@ -412,7 +421,8 @@ /* Is Stationery */ file->finderFlags[5] = (file->finderInfo.fdFlags & kIsStationery) ? 1 : 0; - + + return noErr; } diff -Naur osxutils-old/src/getfcomment.c osxutils-new/src/getfcomment.c --- osxutils-old/src/getfcomment.c 2004-12-18 18:31:38.000000000 -0500 +++ osxutils-new/src/getfcomment.c 2005-06-06 06:34:36.000000000 -0400 @@ -106,6 +106,41 @@ return 0; } +/* Try to get a comment from spotlight, copying it into 'buf' and returning + * true if successful. */ +static int TrySpotlightComment(char *path, char *buf) { + if (MDItemCreate == NULL) { + return 0; /* Spotlight not around */ + } else { + MDItemRef mditem = NULL; + CFStringRef cfpath = NULL, comment = NULL; + int result = 0; + + cfpath = CFStringCreateWithFileSystemRepresentation(NULL, path); + if (cfpath == NULL) + goto done; + + mditem = MDItemCreate(NULL, cfpath); + if (mditem == NULL) + goto done; + + comment = MDItemCopyAttribute(mditem, kMDItemFinderComment); + if (comment == NULL) + goto done; + + result = CFStringGetCString(comment, buf, MAX_COMMENT_LENGTH - 1, + GetApplicationTextEncoding()); + + done: + if (cfpath != NULL) + CFRelease(cfpath); + if (mditem != NULL) + CFRelease(mditem); + if (comment != NULL) + CFRelease(comment); + return result; + } +} static void PrintFileComment (char *path) { @@ -113,8 +148,8 @@ FSRef fileRef; FSSpec fileSpec; DTPBRec dt; - char buf[255] = "\0"; - char comment[255] = "\0"; + char buf[MAX_COMMENT_LENGTH] = "\0"; + char comment[MAX_COMMENT_LENGTH] = "\0"; //see if the file in question exists and we can write it if (access(path, R_OK|F_OK) == -1) @@ -123,44 +158,46 @@ return; } - //get file reference from path - err = FSPathMakeRef(path, &fileRef, NULL); - if (err != noErr) - { - fprintf(stderr, "FSPathMakeRef: Error %d for file %s\n", err, path); - return; - } - - //retrieve filespec from file ref - err = FSGetCatalogInfo (&fileRef, NULL, NULL, NULL, &fileSpec, NULL); - if (err != noErr) - { - fprintf(stderr, "FSGetCatalogInfo(): Error %d getting file spec for %s\n", err, path); - return; - } - - ///////////// oK, now we can go about getting the comment ///////////// - - dt.ioVRefNum = fileSpec.vRefNum; - - err = PBDTGetPath(&dt); - - //fill in the relevant fields (using parameters) - dt.ioNamePtr = fileSpec.name; - dt.ioDirID = fileSpec.parID; - dt.ioDTBuffer = (char *)&buf; - - PBDTGetCommentSync(&dt); - - if (dt.ioDTActCount != 0) //if zero, that means no comment - { + if (!TrySpotlightComment(path, comment)) { + //get file reference from path + err = FSPathMakeRef(path, &fileRef, NULL); + if (err != noErr) + { + fprintf(stderr, "FSPathMakeRef: Error %d for file %s\n", err, path); + return; + } + + //retrieve filespec from file ref + err = FSGetCatalogInfo (&fileRef, NULL, NULL, NULL, &fileSpec, NULL); + if (err != noErr) + { + fprintf(stderr, "FSGetCatalogInfo(): Error %d getting file spec for %s\n", err, path); + return; + } + + ///////////// oK, now we can go about getting the comment ///////////// + + dt.ioVRefNum = fileSpec.vRefNum; + + err = PBDTGetPath(&dt); + + //fill in the relevant fields (using parameters) + dt.ioNamePtr = fileSpec.name; + dt.ioDirID = fileSpec.parID; + dt.ioDTBuffer = (char *)&buf; + + PBDTGetCommentSync(&dt); + + if (dt.ioDTActCount == 0) //if zero, that means no comment + return; + strncpy((char *)&comment, (char *)&buf, dt.ioDTActCount); - if (!printFileName) - printf("%s\n", (char *)&comment); - else - printf("Comment for '%s':\n%s\n", path, (char *)&comment); } - return; + + if (!printFileName) + printf("%s\n", (char *)&comment); + else + printf("Comment for '%s':\n%s\n", path, (char *)&comment); } diff -Naur osxutils-old/src/rcmac osxutils-new/src/rcmac --- osxutils-old/src/rcmac 2004-12-17 00:35:04.000000000 -0500 +++ osxutils-new/src/rcmac 2005-06-06 04:56:10.000000000 -0400 @@ -46,6 +46,7 @@ done if [ $u ] || [ $vv ] ; then exit $u ; fi if ! [ $1 ] ; then set $1 "." ; fi +if echo -- "$1" | grep '^[-()!,]'; then set $1 "./$1"; fi #echo "DEBUG: find -f \"$1\" \( -type d \) -exec echo '{}': \; -exec lsmac $lsmacoptions -o $escape '{}' \; -exec echo \;" #echo "DEBUG: \$f is $f, \$1 is $1, \$@ is $@, \$lsmacoptions is $lsmacoptions, \$escape is $escape." -find -f $1 \( -type d \) -exec echo '{}': \; -exec lsmac $lsmacoptions -o $escape '{}' \; -exec echo \; +find $1 \( -type d \) -exec echo '{}': \; -exec lsmac $lsmacoptions -o $escape '{}' \; -exec echo \;