sdetweil has asked for the wisdom of the Perl Monks concerning the following question:

I am using Activestate Perl on Windows, and the Archive::Zip module (1.26)..

the zip file creation is

zip->new() create the object
zip->addfile(), add files to in memory object, repeat as many times a required
zip->writetoNamedFile(filename); write the in memory object to disk in one operation..

someplace in the last function, we encounter a 'read' error. fh->read() fails..(lib.rchive/Zip/newFileMeber.pm/_readRawChunk())

There is an error handler in the zip module package, so we know which file is causing the problem. (5 of them)..

turns out these files are open for write in another process.. so the error is understandable.. BUT.. if we drop to a commandline, we can COPY the file that we got the read error on without difficulty..

SO.. questions..
1. is there some open mode set incorrectly in the zip module Zip.pm/newFileMember.pm which could be corrected to avoid this read problem.
I don't see any 'cross process sharing mode flags' on the open like I see on a C runtime sopen() api.
2. why does the COPY command work?
3. I have been unable to reproduce this with a perl script as the writing process..

this 'file' happens to be a logfile for a long running subsystem component. so it might be 'in use' for months.

we coded up a 'workaround' but can't explain why it works..
use File::Copy copy(badfile,tempfile); zip->addfile(tempfile); unlink(tempfile);

but why does the copy function work?

Sam

Replies are listed 'Best First'.
Re: archive::zip create, file read error
by roboticus (Chancellor) on Mar 06, 2009 at 13:35 UTC
    sdetweil:

    I'd guess that Archive::Zip opens the file in a more restrictive locking mode than copy. I've seen it happen with many programs.

    ...roboticus
Re: archive::zip create, file read error
by Bloodnok (Vicar) on Mar 06, 2009 at 13:07 UTC
    You might consider putting most of the narrative outside the code tags ... to reduce the width of the rendered window.

    Other than that, it sounds like DOS isn't as pernickety as perl (no surprises there then) but a little more actual code would, IMO, help.

    A user level that continues to overstate my experience :-))
      Further to Bloodnok's request:

      Dearest sdetweil: Please do not use  <pre> ... </pre> tags (as you are doing around almost (?) the whole of your post): it screws up the rendering of your posting and of an entire group of other postings on the monk's main page.

      Please do go back and Update your post so as to, at the very least, wrap (almost) everything in  <code> ... </code> or  <c> ... </c> tags (just s{ \b pre \b }{code}xmsg will do the trick); this will make only your own posting illegible.

      Please see Writeup Formatting Tips and Perl Monks Approved HTML tags.