コード例 #1
0
ファイル: tclMacTest.c プロジェクト: gordonchaffee/expectnt
int
TclMacChmod(
    char *path, 
    int mode)
{
    HParamBlockRec hpb;
    OSErr err;
    
    c2pstr(path);
    hpb.fileParam.ioNamePtr = (unsigned char *) path;
    hpb.fileParam.ioVRefNum = 0;
    hpb.fileParam.ioDirID = 0;
    
    if (mode & 0200) {
        err = PBHRstFLockSync(&hpb);
    } else {
        err = PBHSetFLockSync(&hpb);
    }
    p2cstr((unsigned char *) path);
    
    if (err != noErr) {
        errno = TclMacOSErrorToPosixError(err);
        return -1;
    }
    
    return 0;
}
コード例 #2
0
ファイル: FSpCompat.c プロジェクト: zv/metamage_1
pascal	OSErr	FSpRstFLockCompat(const FSSpec *spec)
{
#if !__MACOSSEVENORLATER
    if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
    {
        HParamBlockRec	pb;

        pb.fileParam.ioVRefNum = spec->vRefNum;
        pb.fileParam.ioDirID = spec->parID;
        pb.fileParam.ioNamePtr = (StringPtr) &(spec->name);
        pb.fileParam.ioFVersNum = 0;
        return ( PBHRstFLockSync(&pb) );
    }
    else
#endif	/* !__MACOSSEVENORLATER */
    {
        return ( FSpRstFLock(spec) );
    }
}
コード例 #3
0
int chmod(char *path, int mode)
{
    HParamBlockRec hpb;
    OSErr err;

    hpb.fileParam.ioNamePtr = C2PStr(path);
    hpb.fileParam.ioVRefNum = 0;
    hpb.fileParam.ioDirID = 0;

    if (mode & 0200) {
        err = PBHRstFLockSync(&hpb);
    } else {
        err = PBHSetFLockSync(&hpb);
    }

    if (err != noErr) {
        errno = err;
        return -1;
    }

    return 0;
}
コード例 #4
0
int __cdecl _chmod (
        const char *path,
        int mode
        )
{
        HParamBlockRec hparamBlock;
        char szPath[256];
        OSErr osErr;

        if (!*path)
        {
                errno = ENOENT;
                return -1;
        }

        strcpy(szPath, path);
        hparamBlock.fileParam.ioNamePtr = _c2pstr(szPath);
        hparamBlock.fileParam.ioVRefNum = 0;
        hparamBlock.fileParam.ioDirID = 0;

        if (mode & _S_IWRITE) {
                /* clear read only/locked bit */
                osErr = PBHRstFLockSync(&hparamBlock);
        }
        else {
                /* set read only/locked bit */
                osErr = PBHSetFLockSync(&hparamBlock);
        }

        if (osErr)
        {
            _dosmaperr(osErr);
            return -1;
        }

        return 0;
}