/* *--------------------------------------------------------------------------- * * TclpObjAccess -- * * This function replaces the library version of access(). * * Results: * See access() documentation + stat() documentation. * * Side effects: * See access() documentation + stat() documentation. * *--------------------------------------------------------------------------- */ int TclpObjAccess( Tcl_Obj *pathPtr, /* Path of file to access */ int mode) /* Permission setting. */ { CONST char *path = Tcl_FSGetNativePath(pathPtr); if (path == NULL) { return -1; } else { int result = access(path, mode); /* For file mounted via NFS, access() may be to liberal */ Tcl_StatBuf buf; int statResult = TclpObjStat(pathPtr, &buf); if (statResult != 0) return -1; if ((mode & R_OK) && ((buf.st_mode & S_IRUSR) == 0)) result = -1; if ((mode & W_OK) && ((buf.st_mode & S_IWUSR) == 0)) result = -1; if ((mode & X_OK) && ((buf.st_mode & S_IXUSR) == 0)) result = -1; return result; } }