Tk
view release on metacpan or search on metacpan
pTk/mTk/tclUnix/tclUnixFCmd.c view on Meta::CPAN
if (result != 0) {
Tcl_AppendResult(interp, "could not read \"",
Tcl_GetString(fileName), "\": ",
Tcl_PosixError(interp), (char *) NULL);
return TCL_ERROR;
}
groupPtr = getgrgid(statBuf.st_gid); /* INTL: Native. */
if (groupPtr == NULL) {
*attributePtrPtr = Tcl_NewIntObj((int) statBuf.st_gid);
} else {
Tcl_DString ds;
CONST char *utf;
utf = Tcl_ExternalToUtfDString(NULL, groupPtr->gr_name, -1, &ds);
*attributePtrPtr = Tcl_NewStringObj(utf, -1);
Tcl_DStringFree(&ds);
}
endgrent();
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* GetOwnerAttribute
*
* Gets the owner attribute of a file.
*
* Results:
* Standard TCL result. Returns a new Tcl_Obj in attributePtrPtr
* if there is no error.
*
* Side effects:
* A new object is allocated.
*
*----------------------------------------------------------------------
*/
static int
GetOwnerAttribute(interp, objIndex, fileName, attributePtrPtr)
Tcl_Interp *interp; /* The interp we are using for errors. */
int objIndex; /* The index of the attribute. */
Tcl_Obj *fileName; /* The name of the file (UTF-8). */
Tcl_Obj **attributePtrPtr; /* A pointer to return the object with. */
{
Tcl_StatBuf statBuf;
struct passwd *pwPtr;
int result;
result = TclpObjStat(fileName, &statBuf);
if (result != 0) {
Tcl_AppendResult(interp, "could not read \"",
Tcl_GetString(fileName), "\": ",
Tcl_PosixError(interp), (char *) NULL);
return TCL_ERROR;
}
pwPtr = getpwuid(statBuf.st_uid); /* INTL: Native. */
if (pwPtr == NULL) {
*attributePtrPtr = Tcl_NewIntObj((int) statBuf.st_uid);
} else {
Tcl_DString ds;
CONST char *utf;
utf = Tcl_ExternalToUtfDString(NULL, pwPtr->pw_name, -1, &ds);
*attributePtrPtr = Tcl_NewStringObj(utf, Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
}
endpwent();
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* GetPermissionsAttribute
*
* Gets the group attribute of a file.
*
* Results:
* Standard TCL result. Returns a new Tcl_Obj in attributePtrPtr
* if there is no error. The object will have ref count 0.
*
* Side effects:
* A new object is allocated.
*
*----------------------------------------------------------------------
*/
static int
GetPermissionsAttribute(interp, objIndex, fileName, attributePtrPtr)
Tcl_Interp *interp; /* The interp we are using for errors. */
int objIndex; /* The index of the attribute. */
Tcl_Obj *fileName; /* The name of the file (UTF-8). */
Tcl_Obj **attributePtrPtr; /* A pointer to return the object with. */
{
Tcl_StatBuf statBuf;
char returnString[7];
int result;
result = TclpObjStat(fileName, &statBuf);
if (result != 0) {
Tcl_AppendResult(interp, "could not read \"",
Tcl_GetString(fileName), "\": ",
Tcl_PosixError(interp), (char *) NULL);
return TCL_ERROR;
}
sprintf(returnString, "%0#5lo", (long) (statBuf.st_mode & 0x00007FFF));
*attributePtrPtr = Tcl_NewStringObj(returnString, -1);
return TCL_OK;
}
/*
*---------------------------------------------------------------------------
( run in 2.955 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )