System.Rewrite and System.Reset silently fail with filenames > MAX_PATH
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
If you use Rewrite/Reset to create, write to and read from files, and the filename is > MAX_PATH characters long, no errors are reported and you can perform operations like read or write on them.
Steps to reproduce:
Build and run attached z.lpr.
It will report that is has created files, written to them and read from them when the filenames > MAX_PATH characters:
...
13 [259]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
14 [260]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
15 [261]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
16 [262]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
17 [263]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
18 [264]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
19 [265]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
20 [266]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
21 [267]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
22 [268]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
23 [269]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
24 [270]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
25 [271]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
OK till , where Length(Fn)=26, this is unlikely since 271 > MAX_PATH (260).
Doing additional check if FileExists(Fn): FALSE
Checking the destination directory shows that only 13 files exist there.
The fully qualified filename of the last file has 255 characters.
Now build and run the application with Delphi (D7 in my case):
Borland Delphi Version 15.0
...
z.lpr(97)
98 lines, 0.05 seconds, 73464 bytes code, 4565 bytes data.
And run:
C:\Users\Bart\LazarusProjecten\bugs\Console\zipper>z
1 [247]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
...
13 [259]: Create=OK, Write=OK, Reset=OK, Read=OK: S="foo"
14 [260]: Create=FAIL
Fail with Length(Fn)=260
Additional information:
Adding Flush(F) after each write operation does not make any difference.
Mantis conversion info:
- Mantis ID: 35292
- OS: Windows
- OS Build: 10
- Build: r41788
- Platform: i386
- Version: 3.3.1
- Monitored by: » @xhajt03 (Tomas Hajny)