summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixChan.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-09-17 14:13:14 (GMT)
committersebres <sebres@users.sourceforge.net>2024-09-17 14:13:14 (GMT)
commit18ed5377e67970c87daf0c2d6f0fee40e4744582 (patch)
treebbdc161b100a086dd602eaf2b6b08bfe48a3e2ca /unix/tclUnixChan.c
parente5dcd8f739b96df18f98713d33b39c963c435bbd (diff)
parentf2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c (diff)
downloadtcl-18ed5377e67970c87daf0c2d6f0fee40e4744582.zip
tcl-18ed5377e67970c87daf0c2d6f0fee40e4744582.tar.gz
tcl-18ed5377e67970c87daf0c2d6f0fee40e4744582.tar.bz2
merge bug-02d5d65d70adab97: avoid unneeded (but expensive) path normalization for several file subsystem commands and operations;
closes [02d5d65d70adab97]
Diffstat (limited to 'unix/tclUnixChan.c')
-rw-r--r--unix/tclUnixChan.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 1844a23..e072cd7 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -12,6 +12,7 @@
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
+#include "tclFileSystem.h"
#include "tclIO.h" /* To get Channel type declaration. */
#undef SUPPORTS_TTY
@@ -1418,6 +1419,24 @@ TclpOpenFileChannel(
native = (const char *)Tcl_FSGetNativePath(pathPtr);
if (native == NULL) {
if (interp != (Tcl_Interp *) NULL) {
+ /*
+ * We need this just to ensure we return the correct error messages under
+ * some circumstances (relative paths only), so because the normalization
+ * is very expensive, don't invoke it for native or absolute paths.
+ */
+ if (
+ (
+ (
+ !TclFSCwdIsNative() &&
+ (Tcl_FSGetPathType(pathPtr) != TCL_PATH_ABSOLUTE)
+ ) ||
+ (*TclGetString(pathPtr) == '~') /* possible tilde expansion */
+ ) &&
+ Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL
+ ) {
+ return NULL;
+ }
+
Tcl_AppendResult(interp, "couldn't open \"",
TclGetString(pathPtr), "\": filename is invalid on this platform",
(char *)NULL);