QlgRmdir()--Remove Directory (using NLS-enabled path name)


  Syntax
 #include <unistd.h>

 int QlgRmdir(Qlg_Path_Name_T *path,);  

  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for rmdir().

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 about the path parameter is provided here. For more information about the path parameter and for a discussion of authorities required, return values, usage notes, and related information, see rmdir()--Remove Directory.


Parameters

path
(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name or a pointer to a path name of the directory to be removed. For more information about the Qlg_Path_Name_T structure, see Path name format.

Related Information


Example

The following example removes a directory.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#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) != 0)
    perror("QlgMkdir() error");
  else if ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)&path_f,S_IWUSR)) < 0)
    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!");
}

API introduced: V5R1

[ Back to top | UNIX-Type APIs | APIs by category ]