views:

29

answers:

0

I'm writting a photoshop plugin. Im currently trying to write code to save my data to file, however any attempt to do so is resulting in SetFilePointer returning -1. What to do!!!!

OSErr SetFPos (int32 refNum, short posMode, long posOff)
{
    long moved = SetFilePointer((HANDLE)refNum, posOff, NULL, posMode);

    if (moved != posOff)
     return writErr;

    return noErr;
}


static void DoWriteStart ()
{
    if (*gResult != noErr)
    {
     return;
    }

    int16 resourceCount = gCountResources(histResource);

    while (resourceCount)
    {
     // a read only handle, no need to dispose
     Handle resourceHandle = gGetResources(histResource,resourceCount--);
     Ptr resourcePtr = NULL;
     sPSHandle->SetLock(resourceHandle, true, &resourcePtr, NULL);
     sPSHandle->SetLock(resourceHandle, false, &resourcePtr, NULL);
    }

    // read script params here
    ReadScriptParamsOnWrite ();
    if (*gResult != noErr)
    {
     return;
    }

    /* Write the header. */

    *gResult = SetFPos (gFormatRecord->dataFork, fsFromStart, 0);
    if (*gResult != noErr)
    {
     return;
    }