Recent

Author Topic: System.Reset does not work with opened files  (Read 2891 times)

anna

  • Sr. Member
  • ****
  • Posts: 426
System.Reset does not work with opened files
« on: October 09, 2013, 06:42:36 pm »
Code: [Select]
var
  f: file;
begin
  //filemode := fmOpenRead;
  system.assign(f,'C:\testfile.dat');
  system.reset(f,1);// <---- here is exeption, if file is already read by third application

  system.close(f);
end;
  But if uncomment filemode := fmOpenRead; all is okey. Why? filemode is used only by sysutils unit, and not by system unit
WinXP SP3 Pro Russian 32-bit (5.1.2600)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: System.Reset does not work with opened files
« Reply #1 on: October 09, 2013, 07:14:28 pm »
...
filemode is used only by sysutils unit, and not by system unit

What makes you think so ?

http://www.freepascal.org/docs-html/rtl/system/filemode.html
Quote
Source position: systemh.inc line 462
const Filemode: Byte = 2;

http://www.freepascal.org/docs-html/rtl/system/reset.html
Quote
Description
Reset opens a file F for reading. F can be any file type. If F is a text file, or refers to standard I/O (e.g : '') then it is opened read-only, otherwise it is opened using the mode specified in filemode.

anna

  • Sr. Member
  • ****
  • Posts: 426
Re: System.Reset does not work with opened files
« Reply #2 on: October 10, 2013, 05:46:38 am »
What makes you think so ?
fmOpenRead declared not in system. Hm-m...
WinXP SP3 Pro Russian 32-bit (5.1.2600)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: System.Reset does not work with opened files
« Reply #3 on: October 10, 2013, 11:34:29 am »
Actually, it's wrong to assign fmOpenRead to FileMode. It's supposed to be assigned with one of the fm* values declared in the system unit as well. The behavior is then undefined.

 

TinyPortal © 2005-2018