Thanks Howard, createFile indeed does the job without the aesthetically
displeasing moving/renaming. Here's what I wound up with after reading the docs
and testing...
...
my $__cfh;
until($__cfh = createFile($File->{fullPath} . "/" . $File->{name}, 'w ke'))
{
print LOG "Waiting for copy completion " . $File->{fullPath} . "/" .
$File->{name} . "\n";
sleep(15);
}
CloseHandle($__cfh);
print LOG "Starting process....\n";
...
> -------Original Message-------
> From: Howard Tanner <[EMAIL PROTECTED]>
> Subject: RE: File test operator for slow incoming files
> Sent: Aug 24 '06 20:54
>
> Lynn,
>
> The Windows API CreateFile allows you to open a file exclusively. If the
> file is already open, the exclusive open will fail. ActivePerl has
> Win32API::File::createFile, which provides a Perl-friendly interface to this
> API. Just use the value 0 for $svShare to request exclusive access. If it
> fails, you know the file is still open. This should be cleaner than your
> copy (or my rename) solution.
>
> Howard Tanner
>
> P.S. Don't forget to call Win32API::File::CloseHandle if the call to
> createFile succeeds.
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Lynn.
> Rickards
> Sent: Thursday, August 24, 2006 11:04 AM
> To: [email protected]
> Subject: File test operator for slow incoming files
>
> Greetings,
>
> This is on XP Pro and Win Server 2003
>
> Script is monitoring a shared directory for incoming files. File arrives, is
> seen and is processed.
>
> Files are placed in this share by users across a global WAN so it can be
> some time before the
> copy is complete and the file is truly available for processing - maybe 30
> minutes from the
> time the file is first seen, so I need to test for this.
>
> BTW the monitor is based on Roth's dirmon.pl
>
> Looking at file size doesn't help since windoze reports finished size as
> soon as the first byte arrives.
>
> Here's how I thought I could do it...
>
> until(-W $File->{fullPath} . "/" . $File->{name} )
> {
> print LOG "Waiting for copy completion
> $File->{fullPath}" . "/" . $File->{name} . "\n";
> sleep(15);
> }
> print LOG "Starting process....\n";
>
> Unfortunately -W (or -w -r or any others that look interesting) don't seem
> to do what I want so
> when the file first appears, script goes straight to processing.
>
> The one thing that works is to try to move the file to another location and
> loop like above until the
> move is successful. Then I have to move it back to get on with processing.
> This seems to
> be unnecessarily clunky. Anybody got a better method please?
>
> TIA - Lynn.
>
>
>
>
>
>
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs