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

int smbc_stat ( const char *  url,
struct stat *  st 
)

Get information about a file or directory.

Parameters:
url The smb url to get information for
st pointer to a buffer that will be filled with standard Unix struct stat information.
Returns:
0 on success, < 0 on error with errno set:
  • ENOENT A component of the path file_name does not exist.
  • EINVAL a NULL url was passed or smbc_init not called.
  • EACCES Permission denied.
  • ENOMEM Out of memory
  • ENOTDIR The target dir, url, is not a directory.
See also:
Unix stat()

Definition at line 1230 of file libsmbclient.c.

{
      struct smbc_server *srv;
      fstring server, share, user, password, workgroup;
      pstring path;
      time_t m_time = 0, a_time = 0, c_time = 0;
      SMB_BIG_UINT size = 0;
      uint16 mode = 0;
      SMB_INO_T ino = 0;

      if (!smbc_initialized) {

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

      if (!fname) {

            errno = EINVAL;
            return -1;

      }
  
      DEBUG(4, ("smbc_stat(%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 (!smbc_getatr(srv, path, &mode, &size, 
                   &c_time, &a_time, &m_time, &ino)) {

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

      st->st_ino = ino;

      smbc_setup_stat(st, path, size, mode);

      st->st_atime = a_time;
      st->st_ctime = c_time;
      st->st_mtime = m_time;
      st->st_dev   = srv->dev;

      return 0;

}


Generated by  Doxygen 1.6.0   Back to index