Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

int smbc_rmdir ( const char *  durl  ) 

Remove a directory.

Parameters:
durl The smb url of the directory to remove
Returns:
0 on success, < 0 on error with errno set:
  • EACCES or EPERM Write access to the directory containing pathname was not allowed.
  • EINVAL durl is NULL or smbc_init not called.
  • ENOENT A directory component in pathname does not exist.
  • ENOTEMPTY directory contains entries.
  • ENOMEM Insufficient kernel memory was available.
See also:
smbc_mkdir(), smbc_unlink()
Todo:
Are errno values complete and correct?

Definition at line 2141 of file libsmbclient.c.

{
      struct smbc_server *srv;
      fstring server, share, user, password, workgroup;
      pstring path;

      if (!smbc_initialized) {

            errno = EINVAL;
            return -1;

      }

      if (!fname) {

            errno = EINVAL;
            return -1;

      }
  
      DEBUG(4, ("smbc_rmdir(%s)\n", fname));

      smbc_parse_path(fname, server, share, path, user, password); /*FIXME, errors*/

      if (user[0] == (char)0) pstrcpy(user, smbc_user);

      pstrcpy(workgroup, lp_workgroup());

      srv = smbc_server(server, share, workgroup, user, password);

      if (!srv) {

            return -1;  /* errno set by smbc_server */

      }

      /* if (strncmp(srv->cli.dev, "IPC", 3) == 0) {

         mode = aDIR | aRONLY;

         }
         else if (strncmp(srv->cli.dev, "LPT", 3) == 0) {

         if (strcmp(path, "\\") == 0) {

         mode = aDIR | aRONLY;

         }
         else {

         mode = aRONLY;
         smbc_stat_printjob(srv, path, &size, &m_time);
         c_time = a_time = m_time;
         
         }
         else { */

      if (!cli_rmdir(&srv->cli, path)) {

            errno = smbc_errno(&srv->cli);

            if (errno == EACCES) {  /* Check if the dir empty or not */

                  pstring lpath; /* Local storage to avoid buffer overflows */

                  smbc_rmdir_dirempty = True;  /* Make this so ... */

                  pstrcpy(lpath, path);
                  pstrcat(lpath, "\\*");

                  if (cli_list(&srv->cli, lpath, aDIR | aSYSTEM | aHIDDEN, rmdir_list_fn,
                             NULL) < 0) {

                        /* Fix errno to ignore latest error ... */

                        DEBUG(5, ("smbc_rmdir: cli_list returned an error: %d\n", 
                                smbc_errno(&srv->cli)));
                        errno = EACCES;

                  }

                  if (smbc_rmdir_dirempty)
                        errno = EACCES;
                  else
                        errno = ENOTEMPTY;

            }

            return -1;

      } 

      return 0;

}


Generated by  Doxygen 1.6.0   Back to index