Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 83313ea7893d22fa3653d752bc3ab766df88c6d604a80249eb79431bf5e94483
Ticket: cc74e50996e20cbb6a851087b36c52eb75526aa4
open command fails with .ext file extension (only)
User & Date: fvogel on 2019-05-12 17:33:46
Changes

  1. comment changed to:
    <verbatim>
    open "E:/tcltk-fossil/tcltk/5 7 8.ext" w    ; # fails: permission denied
    </verbatim>
    
    Changing the file extension to .txt, or .exe, or .zer, or whatever, or removing the extension from the filename, let this command work. It seems to fail with ".ext" file extension only.
    
    This happens on a Windows 10 machine running Tcl as a normal unpriviledged user, however I can read and write files on disk E:\
    
    It does not happen on a Vista machine on which I'm an admin (that said, directory is different).
    
    Investigation in the source code shows that the call (tclWinChan.c: 951):
    
    <verbatim>
        handle = CreateFile(nativeName, accessMode, shareMode,
    	    NULL, createMode, flags, (HANDLE) NULL);
    </verbatim>
    
    returns INVALID_HANDLE_VALUE, indicating failure of file creation.
    
    Arguments of this call are:
    <verbatim>
    nativeName = 0x00b6ccd8 "E:\tcltk-fossil\tcltk\5 7 8.ext"
    accessMode = 1073741824
    shareMode = 3
    createMode = 2
    flags = 128
    </verbatim>
    
    When running:
    <verbatim>
    open "E:/tcltk-fossil/tcltk/5 7 8.txt" w
    </verbatim>
    then the same call succeeds (with the same arguments, except the filename which now has .txt extension instead of .ext).
    
    So the open command may fail just because a filename has .ext extension? That's weird...
    
  2. icomment:
    For the records, I have run into this while investigating Tk test suite failures on that Win10 machine, that do not happen on a Vista machine. For the record, ""E:\tcltk-fossil\tcltk" is the directory returned on that Win10 machine by proc initialdir in winDialog.test, which just returns tcltest::temporaryDirectory.
    
    These failures reported by the Tk test suite are:
    
    <verbatim>
    ==== winDialog-5.7.6 GetFileName: All/extension FAILED
    ==== Contents of test case:
    
        # In 8.6.4 this combination resulted in bar.ext.ext which is bad
        start {set x [tk_getSaveFile -filetypes {{All *}} -defaultextension {ext} -title Save]}
        set msg {}
        then {
    	if {[catch {SetText [vista? 0x47C 0x3e9] bar} msg]} {
    	    Click cancel
    	} else {
    	    Click ok
    	}
        }
        set x "[file tail $x]$msg"
    
    ---- Result was:
    
    ---- Result should have been (exact matching):
    bar.ext
    ==== winDialog-5.7.6 FAILED
    
    
    
    ==== winDialog-5.7.7 tk_getOpenFile: -defaultextension FAILED
    ==== Contents of test case:
    
        unset -nocomplain x
        tcltest::makeFile "" "5 7 7.ext" [initialdir]
        start {set x [tk_getOpenFile  -defaultextension ext  -initialdir [file nativename [initialdir]]  -initialfile "5 7 7" -title Foo]}
        then {
            Click ok
        }
        return $x
    
    ---- Test generated error; Return code was: 1
    ---- Return code should have been one of: 0 2
    ---- errorInfo: couldn't open "E:/tcltk-fossil/tk/win/5 7 7.ext": permission denied
        while executing
    "open $fullName w"
        (procedure "tcltest::makeFile" line 13)
        invoked from within
    "tcltest::makeFile "" "5 7 7.ext" [initialdir]"
        ("uplevel" body line 3)
        invoked from within
    "uplevel 1 $script"
    ---- errorCode: POSIX EACCES {permission denied}
    ==== winDialog-5.7.7 FAILED
    
    initialdir= E:/tcltk-fossil/tk/win
    
    
    ==== winDialog-5.7.8 tk_getOpenFile: -defaultextension FAILED
    ==== Contents of test case:
    
        unset -nocomplain x
    puts "initialdir= [initialdir]"
        tcltest::makeFile "" "5 7 8.ext" [initialdir]
    tk_messageBox
        start {set x [tk_getOpenFile  -defaultextension ext  -initialdir [file nativename [initialdir]]  -initialfile "5 7 8.ext" -title Foo]}
        then {
            Click ok
        }
        return $x
    
    ---- Test generated error; Return code was: 1
    ---- Return code should have been one of: 0 2
    ---- errorInfo: couldn't open "E:/tcltk-fossil/tk/win/5 7 8.ext": permission denied
        while executing
    "open $fullName w"
        (procedure "tcltest::makeFile" line 13)
        invoked from within
    "tcltest::makeFile "" "5 7 8.ext" [initialdir]"
        ("uplevel" body line 4)
        invoked from within
    "uplevel 1 $script"
    ---- errorCode: POSIX EACCES {permission denied}
    ==== winDialog-5.7.8 FAILED
    </verbatim>
    
  3. login: "fvogel"
  4. mimetype: "text/x-fossil-wiki"