[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MacPerl::SetFileInfo Help (fwd)



With all due respect to Mark's knowledge and observation abilities, I believe
he is mistaken in this question.

mark@cheers.jsc.nasa.gov (Mark Manning/Muniz Eng.) writes:
>According to Matthias Ulrich Neeracher:
>>Mark: 
>> >The file isn't even officially created until after it's been closed.
>> 
>> Hmm? Where did you get that idea? The Finder is slow to update sometimes,
>> but the file is certainly created at open() time.
>
>The OPEN command does not guarantee that the file is
>created immediately.

But it does!

>Only that you wish to open and/or
>create a file if it isn't there.  With a ram cache (which
>is automatically engaged in  Mac OS version 7.5 and later),

In fact, I remember reading that a cache setting of 0K was silently
interpreted as a non-zero cache size for some system versions prior
to 7.5 :-)

>the open command can be cached and, until a flush is issued
>(ie: a close usually does this) by the user or system, the
>request to create a new file can take as long as five
>minutes.

We have to distinguish two properties of the file system cache here:

 - Is a file created *on disk* immediately when it's opened? No. That may
   indeed take a considerable time (same as on UN*X).
 - Is a file created *in the file system* immediately when it's opened? Yes.

This means that, although a freshly created file would not be visible to
a tool reading SCSI blocks directly, it is visible and available to
manipulation in the file system (since *every* call goes through the cache
first). 

The following program:

$name = "t001";
for ($i = 100; $i--; ) {
    open(T, ">$name") || die "open $name";
				MacPerl::SetFileInfo($name, "TEXT", $name);
				++$name;
}

created all 100 files and set their creators exactly as specified. If you have
a perl program to demonstrate your claim that freshly created files may not be
immediately visible, you're welcome to post it & convince me :-)

>My feelings are: Better safe than sorry.  :-)

A fine principle, although, to be pedantic, close() on a file does not entirely
flush the disk cache, so you're not safe with close either.

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "There once was an Age of Reason, but we've progressed beyond it."
                                   -- Ayn Rand, _Atlas Shrugged_







***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch