[delphizip] Re: Exclusive file access

  • From: "Russell Peters" <russellpeters@xxxxxxxxxxx>
  • To: <delphizip@xxxxxxxxxxxxx>
  • Date: Wed, 25 Sep 2002 07:40:11 +1000

Unfortunately the dlls don't use the windows API (use older but standard C
routines ie fopen, fread etc).
As soon as I can I will have a look at (optionally) forcing the dll to make
a temporary file.
Actually I thought I did make it do so (in 1.7.0.5) if the target was not
FIXED_DISK, FLOOPY_DISK or RAM_DISK making it only in danger of multiple
access while being transferred to final destination and I would be very
surprised if it allowed any shared writes.
Russell Peters
http://www.users.bigpond.com/russellpeters/delphizip.html


----- Original Message -----
From: "James Turner" <james.d.h.turner@xxxxxxxxxxxx>
To: <delphizip@xxxxxxxxxxxxx>
Sent: Wednesday, September 25, 2002 12:07 AM
Subject: [delphizip] Re: Exclusive file access


>
> I haven't tried what I'm about to suggest but I can think of no reason why
> there should be a problem.
>
> To prevent write access to zip file simple open it with FILE_SHARE_READ
> access. This will prevent others from writing to the file. Before calling
> the ZipMaster.Add function, you must call CloseHandle. When the
> ZipMaster.Add function has completed, reopen the file with FILE_SHARE_READ
> access.
>
> If the ZipDLL allows shared write access (something I doubt) there could
be
> problems.
>
> See Microsoft documentation on the API function CreateFile for more
details.
>
> This is not a perfect solution, but in practice should be ok. You should
> also consider monitoring the file date - this is the approach I use to
solve
> a slightly different problem.
>
> James Turner
>
> PS
> I have a feeling that it is possible to limit the instances of file
sharing
> under NT. This might be a better solution. The function LockFileEx may
also
> be useful.
>
> ----- Original Message -----
> From: "Petko Kafedjiski" <kafedjiski@xxxxxxxxxxx>
> To: <delphizip@xxxxxxxxxxxxx>
> Sent: Tuesday, September 24, 2002 11:00 AM
> Subject: [delphizip] Re: Exclusive file access
>
>
> >
> > Thank you very much Russell.
> >
> > I missed one thing: by doing, what you advice (iterating through all
> > instances), I suspect that other instances run on other machines on the
> > network can also overwrite the file, am I right?
> >
> > However, I have an idea and it is to create a temp file for every
instance
> > that opens the archive, so this will fix the problem to a given level.
> >
> > Regards,
> > Petko Kafedjiski
> > Milenix Software Ltd.
> > http://www.milenix.com
> >
> > P.S.: I am sorry for my bad english :)
> >
> > ----- Original Message -----
> > From: "Russell Peters" <russellpeters@xxxxxxxxxxx>
> > To: <delphizip@xxxxxxxxxxxxx>
> > Sent: Monday, September 23, 2002 11:58 PM
> > Subject: [delphizip] Re: Exclusive file access
> >
> >
> > >
> > > This would be helped if I can add an AddTemp option (force add/modify
to
> a
> > > temporary file), other than that the only way that comes to mind is to
> > make
> > > a temporary file (for each instance) to work on.
> > > - Russell Peters
> > > A late thought - it should be possible to iterate through all
instances
> > > checking ZipBusy and only writing if none busy.
> > > Hope this helps.
> > > ----- Original Message -----
> > > From: "Petko Kafedjiski" <kafedjiski@xxxxxxxxxxx>
> > > To: <delphizip@xxxxxxxxxxxxx>
> > > Sent: Tuesday, September 24, 2002 4:15 AM
> > > Subject: [delphizip] Exclusive file access
> > >
> > >
> > > >
> > > > Hello to all! I am new to this mail list, so my question may be
> answered
> > > > already and I want to appologize, if it is so.
> > > >
> > > > I have an application (http://www.milenix.com - MyInfo 2), which
uses
> > > BCBZip
> > > > ver. 1.6. However there is a problem, because a single file could be
> > > opened
> > > > in two instances of the program and then when the user saves the
file
> > > (which
> > > > is actually an archive with many files within) in one of the
instances
> > and
> > > > then saves it in the other - there is a mess with the file and
> sometimes
> > > > even the all information could be lost.
> > > >
> > > > I want to prevent this by gaining exclusive read-write access of the
> > file,
> > > > so it could be opened only once. There is no such option in BCBZip,
> but
> > is
> > > > there some way to workaround it?
> > > >
> > > > Thank you very much for your time!
> > > > Petko Kafedjiski
> > > > Milenix Software Ltd.
> > > > http://www.milenix.com
> > > >
> > > >
> > >
> >
>
>
>


Other related posts: