Page 1 of 1

Trouble with DefineVirtualFile()

Posted: Tue Feb 16, 2010 9:20 pm
by Paolo Canonici
Hi all,
I've some problem using the function DefineVirtualFile(), since I'm not able to write anything yet into my resource file. This is my code snippet:

Code: Select all

virtualFile$ = DefineVirtualFile("dh0:"..filename$, 0, 6, "textfile.txt")
OpenFile(1, virtualFile$)
but it raises an error on the OpenFile saying: "Cannot read file textfile.txt !"

I've also tryed to change the source file location (to point to my work: path), the offset value and the file opening method (write or read), but nothing different happens...

Thanks for any suggestion.
Paolo.

Re: Trouble with DefineVirtualFile()

Posted: Tue Feb 16, 2010 10:49 pm
by Allanon
Hi Paolo,
I've never used virtual files, but I've done a small test:

I've created a resource file from shell with:
Sdb:scui/progetti> echo "TESTING VIRTUAL FILE" > test.txt
Sdb:scui/progetti> echo "SECOND LINE" >> test.txt

Now I will define two virtual file inside my resource file "test.txt"

Code: Select all

vf1 = DefineVirtualFile("Sdb:scui/progetti/Test.txt", 0, 20, "TEST1.TXT")
vf2 = DefineVirtualFile("Sdb:scui/progetti/Test.txt", 21, 32, "TEST2.TXT")
OpenFile(1, vf1)
OpenFile(2, vf2)
l1 = ReadLine(1)
l2 = ReadLine(2)
DebugPrint(l1, l2)
This is a very quick test but has worked fine for me, the DebugPrint has printed:

Code: Select all

TESTING VIRTUAL FILE SECOND LINE
Hope this help

P.S.: I've tried to give an bad resource file (that does not exists) and I've received the error you have reported, maybe you have an error in the resource file location...

Regards,
Fabio.

Re: Trouble with DefineVirtualFile()

Posted: Thu Feb 18, 2010 3:39 pm
by Paolo Canonici
Hi Allanon,
thanks for your reply! Infact I misunderstood the function's capabilities... I thought it could also transparently create and write a file, but obviously I was wrong. ;-)
Now I have done a script to build a resource file containing all the stuff and I'm sure that all the data were correctly stored, since I have tested the inverse operation by extracting a file and this is exactly the same file as the original one.
...but I'm encountering a new issue on wich I am about to post a specific topic in the Bug Report section of the forum. So we'll move over there! :-)

Hi,
Paolo.