Tcl Source Code

Check-in [f5ff2ff965]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[Bug 2893771]: file stat fails on locked files on win32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA1: f5ff2ff965803d8399c01d18251a68431d0228b3
User & Date: jan.nijtmans 2013-03-19 13:48:37
Context
2013-03-19
14:31
3597000 Consistent [file copy] result. check-in: 629ee9f78d user: dgp tags: core-8-5-branch
13:57
[Bug 3608360]: Incompatible behaviour of "file exists". check-in: 5567ed9fa5 user: jan.nijtmans tags: trunk
13:48
[Bug 2893771]: file stat fails on locked files on win32. check-in: f5ff2ff965 user: jan.nijtmans tags: core-8-5-branch
13:37
make sure that [file stat] returns the right data, even for locked files. check-in: f92d60cd3d user: jan.nijtmans tags: core-8-4-branch
13:11
Test independence in fCmd.test. check-in: a9c03bc5f2 user: dgp tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2013-03-18  Donal K. Fellows  <[email protected]>

	* tests/cmdAH.test (cmdAH-19.12): [Bug 3608360]: Added test to ensure
	that we never ever allow [file exists] to do globbing.

2013-03-12  Jan Nijtmans  <[email protected]>

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2013-03-19  Jan Nijtmans  <[email protected]>

	* win/tclWinFile.c: [Bug 2893771]: file stat fails on locked files
	on win32.

2013-03-18  Donal K. Fellows  <[email protected]>

	* tests/cmdAH.test (cmdAH-19.12): [Bug 3608360]: Added test to ensure
	that we never ever allow [file exists] to do globbing.

2013-03-12  Jan Nijtmans  <[email protected]>

Changes to tests/fCmd.test.

2534
2535
2536
2537
2538
2539
2540






















2541
2542
2543
2544
2545
2546
2547
} -returnCodes error -match glob -result *

cd [temporaryDirectory]
file delete -force abc.link
file delete -force d1/d2
file delete -force d1
cd [workingDirectory]























removeFile abc2.file
removeFile abc.file
removeDirectory abc2.dir
removeDirectory abc.dir

test fCmd-30.1 {file writable on 'My Documents'} -constraints {win 2000orNewer} -body {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
} -returnCodes error -match glob -result *

cd [temporaryDirectory]
file delete -force abc.link
file delete -force d1/d2
file delete -force d1
cd [workingDirectory]

test fCmd-30.1 {file writable on 'My Documents'} -setup {
    # Get the localized version of the folder name by looking in the registry.
    set mydocsname [registry get {HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders} Personal]
} -constraints {win reg} -body {
    file writable $mydocsname
} -result 1
test fCmd-30.2 {file readable on 'NTUSER.DAT'} -constraints {win} -body {
    expr {[info exists env(USERPROFILE)]
          && [file exists $env(USERPROFILE)/NTUSER.DAT]
          && [file readable $env(USERPROFILE)/NTUSER.DAT]}
} -result {1}
test fCmd-30.3 {file readable on 'pagefile.sys'} -constraints {win} -body {
    set r {}
    if {[info exists env(SystemDrive)]} {
        set path $env(SystemDrive)/pagefile.sys
        lappend r exists [file exists $path]
        lappend r readable [file readable $path]
        lappend r stat [catch {file stat $path a} e] $e
    }
    return $r
} -result {exists 1 readable 0 stat 0 {}}

removeFile abc2.file
removeFile abc.file
removeDirectory abc2.dir
removeDirectory abc.dir

test fCmd-30.1 {file writable on 'My Documents'} -constraints {win 2000orNewer} -body {

Changes to win/tclWinFile.c.

1539
1540
1541
1542
1543
1544
1545
1546
1547
1548


1549
1550

1551
1552
1553
1554
1555
1556
1557
{
    DWORD attr;

    attr = (*tclWinProcs->getFileAttributesProc)(nativePath);

    if (attr == 0xffffffff) {
	/*
	 * File doesn't exist.
	 */



	TclWinConvertError(GetLastError());
	return -1;

    }

    if (mode == F_OK) {
	/*
	 * File exists, nothing else to check.
	 */








|


>
>
|
|
>







1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
{
    DWORD attr;

    attr = (*tclWinProcs->getFileAttributesProc)(nativePath);

    if (attr == 0xffffffff) {
	/*
	 * File might not exist.
	 */

	DWORD lasterror = GetLastError();
	if (lasterror != ERROR_SHARING_VIOLATION) {
	    TclWinConvertError(lasterror);
	    return -1;
	}
    }

    if (mode == F_OK) {
	/*
	 * File exists, nothing else to check.
	 */

2042
2043
2044
2045
2046
2047
2048



2049


2050




2051
2052
2053
2054
2055
2056
2057
	 * Fall back on the less capable routines. This means no nlink or ino.
	 */

	WIN32_FILE_ATTRIBUTE_DATA data;

	if ((*tclWinProcs->getFileAttributesExProc)(nativePath,
		GetFileExInfoStandard, &data) != TRUE) {



	    Tcl_SetErrno(ENOENT);


	    return -1;




	}

	attr = data.dwFileAttributes;

	statPtr->st_size = ((Tcl_WideInt) data.nFileSizeLow) |
		(((Tcl_WideInt) data.nFileSizeHigh) << 32);
	statPtr->st_atime = ToCTime(data.ftLastAccessTime);







>
>
>
|
>
>
|
>
>
>
>







2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
	 * Fall back on the less capable routines. This means no nlink or ino.
	 */

	WIN32_FILE_ATTRIBUTE_DATA data;

	if ((*tclWinProcs->getFileAttributesExProc)(nativePath,
		GetFileExInfoStandard, &data) != TRUE) {
	    HANDLE hFind;
	    WIN32_FIND_DATAT ffd;
	    DWORD lasterror = GetLastError();

	    if (lasterror != ERROR_SHARING_VIOLATION) {
		TclWinConvertError(lasterror);
		return -1;
		}
	    hFind = (*tclWinProcs->findFirstFileProc)(nativePath, &ffd);
	    memcpy(&data, &ffd, sizeof(data));
	    FindClose(hFind);
	}

	attr = data.dwFileAttributes;

	statPtr->st_size = ((Tcl_WideInt) data.nFileSizeLow) |
		(((Tcl_WideInt) data.nFileSizeHigh) << 32);
	statPtr->st_atime = ToCTime(data.ftLastAccessTime);