#include <unistd.h> int QlgAccess(const Qlg_Path_Name_T *path, int amode);Service Program Name: QP0LLIB1
The QlgAccess() function, like the access() function, determines whether a file can be accessed in a particular manner. The difference is that the QlgAccess() function takes a pointer to a Qlg_Path_Name_T structure, while access() takes a pointer to a character string.
Limited information on the path parameter is provided here. For more information on the path parameter and for a discussion of other parameters, authorities required, return values, and related information, see access()--Determine File Accessibility.
See Code disclaimer information for information pertaining to code examples.
The following example determines how a file is accessed:
#include <stdio.h>
#include <unistd.h>
main()
{
/****************************************************************/
/* Defininitons */
/****************************************************************/
#define mypath "/"
const char US_const[3]= "US";
const char Language_const[4] ="ENU";
typedef struct pnstruct
{
Qlg_Path_Name_T qlg_struct;
char pn[100]; /* This array size must be >= the */
/* length of the path name or this must */
/* be a pointer to the path name. */
};
struct pnstruct path;
/****************************************************************/
/* Initialize Qlg_Path_Name_T parameters */
/****************************************************************/
memset((void*)path name, 0x00, sizeof(struct pnstruct));
path.qlg_struct.CCSID = 37;
memcpy(path.qlg_struct.Country_ID,US_const,2);
memcpy(path.qlg_struct.Language_ID,Language_const,3);
path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
path.qlg_struct.Path_Length = sizeof(mypath)-1;
path.qlg_struct.Path_Name_Delimiter[0] = '/';
memcpy(path.pn,mypath,sizeof(mypath)-1);
if (QlgAccess((Qlg_Path_Name_T *)&path, F_OK) != 0)
printf("'%s' does not exist!\n", mypath);
else {
if (QlgAccess((Qlg_Path_Name_T *)&path, R_OK) == 0)
printf("You have read access to '%s'\n", mypath);
if (QlgAccess((Qlg_Path_Name_T *)&path, W_OK) == 0)
printf("You have write access to '%s'\n", mypath);
if (QlgAccess((Qlg_Path_Name_T *)&path, X_OK) == 0)
printf("You have search access to '%s'\n", mypath);
}
}
Output:
The output from a user with read and execute access is:
You have read access to '/' You have write access to '/' You have search access to '/'
| Top | UNIX-Type APIs | APIs by category |