Recent

Author Topic: Reset doesn't open ReadOnly file  (Read 631 times)

fxeconomist

  • Jr. Member
  • **
  • Posts: 67
Reset doesn't open ReadOnly file
« on: March 05, 2026, 05:21:19 pm »
I am having all these code issues because I'm writing an installer for a Freelancer mod that was lost a zillion years ago.

And I noticed. I updated my code but it feels kinda funny.

Whenever I try to open a readonly file with Reset, it gets Access Denied error.

Sure, I am adding now lines to get rid of the attribute, but why do I have to do that ?

ASerge

  • Hero Member
  • *****
  • Posts: 2481
Re: Reset doesn't open ReadOnly file
« Reply #1 on: March 05, 2026, 05:39:50 pm »
Whenever I try to open a readonly file with Reset, it gets Access Denied error.
Try System.FileMode := 0; before Reset.

fxeconomist

  • Jr. Member
  • **
  • Posts: 67
Re: Reset doesn't open ReadOnly file
« Reply #2 on: March 05, 2026, 06:13:21 pm »
Whenever I try to open a readonly file with Reset, it gets Access Denied error.
Try System.FileMode := 0; before Reset.

Now why did they have to do that, it was known since the times of yore that Reset opens only for reading...

ASerge

  • Hero Member
  • *****
  • Posts: 2481
Re: Reset doesn't open ReadOnly file
« Reply #3 on: March 05, 2026, 07:20:06 pm »
Now why did they have to do that, it was known since the times of yore that Reset opens only for reading...
Read the help for this variable. The read/write is not the same as the read-only.

tetrastes

  • Hero Member
  • *****
  • Posts: 761
Re: Reset doesn't open ReadOnly file
« Reply #4 on: March 05, 2026, 07:38:27 pm »
Now why did they have to do that, it was known since the times of yore that Reset opens only for reading...

https://www.freepascal.org/docs-html/current/rtl/system/reset.html
Quote
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.

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: Reset doesn't open ReadOnly file
« Reply #5 on: March 05, 2026, 09:29:24 pm »
I am having all these code issues because I'm writing an installer for a Freelancer mod that was lost a zillion years ago.
In that case it might be useful to also have a look at the class TFileStream and the CopyFile(...) function.
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

 

TinyPortal © 2005-2018