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

Re: [MacPerl] Newbie question



Op 29-09-2000 om 13:59 schreef CoDeReBeL@hotmail.com:

> > At 12:45 PM -0500 9/29/00, <CoDeReBeL@hotmail.com> wrote:
> >> I'm also assuming that Perl will refuse to open a file for writing that
> >> already is, which also seems reasonable.
> > 
> > This depends entirely on the operating system.  It certainly isn't
> > true under Unix, where you can open a file for writing as many times
> > as you want.  It may or may not be true for MacPerl.  You might be
> > able to find out from Mac OS using a toolbox call.
> > 
> > --
> > --
> > Paul Schinder
> > schinder@pobox.com
> > 
> 
> Overwhelmed with curiosity, I decided to find out what the deal was. If any
> process *except* MacPerl has a file open for writing, then
> 
> open (WHATEVER, '+<theFileName')
> 
> returns false. If, however, the process that has the file open for writing
> is MacPerl itself, it returns true. I used MPW in the test. Presumably,
> standalone applications and droplets count as separate processes.

Sorry, but it doesn't always work that way when your file is on
a server, i tried it on an NT server and on a AppleShare IP server
and i can open/move the file even while it is written from an other
client.

U can find out a little more on your local machine by checking the
filetype, if it is being written the type changes to bsy*
I'm not sure if this is also the case when it is just in use.

---snippet---
$file = "thefileUareChecking";

my $srcspec = Mac::Files::FSpGetCatInfo($file);
    if($srcspec)
    {
        $spec = $srcspec->ioFlFndrInfo->fdType;
    
        $res = $spec;
        print "$res\n";
        if($res =~ s/bzy.*/1/)
        {
            return 1;
        }
        else
        {   
            return 0;
        }
    }
    else
    {
        return -1;
    }
}
------------

Please let me know if you find a conclusive way to be absolutely
sure that a file is not in use.

Thanks for bringing up this subject.

Cheers, Tom.





# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org