JavaMonkey
Programmer
I read FAQ 184-145 a while back and thought the concepts there of using CABARC would be very useful. I'm implementing it now in a new app, but I'm using it for a slightly different purpose. I've always envied Access developers for one reason: they can put all their data in a single MDB (I think that's the extension?) file. Those of us using VFP have to create dozens of files...dbf, fpt, cdx, dbc, etc. In most ways, that's better for us as developers but there's one horrible flaw: getting users to deal with all the files properly. They have to be persuaded to back up a whole folder of data instead of simply copying one file and then restore ALL the files together as one unit if a restore is needed. But, human nature being what it is, some user will undoubtedly make a mistake on a customer and decide to restore only customer.dbf from last week...thereby crashing all the links to invoices of new customers as well as losing the matching CDX and FPT files (just one scenario but I think everyone can imagine many other similar situations).
Anyway, I thought I'd try using CAB type files as the main storage medium with this app, which will have relatively small numbers of records (perhaps 2000 or so at most) so they will compress pretty fast with CABARC. When the app starts, it extracts all the database files from the CAB into a 'working' folder...when it shuts down, it compresses the files back into the CAB. The user never really knows that his/her data file is actually 33 separate files...he or she can store the single CAB file under any preferred name in any location.
However, I've run into a slight problem...CABARC is faster than my OS/hard drive! I've run the extraction routine with some debug stuff to test what's happening and it appears that WinExec reports back a successful extraction of all files and my app proceeds on to the next few lines of code which open the database...only to report that the DBC doesn't exist. It does however exist in the 'working' folder and if I use a wait window or suspend execution and then click resume in the debugger, all is fine. It seems like VFP is racing ahead in code faster than the hard drive can finish writing the extracted files to the folder, or something like that. I put in a do while loop to flash a counter in a wait window nowait to see a bit more detail...the counter hits about 250 iterations before VFP can see the extracted DBC (using file() to confirm that the DBC is there. The [/b]do while[/b] loop is a workaround...letting VFP do nothing but count upward until the files are written to disk...but it seems like a kludge. Is there any better way to do this? Any way of running WinExec or ShellExecute and making it wait til the disk writes are complete before sending back the result code (at which point VFP program execution continues)?
Anyway, I thought I'd try using CAB type files as the main storage medium with this app, which will have relatively small numbers of records (perhaps 2000 or so at most) so they will compress pretty fast with CABARC. When the app starts, it extracts all the database files from the CAB into a 'working' folder...when it shuts down, it compresses the files back into the CAB. The user never really knows that his/her data file is actually 33 separate files...he or she can store the single CAB file under any preferred name in any location.
However, I've run into a slight problem...CABARC is faster than my OS/hard drive! I've run the extraction routine with some debug stuff to test what's happening and it appears that WinExec reports back a successful extraction of all files and my app proceeds on to the next few lines of code which open the database...only to report that the DBC doesn't exist. It does however exist in the 'working' folder and if I use a wait window or suspend execution and then click resume in the debugger, all is fine. It seems like VFP is racing ahead in code faster than the hard drive can finish writing the extracted files to the folder, or something like that. I put in a do while loop to flash a counter in a wait window nowait to see a bit more detail...the counter hits about 250 iterations before VFP can see the extracted DBC (using file() to confirm that the DBC is there. The [/b]do while[/b] loop is a workaround...letting VFP do nothing but count upward until the files are written to disk...but it seems like a kludge. Is there any better way to do this? Any way of running WinExec or ShellExecute and making it wait til the disk writes are complete before sending back the result code (at which point VFP program execution continues)?