| Ticket UUID: | 2879351 | ||
| Title: | file writable broken on Windows | ||
| Type: | Bug | Created on: | 2009-10-14 22:41:40 |
| Submitter: | damonc | Assigned to: | aku |
| Subsystem: | 37. File System | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2013-09-24 22:04:22 |
| Status: | Closed | Closed by: | dkf |
| Resolution: | Fixed | Closed on: | 2013-09-24 22:04:22 |
| Version: | obsolete: 8.6b1.1 | ||
| Description: | ||||
This is a dup of bug #2857875, which was closed by SF while I was off having a baby. The following script was run on a Vista 32 bit installation with the given results:
puts "Tcl Version = [info patchlevel]"
set file tmp[pid].txt
foreach dir [list C:/ "C:/Program Files" $::env(LOCALAPPDATA)] {
if {[file writable $dir]} {
puts "$dir is writable"
} else {
puts "$dir is not writable"
}
if {[catch {close [open [file join $dir $file] w]} err]} {
puts "Could not create file in $dir"
} else {
puts "Created file in $dir"
file delete [file join $dir $file]
}
}
Results:
Tcl Version = 8.4.12
C:/ is writable
Could not create file in C:/
C:/Program Files is not writable
Created file in C:/Program Files
C:\Users\vmuser\AppData\Local is writable
Created file in C:\Users\vmuser\AppData\Local
Tcl Version = 8.4.13
C:/ is not writable
Could not create file in C:/
C:/Program Files is not writable
Created file in C:/Program Files
C:\Users\vmuser\AppData\Local is writable
Created file in C:\Users\vmuser\AppData\Local
Tcl Version = 8.6b1.1
C:/ is not writable
Could not create file in C:/
C:/Program Files is not writable
Created file in C:/Program Files
C:\Users\vmuser\AppData\Local is writable
Created file in C:\Users\vmuser\AppData\Local
And, running as Administrator:
Tcl Version = 8.6b1.1
C:/ is writable
Created file in C:/
C:/Program Files is writable
Created file in C:/Program Files
C:\Users\vmuser\AppData\Local is writable
Created file in C:\Users\vmuser\AppData\Local
Please tell me if there's anything else I can test or any other information you need.
| ||||
| User Comments: | ||||
dgp added on 2009-10-15 20:04:07:
Please explain which of those results are what you desire, and which are not. If 8.4.12 is doing the right thing, then as noted before this is a problem introduced by the "fix" to 1193497. The task is to find someone who understands how Tcl connects to the Win filesystems, what bug 1193497 was fixing, how it went wrong and broke things for you, and how a unified solution can cover everyone, if it's even possible. damonc added on 2009-10-15 22:00:11:
The last result, for the latest release, is the most important. Note that while [file writable] SAYS that C:/Program Files is not writable, the user IS able to create a file in there. That is the problem. The rest of the results in the latest release seem to be true. dgp added on 2012-01-14 01:26:45:
The branch 'fix-win-native-access' includes a patch that may fix the bug reported here. http://core.tcl.tk/tcl/info/0aabf0529e I'm not equipped to test the effectiveness of the patch, or whether it introduces any new test failures or other problems. I'd be grateful if folks who can and who are intersted in this bug and related bugs could do so, and report back whether the patch is suitable for merging into the release branches. dgp added on 2012-01-14 01:32:03:
Based on correspondence with the contributor of that
patch, the issue reported here about the directory
c:/Program Files may be a consequence of a feature
of Windows (7?) called VirtualStore which is some
systematic conspiracy to lie to 32bit apps running on
64bit systems (?):
" % file writable {C:\Program Files}
0
% set a [open {C:\Program Files\foo.bar} w]
file5020d8
% puts $a "Hello world!"
% close $a
% exit
C:\>type foo.bar
The system cannot find the file specified.
file writable *correctly* reports that C:\Program Files is not
writable. If a 32-bit app tries to write there anyway, then for
purposes of backward compatibility, Windows (lies and) creates a
shadow directory tree under %HOME%\AppData\Local\VirtualStore\ to
hold user files. These files will appear to be in C:\Program Files
to other 32-bit apps run by the same user, but 64-bit apps or apps
run by other users will not see these files. If the Tcl script is
providing output for other apps, this is bad news. IMO, in this
circumstance the recommendation to avoid file writable and rely on
open is exactly backwards."
dgp added on 2012-02-03 00:41:13:
Patch from fix-win-native-access branch committed for 8.4.20, 8.5.12, and 8.6b3. Continued testing strongly encouraged. In particular, the #define UNICODE variant of the trunk is likely to have some lingering problems. | ||||
