summaryrefslogtreecommitdiffstats
path: root/generic/tclIOUtil.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2002-07-08 10:08:57 (GMT)
committervincentdarley <vincentdarley>2002-07-08 10:08:57 (GMT)
commit6cf4fe89feaa9ef6da9ddded6f2199f76d00e73e (patch)
tree44cae45dd1f262fcc31e6d07b240050fb7e44481 /generic/tclIOUtil.c
parent11a54cb010fa27ab006f13181b40da00a4f87550 (diff)
downloadtcl-6cf4fe89feaa9ef6da9ddded6f2199f76d00e73e.zip
tcl-6cf4fe89feaa9ef6da9ddded6f2199f76d00e73e.tar.gz
tcl-6cf4fe89feaa9ef6da9ddded6f2199f76d00e73e.tar.bz2
fs cleanup
Diffstat (limited to 'generic/tclIOUtil.c')
-rw-r--r--generic/tclIOUtil.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index 7b8fdc9..37d9071 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.51 2002/06/26 16:01:09 vincentdarley Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.52 2002/07/08 10:08:57 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -1718,7 +1718,28 @@ Tcl_FSOpenFileChannel(interp, pathPtr, modeString, permissions)
if (fsPtr != NULL) {
Tcl_FSOpenFileChannelProc *proc = fsPtr->openFileChannelProc;
if (proc != NULL) {
- return (*proc)(interp, pathPtr, modeString, permissions);
+ int mode, seekFlag;
+ mode = TclGetOpenMode(interp, modeString, &seekFlag);
+ if (mode == -1) {
+ return NULL;
+ }
+ retVal = (*proc)(interp, pathPtr, mode, permissions);
+ if (retVal != NULL) {
+ if (seekFlag) {
+ if (Tcl_Seek(retVal, (Tcl_WideInt)0,
+ (Tcl_WideInt)SEEK_END) < (Tcl_WideInt)0) {
+ if (interp != (Tcl_Interp *) NULL) {
+ Tcl_AppendResult(interp,
+ "could not seek to end of file while opening \"",
+ Tcl_GetString(pathPtr), "\": ",
+ Tcl_PosixError(interp), (char *) NULL);
+ }
+ Tcl_Close(NULL, retVal);
+ return NULL;
+ }
+ }
+ }
+ return retVal;
}
}
/* File doesn't belong to any filesystem that can open it */