summaryrefslogtreecommitdiffstats
path: root/generic/tclFCmd.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-27 11:20:55 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-27 11:20:55 (GMT)
commit9dc4d62155a906e3cb7a4d11c2332774d2071d83 (patch)
tree6929ad8d04393f5896cf880f00b93ac8f43551b2 /generic/tclFCmd.c
parent27c1ef5872d95f6f8e442c9258454630bc6489a4 (diff)
downloadtcl-9dc4d62155a906e3cb7a4d11c2332774d2071d83.zip
tcl-9dc4d62155a906e3cb7a4d11c2332774d2071d83.tar.gz
tcl-9dc4d62155a906e3cb7a4d11c2332774d2071d83.tar.bz2
[Bug 3508771] Wrong Tcl_StatBuf used on MinGW
[Bug 2015723] duplicate inodes from file stat on windows
Diffstat (limited to 'generic/tclFCmd.c')
-rw-r--r--generic/tclFCmd.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index 6113cf7..3d6a169 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -516,20 +516,23 @@ CopyRenameOneFile(interp, source, target, copyFlag, force)
goto done;
}
- /*
- * Prevent copying or renaming a file onto itself. Under Windows,
- * stat always returns 0 for st_ino. However, the Windows-specific
- * code knows how to deal with copying or renaming a file on top of
- * itself. It might be a good idea to write a stat that worked.
- */
-
- if ((sourceStatBuf.st_ino != 0) && (targetStatBuf.st_ino != 0)) {
- if ((sourceStatBuf.st_ino == targetStatBuf.st_ino) &&
- (sourceStatBuf.st_dev == targetStatBuf.st_dev)) {
- result = TCL_OK;
- goto done;
- }
- }
+ /*
+ * Prevent copying or renaming a file onto itself. On Windows since
+ * 8.5 we do get an inode number, however the unsigned short field is
+ * insufficient to accept the Win32 API file id so it is truncated to
+ * 16 bits and we get collisions. See bug #2015723.
+ */
+
+#if !defined(WIN32) && !defined(__CYGWIN__)
+ if ((sourceStatBuf.st_ino != 0) && (targetStatBuf.st_ino != 0)) {
+ if ((sourceStatBuf.st_ino == targetStatBuf.st_ino) &&
+ (sourceStatBuf.st_dev == targetStatBuf.st_dev)) {
+ result = TCL_OK;
+ goto done;
+ }
+ }
+#endif
+
/*
* Prevent copying/renaming a file onto a directory and