Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Delay in reading files, part 3. Pure Carbon this time.



OK, I think I've narrowed this problem down. But I still don't have the answer.

This code here:

int main() {
    WriteFile( kMyPlace, kMyName, kToWrite );

FSRef ref;
OSErr err = FSPathMakeRef( (const unsigned char*) kMyPlace"/"kMyName, &ref, NULL );
if (err) {
WriteFile( kMyPlace, "CantReadWhatIWrote", "argh!!!" );
} else {
WriteFile( kMyPlace, "ICanReadIt", "yippee" );
}


    return 0;
}

I see a file called "ICanReadIt" created, meaning that I can read the file I wrote within the same program, immediately after it is written. This is what I'd expect.


However, from the parent program that calls this small program, I get this strange problem.


bool MacCheckPublishFileExists() {
    FSRef ref;
    OSStatus err = FSPathMakeRef( ProtFile, &ref, NULL );
    if (err) {
        return false;
    } else {
        return true;
    }
}

I get an non-zero err here, unless I wait for over 0.125 seconds after the auxilliary app exits.

    while (MacCheckPublishAppExists()) {
        WaitSeconds( 0.05 );
    }
    WaitSeconds( 0.13 );
    BOOL Result = MacCheckPublishFileExists();


In both cases I call FSPathMakeRef! So it can't be a case of mixing Cocoa or Carbon, can it?


I mean, the parent app is actually a Cocoa app, but in this case I'm using Carbon calls (FSPathMakeRef) to read the file.

This doesn't really make sense to me.

If I change the above code to this:

    while (MacCheckPublishAppExists()) {
        WaitSeconds( 0.05 );
    }
//    WaitSeconds( 0.13 ); // comment out this line!
    BOOL Result = MacCheckPublishFileExists();


So, we know that the app has finished. So this means by definition, that the file is written, correct? But yet we can't read the file till 0.125 seconds later.


Why???

Where is this documented? I don't see any such behaviour documented. I've never come across it before also. Am I doing something wrong? Or what's going on??


-- http://elfdata.com/plugin/

What does our work achieve, if it's not making the world a happier place?
http://www.whatnextjournal.co.uk/Pages/Next/Happiness.html
When's the last time you thought deeply about how to improve our lives?



_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.