|
2002-03-24
| ||
| 19:28 | • Closed ticket [511658ffff]: 'file attributes c:/' returns 'hidden 1&... artifact: 202e2d7e1b user: vincentdarley | |
|
2002-03-17
| ||
| 00:33 | • Ticket [511658ffff]: 4 changes artifact: 76e9018ddc user: vincentdarley | |
|
2002-02-05
| ||
| 22:51 | • Ticket [511658ffff]: 4 changes artifact: 9f3645621e user: vincentdarley | |
|
2002-02-01
| ||
| 19:53 | • Ticket [511658ffff]: 4 changes artifact: e56d7c6eff user: vincentdarley | |
| 11:10 | • New ticket [511658ffff]. artifact: 2edc0fe89c user: vincentdarley | |
'file attributes c:/' returns 'hidden 1'
Closed / Fixed511658ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2002-02-01 11:10:01
(On Windows 2000sp2) % file attributes c:/ -archive 1 -hidden 1 -longname C:/ -readonly 0 - shortname C:/ -system 1 % file attributes D:/ -archive 1 -hidden 1 -longname D:/ -readonly 0 - shortname D:/ -system 1 % file attributes E:/ -archive 0 -hidden 0 -longname E:/ -readonly 0 - shortname E:/ -system 0 % file attributes c:/apps -archive 0 -hidden 0 -longname C:/Apps -readonly 0 - shortname C:/Apps -system 0 I would expect all of these to return 'hidden 0'. I have 3 partitions. 'c:' and 'd:' are NTFS and 'e:' is a FAT32 partition. It seems as if 'file attributes -hidden' returns the wrong value for NTFS partitions (but not for directories such as 'c:/apps' which are in NTFS partitions). Some quick debugging shows that: DWORD attr = (*tclWinProcs->getFileAttributesProc) (nativeName); returns 'attr = 54', where 'nativeName' is the native representation of 'c:/'. What is the right way to fix this? It turns out that this is also relevant to fixing another bug (which I'm working on offline), that both 'glob -types hidden c:/' and 'glob c:/' return the same thing. A fix is needed on line 1316 of tclWinFCmd.c (of latest cvs head). The bug exists in Tcl 8.3 as well (from which the above results were taken).
vincentdarleyplain2002-02-01 19:53:49
Logged In: YES user_id=32170 This appears to be a known problem/fact, e.g. http://www.macwindows.com/MacOS85.html contains "If you use the Win32 API GetFIleAttributes on the ROOT directory of an NTFS volume (for example, "e:\"), it always has the FILE_ATTRIBUTE_HIDDEN bit. However, if you use his same API against a subdirectory (say,"e:\myshare"), it will only have this bit set if someone set it.... I believe this is because NTFS uses these bits on the root directory to indicate that the file system is NTFS and not FAT." I'm not sure one can "hide" a root volume on windows, so perhaps what is needed is a check that the path is of the form 'x:/' (or x:\) and then to force the hidden flag to zero? anyone actually know anything about this?, beyond my speculation ;-)
vincentdarleyplain2002-02-05 22:51:10
Logged In: YES
user_id=32170
Using the following definition in tclWinFCmd.c should fix
this:
static int
GetWinFileAttributes(
Tcl_Interp *interp,/* The interp we are using
for errors. */
int objIndex,/* The index of the
attribute. */
Tcl_Obj *fileName, /* The name of the file. */
Tcl_Obj **attributePtrPtr)/* A pointer to return the
object with. */
{
DWORD result;
CONST TCHAR *nativeName;
int attr;
nativeName = Tcl_FSGetNativePath(fileName);
result = (*tclWinProcs->getFileAttributesProc)
(nativeName);
if (result == 0xffffffff) {
StatError(interp, fileName);
return TCL_ERROR;
}
attr = (int)(result & attributeArray[objIndex]);
if ((objIndex == WIN_HIDDEN_ATTRIBUTE) && (attr != 0)) {
/*
* It is hidden. However there is a bug on some
Windows
* OSes in which root volumes (drives) formatted as
NTFS
* are declared hidden when they are not (and
cannot be).
*
* We test for, and fix that case, here.
*/
int len;
char *str = Tcl_GetStringFromObj(fileName,&len);
if (len < 4) {
if (len == 0) {
/*
* Not sure if this is possible, but we
pass it on
* anyway
*/
} else if (len == 1 && (str[0] == '/' || str[0]
== '\\')) {
/* Path is pointing to the root volume */
attr = 0;
} else if ((str[1] == ':') && (len == 2 || (str
[2] == '/' || str[2] == '\\'))) {
/* Path is of the form 'x:' or 'x:/'
or 'x:\' */
attr = 0;
}
}
}
*attributePtrPtr = Tcl_NewBooleanObj(attr);
return TCL_OK;
}
vincentdarleyplain2002-03-17 00:33:31
Logged In: YES user_id=32170 fix included in fix to bug 511666
vincentdarleyplain2002-03-24 19:28:32
Logged In: YES user_id=32170 fixed in cvs head.
Log in (anonymous is fine) to add a comment.