Example #1
0
int __cdecl _mkdir (
        const char *path
        )
{
        /* ask OS to create directory */
        HParamBlockRec hparamBlock;
        char st[256];
        OSErr osErr;

        if (!*path)
        {
            errno = ENOENT;
            return -1;
        }
        strcpy(st, path);
        hparamBlock.fileParam.ioNamePtr = _c2pstr(st);
        hparamBlock.fileParam.ioVRefNum = 0;
        hparamBlock.fileParam.ioDirID = 0;
        osErr = PBDirCreateSync(&hparamBlock);
        if (osErr) {
            /* error occured -- map error code and return */
            _dosmaperr(osErr);
            return -1;
        }

        return 0;
}
Example #2
0
pascal	OSErr	FSpDirCreateCompat(const FSSpec *spec,
                                   ScriptCode scriptTag,
                                   long *createdDirID)
{
#if !__MACOSSEVENORLATER
    if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
    {
        OSErr			result;
        UniversalFMPB	pb;

        pb.hPB.fileParam.ioVRefNum = spec->vRefNum;
        pb.hPB.fileParam.ioDirID = spec->parID;
        pb.hPB.fileParam.ioNamePtr = (StringPtr) &(spec->name);
        result = PBDirCreateSync(&(pb.hPB));
        *createdDirID = pb.hPB.fileParam.ioDirID;
        if ( result == noErr )
        {
            /* get info on created item */
            pb.ciPB.dirInfo.ioFDirIndex = 0;
            pb.ciPB.dirInfo.ioDrDirID = spec->parID;
            result = PBGetCatInfoSync(&(pb.ciPB));
            if ( result == noErr )
            {
                /* Set frScript in DXInfo */
                /* The negative script constants (smSystemScript, smCurrentScript, and smAllScripts) */
                /* don't make sense on disk, so only use scriptTag if scriptTag >= smRoman */
                /* (smRoman is 0). frScript is valid if high bit is set (see IM-6, page 9-38) */
                pb.ciPB.dirInfo.ioDrFndrInfo.frScript = (scriptTag >= smRoman) ?
                                                        ((char)scriptTag | (char)0x80) :
                                                        (smRoman);
                /* Restore ioDirID field in pb which was changed by PBGetCatInfo */
                pb.ciPB.dirInfo.ioDrDirID = spec->parID;
                result = PBSetCatInfoSync(&(pb.ciPB));
            }
        }
        return ( result );
    }
    else
#endif	/* !__MACOSSEVENORLATER */
    {
        return ( FSpDirCreate(spec, scriptTag, createdDirID) );
    }
}