View Issue Details

IDProjectCategoryView StatusLast Update
0032939FPCDocumentationpublic2018-01-13 11:45
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSdebian OS VersionJessie
Product Version3.1.1Product Build37880 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032939: File IO Assign works with exxtremely long paths, but rewrite/rest fails
DescriptionClassic File IO behaves erratic:
Assign can handle paths > 255, but subsequent operations fail
Steps To Reproduceprogram q;
{$H+}{$I-}
uses Sysutils;
var
        F: File Of byte;
        path: ansistring;
begin
        path:='/tmp/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/';
        forcedirectories(path);
        path := path+'test.txt';
        WriteLn ('Opening ',path);
        Assign (F,path);
        if IOResult = 0 then writeln('Assign works') else writeln('Assign does not work');
        Reset (F);
        if IOResult = 0 then writeln('Reset works') else writeln('Reset does not work');
        Close (F);
        if IOResult = 0 then writeln('Close works') else writeln('Close does not work');

end.
 
TagsNo tags attached.
Fixed in Revision1455
FPCOldBugId
FPCTarget
Attached Files

Activities

Thaddy de Koning

2018-01-03 10:07

reporter   ~0105279

Last edited: 2018-01-03 10:10

View 2 revisions

I am fine with documenting it if there is a short path limitation. The path length is silly.

Both rewrite and reset fail. Does not matter if there is a file or not.

Jonas Maebe

2018-01-04 08:51

manager   ~0105311

FWIW, Assign doesn't return an error because Assign cannot return any errors. Compare the "Errors" section of https://www.freepascal.org/docs-html/current/rtl/system/assign.html and, e.g., https://www.freepascal.org/docs-html/current/rtl/system/reset.html

The maximum file name length for standard IO is indeed 256 characters.

Thaddy de Koning

2018-01-04 09:09

reporter   ~0105313

Last edited: 2018-01-04 09:47

View 6 revisions

Yes I missed "Assign assigns a name to F, which can be any file type. This call doesn't open the file, it just assigns a name to a file variable, and marks the file as closed."

Maybe move to documentation? There is a workaround available by changing directory:
program q;
{$H+}{$I-}
uses Sysutils;
var
        F: File Of byte;
        Oldpath,Path,Filename: ansistring;
begin
        OldPath :=GetCurrentDir;
        path:='/tmp/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/';
        forcedirectories(path);
        SetCurrentDir(path);
        Filename := 'test.txt';
        WriteLn ('Opening ',Filename);
        Assign (F,Filename); // Does not set IOResult
        Rewrite (F);
        if IOResult = 0 then writeln('Rewrite works') else writeln('Rewrite does not work');
        Close (F);
        if IOResult = 0 then writeln('Close works') else writeln('Close does not work');
        SetCurrentDir(OldPath);
end.

Michael Van Canneyt

2018-01-13 11:45

administrator   ~0105736

Documented in Reset/Rewrite/Assign calls.

Issue History

Date Modified Username Field Change
2018-01-03 10:05 Thaddy de Koning New Issue
2018-01-03 10:07 Thaddy de Koning Note Added: 0105279
2018-01-03 10:10 Thaddy de Koning Note Edited: 0105279 View Revisions
2018-01-04 08:51 Jonas Maebe Note Added: 0105311
2018-01-04 09:09 Thaddy de Koning Note Added: 0105313
2018-01-04 09:09 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-01-04 09:09 Michael Van Canneyt Status new => assigned
2018-01-04 09:10 Michael Van Canneyt Category RTL => Documentation
2018-01-04 09:15 Thaddy de Koning Note Edited: 0105313 View Revisions
2018-01-04 09:33 Thaddy de Koning Note Edited: 0105313 View Revisions
2018-01-04 09:33 Thaddy de Koning Note Edited: 0105313 View Revisions
2018-01-04 09:47 Thaddy de Koning Note Edited: 0105313 View Revisions
2018-01-04 09:47 Thaddy de Koning Note Edited: 0105313 View Revisions
2018-01-13 11:45 Michael Van Canneyt Fixed in Revision => 1455
2018-01-13 11:45 Michael Van Canneyt Note Added: 0105736
2018-01-13 11:45 Michael Van Canneyt Status assigned => resolved
2018-01-13 11:45 Michael Van Canneyt Fixed in Version => 3.1.1
2018-01-13 11:45 Michael Van Canneyt Resolution open => fixed
2018-01-13 11:45 Michael Van Canneyt Target Version => 3.2.0