Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG: VFP9 Allows Overwrite of File Opened Non-Exclusively
Message
From
04/06/2004 19:32:48
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Title:
BUG: VFP9 Allows Overwrite of File Opened Non-Exclusively
Miscellaneous
Thread ID:
00910225
Message ID:
00910225
Views:
96
BUG: VFP9 Allows Overwrite of File Opened Non-Exclusively

This was first reported by Michel Fournier for VFP7 and has persisted in VFP8 and now in VFP9. First reported: Is this bug in VFP7 SP1 fixed in VFP8? Thread #732572 Message #732572

Observed behaviour:
An external process can overwrite a table that VFP has opened non-exclusively

Expected behaviour:
An operating system-level error is generated and the file is not overwritten

Environment:
Windows 2000 Professional SP4
Visual FoxPro 9.0 Beta 09.00.0000.1720

Steps to reproduce:
Run the following code in VFP9 and observe the message boxes.
* W2KBugTest.PRG

#DEFINE hcCurrDir		SYS(5) + CURDIR()

MD _Test1
MD _Test2

CREATE TABLE _Test1\Test ;
	(cTest C(10))

INSERT INTO Test ;
	(cTest) ;
	VALUES ;
		("Test 1")

USE IN Test

CREATE TABLE _Test2\Test ;
	(cTest C(10))

INSERT INTO Test ;
	(cTest) ;
	VALUES ;
		("Test 2")

CLOSE DATABASES ALL

SET EXCLUSIVE OFF

USE _Test1\Test

* Try to copy _Test2\Test.dbf over top of _Test1\Test.dbf while the latter is open:

* Following line should fail, because target file is in use:
* Following line DOES fail with EXCLUSIVE OFF or ON, so is commented out here:
*!*	COPY FILE _Test2\Test.DBF TO _Test1\Test.DBF

* Try the File System Object (presumably the same as what underlies Windows Explorer):
loFSO = CREATEOBJECT("Scripting.FileSystemObject")
loFSO.CopyFile(hcCurrDir + "_Test2\Test.dbf", hcCurrDir + "_Test1\Test.dbf")

* Note that the preceding CopyFile call fails if SET EXCLUSIVE is ON

=MESSAGEBOX("Test table _Test1\Test.DBF has been overwritten while open," + CHR(13) + ;
	"but its cTest value is still: " + Test.cTest, ;
	0 + 64 + 0, ;
	"Step 1")

USE IN Test
USE _Test1\Test

=MESSAGEBOX("Test table _Test1\Test.DBF has been closed, and re-opened." + CHR(13) + ;
	"Its cTest value is now: " + Test.cTest, ;
	0 + 64 + 0, ;
	"Step 2")

CLOSE DATABASES ALL

ERASE _Test1\Test.DBF
ERASE _Test2\Test.DBF
RD _Test1
RD _Test2
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Next
Reply
Map
View

Click here to load this message in the networking platform