Mercury Bugs - mercury
View Issue Details
0000265mercuryBugpublic2012-11-15 00:302012-12-07 05:44
Assigned To 
PlatformwindowsOSwindows 32/64OS Versionany
Product Version 
Target VersionFixed in Version 
Summary0000265: long path handling in io module
Description"io.file_type" uses "_wstat" in C grade, but *stat didn't support long names on Windows OS (> 260)
It may be fixed by using "FindFirstFileW" with "\\?\" file name prefix instead of "_wstat".

Also, other functions in io module (open_input -> mercury_open -> _wfopen) may be can't handle long path.
Steps To Reproduceunpack test_dir.tar, change path to unpacked directory in bugl program, compile and run
Additional Information:- module bugl.
:- interface.

:- import_module io.

:- pred main(io::di, io::uo) is det.

:- implementation.

:- import_module require, dir, list, bool.

main(!IO) :-
    Ps = (
        pred(DN::in, BN::in, FT::in, C::out, Di::in, Do::out, !.IO::di, !:IO::uo) is det :-
            C = yes,
            io.write_strings([DN, " ", BN, "\n"], !IO),
            Do = Di
    dir.recursive_foldl2(Ps, "C:\\5", no, [], MaybeResult, !IO),
        MaybeResult = error(_, Err),
        error(io.error_message(Err)) % exception
        MaybeResult = ok(_)
TagsNo tags attached.
Attached Filestar test_dir.tar (16,896) 2012-11-15 00:30
diff dir.diff (8,095) 2012-12-07 05:44

2012-12-07 05:44   
(Last edited: 2012-12-07 05:54)
test_dir.tar can be unpacked without errors with with 7-Zip to disk root directory (c:\, d:\ or other).

Also dir.recursive_foldl2 and dir.foldl2 can fail on inaccessible dir (no rights to read files list). Possible fix is to skip inaccessible file or dir (see dir.diff).

Issue History
2012-11-15 00:30gloomdemonNew Issue
2012-11-15 00:30gloomdemonFile Added: test_dir.tar
2012-12-07 05:44gloomdemonNote Added: 0000481
2012-12-07 05:44gloomdemonFile Added: dir.diff
2012-12-07 05:45gloomdemonNote Edited: 0000481bug_revision_view_page.php?bugnote_id=481#r9
2012-12-07 05:54gloomdemonNote Edited: 0000481bug_revision_view_page.php?bugnote_id=481#r10