On Fri, 2 Apr 2004, Frank Heckenbach wrote:
Emil Jerabek wrote:
On Fri, Apr 02, 2004 at 12:59:30PM +0200, Frank Heckenbach wrote:
Hi,
there's a strange case when using relative file names and changing the directory. (Incidentally I was made aware of this by a bugfix in the ncurses library (C code) some while ago ... ;-) Consider this program:
program Foo;
var i: Integer; f: Text;
begin Assign (f, 'test.dat'); Rewrite (f); WriteLn (f, 42); Close (f); ChDir ('..'); Reset (f); ReadLn (f, i); WriteLn (i) end.
It fails under both GPC and BP because `Reset' tries to open a file `test.dat' in a different directory than it was created.
Actually, under gpc it works exactly as I would expect it to work. (To try it under BP I would have to setup the old computer). I can have two different files having the same name as long as they are in different directories.
As a test, changed 42 to 123 and compiled, ran. Got an error message as expected. Next, "mv test.dat .. " Then changed 123 back to 42, comiled, ran. Got 123 and no error message.
Russ