Esempio n. 1
0
void test_hcreateresfile(void)
{
    OSErr err;

    // will 0, 0 work on real macos?

    HDelete(0, 0, fname);
    HCreateResFile(0, 0, fname);
    if ( (err = ResError()) != 0) {
        fprintf(stderr, "HCreateResFile failed (File does not exist): %d\n", err);
        exit(1);
    }

    // Verify it doesn't fail if the file/fork already exist.
    HCreateResFile(0, 0, fname);
    if ( (err = ResError()) != 0) {
        fprintf(stderr, "HCreateResFile (File/Fork exist) failed: %d\n", err);
        exit(2);
    }

    // Verify it doesn't fail if the file exists w/o a resource fork.
    HDelete(0, 0, fname);
    HCreate(0, 0, fname, 'TEST', 'BINA');
    HCreateResFile(0, 0, fname);
    if ( (err = ResError()) != 0) {
        fprintf(stderr, "HCreateResFile (File exists) failed: %d\n", err);
        exit(2);
    }

    HDelete(0, 0, fname);
}
Esempio n. 2
0
static SInt16 *macDoOpen(const char *fname, SInt8 perm, int createIfMissing)
{
    int created = 0;
    SInt16 *retval = NULL;
    FSSpec spec;
    OSErr err = fnameToFSSpec(fname, &spec);
    BAIL_IF_MACRO((err != noErr) && (err != fnfErr), NULL, NULL);
    if (err == fnfErr)
    {
        BAIL_IF_MACRO(!createIfMissing, ERR_NO_SUCH_FILE, NULL);
        err = HCreate(spec.vRefNum, spec.parID, spec.name,
                      procInfo.processSignature, 'BINA');
        BAIL_IF_MACRO(oserr(err) != noErr, NULL, NULL);
        created = 1;
    } /* if */

    retval = (SInt16 *) malloc(sizeof (SInt16));
    if (retval == NULL)
    {
        if (created)
            HDelete(spec.vRefNum, spec.parID, spec.name);
        BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
    } /* if */

    err = HOpenDF(spec.vRefNum, spec.parID, spec.name, perm, retval);
    if (oserr(err) != noErr)
    {
        free(retval);
        if (created)
            HDelete(spec.vRefNum, spec.parID, spec.name);
        return(NULL);
    } /* if */

    return(retval);
} /* macDoOpen */
Esempio n. 3
0
int __PHYSFS_platformDelete(const char *path)
{
    FSSpec spec;
    OSErr err;
    BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, NULL, 0);
    err = HDelete(spec.vRefNum, spec.parID, spec.name);
    BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0);
    return(1);
} /* __PHYSFS_platformDelete */
Esempio n. 4
0
void HeapSort(int arr[], int n, PriorityComp pc)
{
	Heap heap;
	int i;

	HeapInit(&heap, pc);

	// 정렬 대상을 가지고 힙을 구성한다.
	for(i=0; i<n; i++)
		HInsert(&heap, arr[i]);

	// 순서대로 하나씩 꺼내서 정렬을 완성한다.
	for(i=0; i<n; i++)
		arr[i] = HDelete(&heap);
}