Overview
| Artifact ID: | b3e409367f4b0ad64bdfa501440b8faeb21a3557 |
|---|---|
| Ticket: | 1617990fffffffffffffffffffffffffffffffff |
| Date: | 2006-12-18 22:30:06 |
| User: | decosterjos |
| Artifact Attached: | 6de378025402f53a232eff04404be0fa4e95259c |
| Filename: | TclpObjAccess.c |
| Description: |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40/* *--------------------------------------------------------------------------- * * 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; } }
