예제 #1
0
boolean setfilecomment (FSSpec *pfs, bigstring bscomment) {
	
	DTPBRec dt;
	
	clearbytes (&dt, longsizeof (dt));
	
	if (!hasdesktopmanager ((*pfs).vRefNum))
		return (false);
	
	dt.ioVRefNum = (*pfs).vRefNum;
	
	if (PBDTGetPath (&dt) != noErr)
		return (false);
	
	dt.ioNamePtr = (*pfs).name;
	
	dt.ioDirID = (*pfs).parID;
	
	dt.ioDTBuffer = (Ptr) bscomment + 1;
	
	dt.ioDTReqCount = stringlength (bscomment);
	
	if (PBDTSetCommentSync (&dt) != noErr)
		return (false);
	
	PBDTFlushSync (&dt);
	
	return (true);
	} /*setfilecomment*/
예제 #2
0
파일: setfcomment.c 프로젝트: Airr/osxutils
///////////////////////////////////////////////////////////////////
// We set the MacOS 9 Finder comment using the File Manager API's
// Desktop Database functions.
///////////////////////////////////////////////////////////////////
static OSErr OS9_SetComment (FSSpec *fileSpec, char *comment, bool *unsupported)
{
#if !__LP64__    
    OSErr	err = noErr;
    DTPBRec dt;
        
    dt.ioVRefNum = (*fileSpec).vRefNum;
        
    err = PBDTGetPath(&dt);
    if (err != noErr) {
        *unsupported = true;
        return err;
    }
    
    //fill in the relevant fields (using parameters)
    dt.ioNamePtr = (*fileSpec).name;
    dt.ioDirID = (*fileSpec).parID;
    dt.ioDTBuffer = comment;
    dt.ioDTReqCount = strlen(comment);
    
    if (PBDTSetCommentSync (&dt) != noErr)
            return (err);
    
    err = PBDTSetCommentSync(&dt);
    if (err != noErr)
        return err; 
        
    err = PBDTFlushSync (&dt);
#endif        
    return (noErr);
}