Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of cabarc to backup/restore data files

Status
Not open for further replies.

crogec

Programmer
May 10, 2002
16
US
I found faq184-145 by ChrisRChamerlain and found it very informative. The compression portion of cabarc seems to be working just fine. However, I am having trouble with the extract side.
I am using cabarc with VFP5.0 to compress all data tables as part of my user selected backup/restore routine. I am not very well versed in the use of winexec and am getting a return code of 33 during the extract or restore routine but the files are not extracted nor restored. Perhaps my problem is more in not understanding how to handle API calls.
The portion of code that applies is:

*use getfile() to return user selected backup cab file to restore from...

cCurBackUp = getfile([cab])
* example of selected file->A:\backup-04-13-2003-211.cab

IF cCurBackUp = ' '
=messagebox('No file found. Files were not restored.',0)
RETURN
ENDIF

*kitchen is the directory where the main app and data lives

lcProg2Run = [CABARC x &cCurBackUp c:\kitchen\]

DECLARE INTEGER WinExec IN kernel32 ;
STRING lpCmdLine ,;
INTEGER uCmdShow
IF !WinExec(lcProg2Run, 0) > 31
= MESSAGEBOX('This should have extracted files to the....',0)
ENDIF

Does anyone have a listing of return codes and meanings for this use of WinExec()?
Can anyone shed some light on why the files are not being extracted?

Thanks,
George
 
crogec

Without testing, it would appear the problem with the extraction of the cabfiles lies with the code:-

lcProg2Run = [CABARC x &cCurBackUp c:\kitchen\]

which I would guess will fail because WinExec() is unlikely to recognise VFP macro substition.

You could try

lcProg2Run = [CABARC x ];
[tab]+ cCurBackUp;
[tab]+ [ c:\kitchen\]

What happens if you follow the guidelines in the FAQ and use extract.exe instead?

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris, thanks for your response. Even though I had been working on this bit of code for a number of hours, I failed to discover all the command options for cabarc. It seems the trouble was with my assumptions. Without the '-o' command option, the extraction will not overwrite same named files. I assumed the default was overwrite without a specific command but that is not so. It now is working as originally coded which I suppose says that winexec() will accept macro substitution. I had not even thought of that as a possibility.
Thanks again for your faq and your response.
George
 
George

Pleased you have resolved the issue and surprised and pleased the embedded macro substitution works.

WinExec was originally suggested for compatibility with 16-bit Windows - Shellexecute() would probably be a better way to go as there may be a marginal performance improvement.

I provide this routine in applications by default where appropriate and it has saved an awful lot of tears over the years - I've just had a user religiously backing up to a zip drive which was failing to write correctly for three weeks, blissfully unaware of disaster looming.

This little routine saved the day!

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris, again thanks for your response.

I stand corrected. After further testing to try to understand why I was getting inconsistent results when extracting files from the cab, (sometimes it seemed to work and sometimes not), I have come to the conclusion you are right and the embedded macro substitution does not seem to work. I at this time cannot tell you why it appeared to work sometimes. I suppose it has to do with my testing method. At any rate, I used your suggested code eliminating the substitution and it now works consistently.

I have not tried the extract.exe yet. I was trying to hurry this along and as usual, I have spent more time on this than it might have taken to use the extract.exe.

I have not used the Shellexecute() you mentioned and wonder if you would point me in a direction of information on it's use.

I appreciate your help.
George
 
Guys, I really appreciate your help and kudos to Mike Lewis for publishing the FoxStuff site! I will experiment with ShellExecute().

Chris, how did your user discover his backup to the zip drive was not working?

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top