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

int smbc_unlink ( const char *  furl  ) 

Unlink (delete) a file or directory.

Parameters:
furl The smb url of the file to delete
Returns:
0 on success, < 0 on error with errno set:
  • EACCES or EPERM Write access to the directory containing pathname is not allowed or one of the directories in pathname did not allow search (execute) permission
  • ENOENT A directory component in pathname does not exist
  • EINVAL NULL was passed in the file param or smbc_init not called.
  • EACCES You do not have access to the file
  • ENOMEM Insufficient kernel memory was available
See also:
smbc_rmdir()s
Todo:
Are errno values complete and correct?

Definition at line 907 of file libsmbclient.c.

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

      if (!smbc_initialized) {

            errno = EINVAL;  /* Best I can think of ... */
            return -1;

      }

      if (!fname) {

            errno = EINVAL;
            return -1;

      }

      smbc_parse_path(fname, server, share, path, user, password); /* FIXME, check 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;  /* smbc_server sets errno */

      }

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

    int job = smbc_stat_printjob(srv, path, NULL, NULL);
    if (job == -1) {

      return -1;

    }
    if ((err = cli_printjob_del(&srv->cli, job)) != 0) {

    
      return -1;

    }
    } else */

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

            errno = smbc_errno(&srv->cli);

            if (errno == EACCES) { /* Check if the file is a directory */

                  int saverr = errno;
                  SMB_BIG_UINT size = 0;
                  uint16 mode = 0;
                  time_t m_time = 0, a_time = 0, c_time = 0;
                  SMB_INO_T ino = 0;

                  if (!smbc_getatr(srv, path, &mode, &size,
                               &c_time, &a_time, &m_time, &ino)) {

                        /* Hmmm, bad error ... What? */

                        errno = smbc_errno(&srv->cli);
                        return -1;

                  }
                  else {

                        if (IS_DOS_DIR(mode))
                              errno = EISDIR;
                        else
                              errno = saverr;  /* Restore this */

                  }
            }

            return -1;

      }

      return 0;  /* Success ... */

}


Generated by  Doxygen 1.6.0   Back to index