Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Waiting for file exclusive access before File action
#1
Hi Gintaras, hi all

my backup program have some flaws i want to correct with QM

1. i backup in zip file, but the backup is done first in empty file, then filled. I'd like to rename the
file after it has been fully created, i.e it's released from backup program access. I messe with the setfile stuff,
but not very efficient. Idea?

2. In this purpose, what is the good file trigger setting, regarding the status trigger (modified etc).

3. i tried to implement my own backup routine, but the qmzip examples failed in my macro.
ref qmzip qmzip_def
str zipfilename="u:\test.zip"
str zipdir="q:\jj"
HZIP zipfile=CreateZip(zipfilename, 0,ZIP_FILENAME);
error => Error in qmzip_def: unexpected character

ZipAdd(zipfilename,zipdir, 0,0,ZIP_FOLDER);

the last one fails saying it needs 6 parameters, not 5. Stuck there.

Thanks.
#2
Function WaitForFileReady
Code:
Copy      Help
;/
function $_file [^waitmax]

;Waits until file exists, is not empty, and is not locked.

;waitmax - max number of seconds to wait. 0 is infinite.


if(waitmax<0 or waitmax>2000000) end ES_BADARG
opt waitmsg -1
int wt(waitmax*1000) t1(GetTickCount)

Dir d
rep
,if d.dir(_file) and d.FileSize
,,__HFile f.Create(_file OPEN_EXISTING); err
,,if(f) f.Close; break
,
,if(wt>0 and GetTickCount-t1>=wt) end "wait timeout"
,0.5

;info: the d.FileSize is for Firefox, which at first creates empty file, then downloads to other file...

2. Modified.

3. Why don't use zip?
#3
1. will test, ty. BTW, the backup program is not related to firefox, but it might work too.

2. will test too

3. what "zip" are you exactly talking about? I tried to use QM class, is there another way?
#4
str files=
;file1
;file2
;...
zip "$desktop$\file.zip" files
#5
2. Maybe "Added" is better in this case.
#6
Hmm, for the zip command, i only found qmzip searching in macros, and did not think about help file.

Of course, it will fit my needs perfectly.

BTW, unrelated but boring too.

I trigger a macro in firefox on middle mouse click

Acc+ AccStuff.FromMouse
POINT+ _m; xm _m
a.Role(_s)
sel _s
case "some" : mac "amac"
case "PAGETAB" :err; ret
case else mac "gotoit"
macro gotoit (menu)
....
....
something to do :mac "doit"

macro doit

here i'd like to access global variable AccStuff defined in first macro,
but i can't. Why?
#7
Never use global Acc variables. It is a COM object, and most COM objects work only in single thread. Also need to release the object, but global variable will not do it automatically when need.
#8
OK, i suspected that, but wanted to be sure. I would have simplified things.

Back to the zip thing, zip macro is useful, but too restricted.

What is the correct code to add files in zip?

function event $name [$newname]
event: 1 added, 2 removed, 4 renamed, 8 modified
ref qmzip qmzip_def

int hzip
sel event
case [1]
_s=name
hzip=OpenZip(_s.unicode 0 ZIP_FILENAME)
ZipAdd(hzip,"src1.txt", "u:\\src1.txt",0,ZIP_FILENAME)
Error in Macro3: expected 6 to 6 arguments, not 5. GRRRRRRRRR!!!!!!!!!!!!!
CloseZip(hzip);
#9
I don't recommend using qmzip.dll directly. You don't know all the details. Somewhere I posted the C header file, but not everything is documented there. Also, qmzip.dll will not be installed with QM in the future.

In your code, the last argument 'level' is missing. I don't remember what it is, try 0. Also, in QM don't use \\ in file paths. Also, ZipAdd fails if opened with OpenZip. Need to create new file with CreateZip. Cannot add more files to an existing zip file.
#10
OK, i'll play more then. Will you thne implement better zip manipulation routine in
forecoming versions? If you could handle rar archives too, it'll be great.
#11
Quote:Will you thne implement better zip manipulation routine in
forecoming versions? If you could handle rar archives too, it'll be great.
no
#12
OK, i'll try to use the command line version of 7-zip then.
#13
OK, played with your function.

Is this stupid code i tried have any chance to fail under some circumstances, or can I use it
too safely for that purpose too?

function event $name [$newname]
event: 1 added, 2 removed, 4 renamed, 8 modified
str NewName Ext
Dir d
long _size
sel event
case [1,8]
d.dir(name)
WaitForFileReady(name)
rep
_size=d.FileSize
out _size
if(_size>0) break
....
do something when file is created
#14
With WaitForFileReady don't need rep d.FileSize. It waits itself. I cannot say whether this code always will work. Need to test.


Forum Jump:


Users browsing this thread: 2 Guest(s)