summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclIOUtil.c20
-rw-r--r--tests/fileSystem.test134
3 files changed, 159 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f2148a6..b589fd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-06-26 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ * tests/fileSystem.test:
+ * generic/tclIOUtil.c: fix to handling of empty paths ""
+ which are not claimed by any filesystem (Bug #573758).
+ Ensure good error messages are given in all cases.
+
2002-06-26 Reinhard Max <max@suse.de>
* unix/tclUnixTime.c: Make [clock format] respect locale settings.
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index 041f5b8..7b8fdc9 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.50 2002/06/21 14:22:28 vincentdarley Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.51 2002/06/26 16:01:09 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -1721,6 +1721,13 @@ Tcl_FSOpenFileChannel(interp, pathPtr, modeString, permissions)
return (*proc)(interp, pathPtr, modeString, permissions);
}
}
+ /* File doesn't belong to any filesystem that can open it */
+ Tcl_SetErrno(ENOENT);
+ if (interp != NULL) {
+ Tcl_AppendResult(interp, "couldn't open \"",
+ Tcl_GetString(pathPtr), "\": ",
+ Tcl_PosixError(interp), (char *) NULL);
+ }
return NULL;
}
@@ -1793,6 +1800,7 @@ Tcl_FSMatchInDirectory(interp, result, pathPtr, pattern, types)
* We have no idea how to match files in a directory
* which belongs to no known filesystem
*/
+ Tcl_SetErrno(ENOENT);
return -1;
}
}
@@ -1892,6 +1900,7 @@ Tcl_FSMatchInDirectory(interp, result, pathPtr, pattern, types)
Tcl_DecrRefCount(cwd);
return ret;
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
@@ -2246,6 +2255,7 @@ Tcl_FSFileAttrStrings(pathPtr, objPtrRef)
return (*proc)(pathPtr, objPtrRef);
}
}
+ Tcl_SetErrno(ENOENT);
return NULL;
}
@@ -2286,6 +2296,7 @@ Tcl_FSFileAttrsGet(interp, index, pathPtr, objPtrRef)
return (*proc)(interp, index, pathPtr, objPtrRef);
}
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
@@ -2321,6 +2332,7 @@ Tcl_FSFileAttrsSet(interp, index, pathPtr, objPtr)
return (*proc)(interp, index, pathPtr, objPtr);
}
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
@@ -2591,6 +2603,7 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
}
}
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
@@ -2732,6 +2745,8 @@ Tcl_FSLink(pathPtr, toPtr, linkAction)
*/
#ifndef S_IFLNK
errno = EINVAL;
+#else
+ Tcl_SetErrno(ENOENT);
#endif /* S_IFLNK */
return NULL;
}
@@ -3400,6 +3415,7 @@ Tcl_FSDeleteFile(pathPtr)
return (*proc)(pathPtr);
}
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
@@ -3431,6 +3447,7 @@ Tcl_FSCreateDirectory(pathPtr)
return (*proc)(pathPtr);
}
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
@@ -3540,6 +3557,7 @@ Tcl_FSRemoveDirectory(pathPtr, recursive, errorPtr)
return (*proc)(pathPtr, recursive, errorPtr);
}
}
+ Tcl_SetErrno(ENOENT);
return -1;
}
diff --git a/tests/fileSystem.test b/tests/fileSystem.test
index 897d016..2c44fca 100644
--- a/tests/fileSystem.test
+++ b/tests/fileSystem.test
@@ -253,7 +253,139 @@ test filesystem-5.1 {cache and ~} {
}
-result {{Parent of ~ \(/foo/bar/blah\) is (/foo/bar|foo:bar)} {Parent of ~ \(/a/b/c\) is (/a/b|a:b)}}
}
-
+
+test filesystem-6.1 {empty file name} {
+ list [catch {open ""} msg] $msg
+} {1 {couldn't open "": no such file or directory}}
+
+test filesystem-6.2 {empty file name} {
+ list [catch {file stat "" arr} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.3 {empty file name} {
+ list [catch {file atime ""} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.4 {empty file name} {knownBug} {
+ list [catch {file attributes ""} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.5 {empty file name} {
+ list [catch {file copy "" ""} msg] $msg
+} {1 {error copying "": no such file or directory}}
+
+test filesystem-6.6 {empty file name} {
+ list [catch {file delete ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.7 {empty file name} {
+ list [catch {file dirname ""} msg] $msg
+} {0 .}
+
+test filesystem-6.8 {empty file name} {
+ list [catch {file executable ""} msg] $msg
+} {0 0}
+
+test filesystem-6.9 {empty file name} {
+ list [catch {file exists ""} msg] $msg
+} {0 0}
+
+test filesystem-6.10 {empty file name} {
+ list [catch {file extension ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.11 {empty file name} {
+ list [catch {file isdirectory ""} msg] $msg
+} {0 0}
+
+test filesystem-6.12 {empty file name} {
+ list [catch {file isfile ""} msg] $msg
+} {0 0}
+
+test filesystem-6.13 {empty file name} {
+ list [catch {file join ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.14 {empty file name} {
+ list [catch {file link ""} msg] $msg
+} {1 {could not read link "": no such file or directory}}
+
+test filesystem-6.15 {empty file name} {
+ list [catch {file lstat "" arr} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.16 {empty file name} {
+ list [catch {file mtime ""} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.17 {empty file name} {
+ list [catch {file mtime "" 0} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.18 {empty file name} {
+ list [catch {file mkdir ""} msg] $msg
+} {1 {can't create directory "": no such file or directory}}
+
+test filesystem-6.19 {empty file name} {
+ list [catch {file nativename ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.20 {empty file name} {
+ list [catch {file normalize ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.21 {empty file name} {
+ list [catch {file owned ""} msg] $msg
+} {0 0}
+
+test filesystem-6.22 {empty file name} {
+ list [catch {file pathtype ""} msg] $msg
+} {0 relative}
+
+test filesystem-6.23 {empty file name} {
+ list [catch {file readable ""} msg] $msg
+} {0 0}
+
+test filesystem-6.24 {empty file name} {
+ list [catch {file readlink ""} msg] $msg
+} {1 {could not readlink "": no such file or directory}}
+
+test filesystem-6.25 {empty file name} {
+ list [catch {file rename "" ""} msg] $msg
+} {1 {error renaming "": no such file or directory}}
+
+test filesystem-6.26 {empty file name} {
+ list [catch {file rootname ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.27 {empty file name} {
+ list [catch {file separator ""} msg] $msg
+} {1 {Unrecognised path}}
+
+test filesystem-6.28 {empty file name} {
+ list [catch {file size ""} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.29 {empty file name} {
+ list [catch {file split ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.30 {empty file name} {
+ list [catch {file system ""} msg] $msg
+} {1 {Unrecognised path}}
+
+test filesystem-6.31 {empty file name} {
+ list [catch {file tail ""} msg] $msg
+} {0 {}}
+
+test filesystem-6.32 {empty file name} {
+ list [catch {file type ""} msg] $msg
+} {1 {could not read "": no such file or directory}}
+
+test filesystem-6.33 {empty file name} {
+ list [catch {file writable ""} msg] $msg
+} {0 0}
+
# Make sure the testfilesystem hasn't been registered.
while {![catch {testfilesystem 0}]} {}
}