Tcl Source Code

View Ticket
Login
Ticket UUID: 2893771
Title: file stat fails on locked files on win32
Type: Bug Version: obsolete: 8.6b1
Submitter: patthoyts Created on: 2009-11-07 10:21:21
Subsystem: 37. File System Assigned To: nijtmans
Priority: 6 Severity:
Status: Closed Last Modified: 2013-03-19 21:26:34
Resolution: Fixed Closed By: nijtmans
    Closed on: 2013-03-19 14:26:34
Description:
On Windows the page file c:\pagefile.sys is always open and locked. In NativeAccess we try using GetFileAttributes but this will return ERROR_SHARING_VIOLATION and -1, leading Tcl to believe the file does not exist. Similar code is in NativeStat fails for the same reason. So we cannot currently test for the existence or size or mtime for this file. However if we then try FindFirstFile for the pathname we can get this information even though the file is in use.
The attached patch tries FindFirstFile when GetFIleAttributes fails. GFA is a bit faster on my system than FFF so I prefer to only try this when necessary. I've not checked for the GetLastError() code as well as I don't know if other error codes might still be appropriate for continuing to check using FFF.
User Comments: nijtmans added on 2013-03-19 21:26:34:

allow_comments - 1

Fixed now on all branches.

nijtmans added on 2013-03-19 19:03:40:
I would prefer another solution for this problem. If GetFileAttributes() returns
ERROR_SHARING_VIOLATION, then we know that the file exists but
is not readable and not writable. Let's thread that as a special case.

nijtmans added on 2013-03-19 18:50:19:

allow_comments - 0

Had to back out this patch, because of bug [3608360]: Incompatible behaviour of "file exists".

patthoyts added on 2009-11-24 07:08:50:

allow_comments - 1

I have applied this patch with a new test to the HEAD 8.6 code.

patthoyts added on 2009-11-07 17:21:23:

File Added - 349887: file-stat.patch

Attachments: