#define TCL_GLOB_TYPE_MOUNT (1<<7)
#endif
+/*
+ * tclvfs will return this code instead of TCL_OK/ERROR/etc. to propagate
+ * through the Tcl_Eval* calls to indicate a posix error has been raised by
+ * some vfs implementation. -1 is what Tcl expects, adopts from posix's
+ * standard error value.
+ */
+#define TCLVFS_POSIXERROR -1
+
#ifndef CONST86
#define CONST86
#endif
return TCL_ERROR;
}
Tcl_SetErrno(posixError);
- return -1;
+ /*
+ * This special error code propagate to the Tcl_Eval* calls in
+ * other parts of the vfs C code to indicate a posix error
+ * being raised by some vfs implementation.
+ */
+ return TCLVFS_POSIXERROR;
}
case VFS_NORMALIZE: {
Tcl_Obj *path;
* internal representation for a vfs path.
*
* Results:
- * Returns TCL_OK on success, or '-1' on failure. If Tcl is
- * exiting, we always return a failure code.
+ * Returns TCL_OK on success, or 'TCLVFS_POSIXERROR' on failure.
+ * If Tcl is exiting, we always return a failure code.
*
* Side effects:
* On success, we allocate some memory for our internal
* in the middle of the exit sequence. We could perhaps be
* more subtle than this!
*/
- return -1;
+ return TCLVFS_POSIXERROR;
}
normedObj = Tcl_FSGetNormalizedPath(NULL, pathPtr);
if (normedObj == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
normed = Tcl_GetStringFromObj(normedObj, &len);
splitPosition = len;
* must return then.
*/
if (splitPosition == 0) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
/* Is the path up to 'splitPosition' a valid moint point? */
* We've reached the beginning of the string without
* finding a mount, so we've failed.
*/
- return -1;
+ return TCLVFS_POSIXERROR;
}
}
mountCmd = VfsBuildCommandForPath(&interp, "stat", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
Tcl_SaveResult(interp, &savedResult);
}
}
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
Tcl_RestoreResult(interp, &savedResult);
Tcl_DecrRefCount(mountCmd);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
Tcl_SetErrno(ENOENT);
- return -1;
+ return TCLVFS_POSIXERROR;
} else {
return returnVal;
}
mountCmd = VfsBuildCommandForPath(&interp, "access", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewIntObj(mode));
Tcl_SaveResult(interp, &savedResult);
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
Tcl_RestoreResult(interp, &savedResult);
if (returnVal != 0) {
Tcl_SetErrno(ENOENT);
- return -1;
+ return TCLVFS_POSIXERROR;
} else {
return returnVal;
}
} else {
/* Leave an error message if the cmdInterp is non NULL */
if (cmdInterp != NULL) {
- if (returnVal == -1) {
+ if (returnVal == TCLVFS_POSIXERROR) {
Tcl_ResetResult(cmdInterp);
Tcl_AppendResult(cmdInterp, "couldn't open \"",
Tcl_GetString(pathPtr), "\": ",
}
} else {
/* Report any error, since otherwise it is lost */
- if (returnVal != -1) {
+ if (returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
}
mountCmd = VfsBuildCommandForPath(&interp, "matchindirectory", dirPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
if (types != NULL) {
/* Now we execute this mount point's callback. */
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != -1) {
+ if (returnVal != TCLVFS_POSIXERROR) {
vfsResultPtr = Tcl_DuplicateObj(Tcl_GetObjResult(interp));
}
Tcl_RestoreResult(interp, &savedResult);
mountCmd = VfsBuildCommandForPath(&interp, "deletefile", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
/* Now we execute this mount point's callback. */
Tcl_SaveResult(interp, &savedResult);
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
Tcl_RestoreResult(interp, &savedResult);
mountCmd = VfsBuildCommandForPath(&interp, "createdirectory", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
/* Now we execute this mount point's callback. */
Tcl_SaveResult(interp, &savedResult);
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
Tcl_RestoreResult(interp, &savedResult);
mountCmd = VfsBuildCommandForPath(&interp, "removedirectory", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewIntObj(recursive));
Tcl_SaveResult(interp, &savedResult);
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
Tcl_RestoreResult(interp, &savedResult);
/* Now we execute this mount point's callback. */
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
if (returnVal == TCL_OK) {
mountCmd = VfsBuildCommandForPath(&interp, "fileattributes", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewIntObj(index));
/* Now we execute this mount point's callback. */
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != -1) {
+ if (returnVal != TCLVFS_POSIXERROR) {
*objPtrRef = Tcl_DuplicateObj(Tcl_GetObjResult(interp));
}
Tcl_RestoreResult(interp, &savedResult);
Tcl_DecrRefCount(mountCmd);
- if (returnVal != -1) {
+ if (returnVal != TCLVFS_POSIXERROR) {
if (returnVal == TCL_OK) {
/*
* Our caller expects a ref count of zero in
mountCmd = VfsBuildCommandForPath(&interp, "fileattributes", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewIntObj(index));
/* Now we execute this mount point's callback. */
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != -1 && returnVal != TCL_OK) {
+ if (returnVal != TCLVFS_POSIXERROR && returnVal != TCL_OK) {
errorPtr = Tcl_DuplicateObj(Tcl_GetObjResult(interp));
}
Tcl_DecrRefCount(mountCmd);
if (cmdInterp != NULL) {
- if (returnVal == -1) {
+ if (returnVal == TCLVFS_POSIXERROR) {
Tcl_ResetResult(cmdInterp);
Tcl_AppendResult(cmdInterp, "couldn't set attributes for \"",
Tcl_GetString(pathPtr), "\": ",
mountCmd = VfsBuildCommandForPath(&interp, "utime", pathPtr);
if (mountCmd == NULL) {
- return -1;
+ return TCLVFS_POSIXERROR;
}
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewLongObj(tval->actime));
Tcl_SaveResult(interp, &savedResult);
returnVal = Tcl_EvalObjEx(interp, mountCmd,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
- if (returnVal != TCL_OK && returnVal != -1) {
+ if (returnVal != TCL_OK && returnVal != TCLVFS_POSIXERROR) {
VfsInternalError(interp);
}
Tcl_RestoreResult(interp, &savedResult);