#include <unistd.h> int QlgRmdir(Qlg_Path_Name_T *path,);Service Program Name: QP0LLIB1
The QlgRmdir() function, like the rmdir() function, removes a directory, path, provided that the directory is empty; that is, the directory contains no entries other than "dot" (.) or "dot-dot" (..). The difference is that the QlgRmdir() function takes a pointer to a Qlg_Path_Name_T structure, while rmdir() 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 authorities required, return values, usage notes, and related information, see rmdir()--Remove Directory.
See Code disclaimer information for information pertaining to code examples.
The following example removes a directory:
#include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <sys/stat.h> #include <fcntl.h> #include <Qp0lstdi.h> main() { #define mypath_d "new_dir" #define mypath_f "new_dir/new_file" 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 must */ /* be a pointer to the path name. */ }; struct pnstruct path_d; struct pnstruct path_f; int file_descriptor; /***************************************************************/ /* Initialize Qlg_Path_Name_T parameters */ /***************************************************************/ memset((void*)&path_d, 0x00, sizeof(struct pnstruct)); path_d.qlg_struct.CCSID = 37; memcpy(path_d.qlg_struct.Country_ID,US_const,2); memcpy(path_d.qlg_struct.Language_ID,Language_const,3); path_d.qlg_struct.Path_Type = QLG_CHAR_SINGLE; path_d.qlg_struct.Path_Length = sizeof(mypath_d)-1; path_d.qlg_struct.Path_Name_Delimiter[0] = '/'; memcpy(path_d.pn,mypath_d,sizeof(mypath_d)-1); memset((void*)&path_f, 0x00, sizeof(struct pnstruct)); path_f.qlg_struct.CCSID = 37; memcpy(path_f.qlg_struct.Country_ID,US_const,2); memcpy(path_f.qlg_struct.Language_ID,Language_const,3); path_f.qlg_struct.Path_Type = QLG_CHAR_SINGLE; path_f.qlg_struct.Path_Length = sizeof(mypath_f)-1; path_d.qlg_struct.Path_Name_Delimiter[0] = '/'; memcpy(path_f.pn,mypath_f,sizeof(mypath_f)-1); if (QlgMkdir((Qlg_Path_Name_T *)&path_d,S_IRWXU|S_IRGRP|S_IXGRP) ! perror("QlgMkdir() error"); else if ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)&path_f,S_IWUSR)) < perror("QlgCreat() error"); else { close(file_descriptor); QlgUnlink((Qlg_Path_Name_T *)&path_f); } if (QlgRmdir((Qlg_Path_Name_T *)&path_d) != 0) perror("QlgRmdir() error"); else puts("removed!"); }
Top | UNIX-Type APIs | APIs by category |