Directory Functions
[Libsmbclient]

Functions used to access directory entries [詳細]

関数

int smbc_unlink (const char *furl)
 Unlink (delete) a file or directory.
int smbc_rename (const char *ourl, const char *nurl)
 Rename or move a file or directory.
int smbc_opendir (const char *durl)
 Open a directory used to obtain directory entries.
int smbc_closedir (int dh)
 Close a directory handle opened by smbc_opendir().
int smbc_getdents (unsigned int dh, struct smbc_dirent *dirp, int count)
 Get multiple directory entries.
smbc_direntsmbc_readdir (unsigned int dh)
 Get a single directory entry.
off_t smbc_telldir (int dh)
 Get the current directory offset.
int smbc_lseekdir (int fd, off_t offset)
 lseek on directories.
int smbc_mkdir (const char *durl, mode_t mode)
 Create a directory.
int smbc_rmdir (const char *durl)
 Remove a directory.
int smbc_urldecode (char *dest, char *src, size_t max_dest_len)
 Convert strings of xx to their single character equivalent.
const char * smbc_version (void)
 Return the version of the linked Samba code, and thus the version of the libsmbclient code.

説明

Functions used to access directory entries


関数

int smbc_unlink ( const char *  furl  ) 

Unlink (delete) a file or directory.

引数:
furl The smb url of the file to delete
戻り値:
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
参照:
smbc_rmdir()s
TODO:
Are errno values complete and correct?

libsmb_compat.c215 行で定義されています。

参照先 statcont_SMBCCTX::unlink.

00216 {
00217         return (statcont->unlink)(statcont, fname);
00218 }

int smbc_rename ( const char *  ourl,
const char *  nurl 
)

Rename or move a file or directory.

引数:
ourl The original smb url (source url) of file or directory to be moved
nurl The new smb url (destination url) of the file or directory after the move. Currently nurl must be on the same share as ourl.
戻り値:
0 on success, < 0 on error with errno set:
  • EISDIR nurl is an existing directory, but ourl is not a directory.
  • EEXIST nurl is a non-empty directory, i.e., contains entries other than "." and ".."
  • EINVAL The new url contained a path prefix of the old, or, more generally, an attempt was made to make a directory a subdirectory of itself or smbc_init not called.
  • ENOTDIR A component used as a directory in ourl or nurl path is not, in fact, a directory. Or, ourl is a directory, and newpath exists but is not a directory.
  • EACCES or EPERM Write access to the directory containing ourl or nurl is not allowed for the process's effective uid, or one of the directories in ourl or nurl did not allow search (execute) permission, or ourl was a directory and did not allow write permission.
  • ENOENT A directory component in ourl or nurl does not exist.
  • EXDEV Rename across shares not supported.
  • ENOMEM Insufficient kernel memory was available.
  • EEXIST The target file, nurl, already exists.
TODO:
Are we going to support copying when urls are not on the same share? I say no... NOTE. I agree for the moment.

libsmb_compat.c220 行で定義されています。

参照先 _SMBCCTX::renamestatcont.

参照元 cmd_rename().

00221 {
00222         return (statcont->rename)(statcont, ourl, statcont, nurl);
00223 }

int smbc_opendir ( const char *  durl  ) 

Open a directory used to obtain directory entries.

引数:
durl The smb url of the directory to open
戻り値:
Valid directory handle. < 0 on error with errno set:
  • EACCES Permission denied.
  • EINVAL A NULL file/URL was passed, or the URL would not parse, or was of incorrect form or smbc_init not called.
  • ENOENT durl does not exist, or name is an
  • ENOMEM Insufficient memory to complete the operation.
  • ENOTDIR name is not a directory.
  • EPERM the workgroup could not be found.
  • ENODEV the workgroup or server could not be found.
参照:
smbc_getdents(), smbc_readdir(), smbc_closedir()

libsmb_compat.c225 行で定義されています。

参照先 add_fd()_SMBCCTX::closedirfdsmbc_compat_fdlist::file_SMBCCTX::opendirstatcont.

参照元 cb_itemsignal()cb_select_child()cb_wholenet()cmd_mkdir()do_cd()main()smb_download_dir()tool_list().

00226 {
00227         SMBCFILE * file;
00228         int fd;
00229 
00230         file = (statcont->opendir)(statcont, durl);
00231         if (!file)
00232                 return -1;
00233 
00234         fd = add_fd(file);
00235         if (fd == -1) 
00236                 (statcont->closedir)(statcont, file);
00237 
00238         return fd;
00239 }

int smbc_closedir ( int  dh  ) 

Close a directory handle opened by smbc_opendir().

引数:
dh Directory handle to close
戻り値:
0 on success, < 0 on error with errno set:
  • EBADF dh is an invalid directory handle
参照:
smbc_opendir()

libsmb_compat.c241 行で定義されています。

参照先 _SMBCCTX::closedirdel_fd()smbc_compat_fdlist::filefind_fd()statcont.

参照元 cb_itemsignal()cb_wholenet()cmd_mkdir()do_cd()main()smb_download_dir()tool_list().

00242 {
00243         SMBCFILE * file = find_fd(dh);
00244         del_fd(dh);
00245         return (statcont->closedir)(statcont, file);
00246 }

int smbc_getdents ( unsigned int  dh,
struct smbc_dirent dirp,
int  count 
)

Get multiple directory entries.

smbc_getdents() reads as many dirent structures from the an open directory handle into a specified memory area as will fit.

引数:
dh Valid directory as returned by smbc_opendir()
dirp pointer to buffer that will receive the directory entries.
count The size of the dirp buffer in bytes
戻り値:
If any dirents returned, return will indicate the total size. If there were no more dirents available, 0 is returned. < 0 indicates an error.
  • EBADF Invalid directory handle
  • EINVAL Result buffer is too small or smbc_init not called.
  • ENOENT No such directory.
参照:
, smbc_dirent, smbc_readdir(), smbc_open()
TODO:
Are errno values complete and correct?
TODO:
Add example code so people know how to parse buffers.

libsmb_compat.c248 行で定義されています。

参照先 smbc_compat_fdlist::filefind_fd()_SMBCCTX::getdentsstatcont.

参照元 cb_itemsignal()cb_select_child()cb_wholenet()main().

00249 {
00250         SMBCFILE * file = find_fd(dh);
00251         return (statcont->getdents)(statcont, file,dirp, count);
00252 }

struct smbc_dirent* smbc_readdir ( unsigned int  dh  ) 

Get a single directory entry.

引数:
dh Valid directory as returned by smbc_opendir()
戻り値:
A pointer to a smbc_dirent structure, or NULL if an error occurs or end-of-directory is reached:
  • EBADF Invalid directory handle
  • EINVAL smbc_init() failed or has not been called
参照:
smbc_dirent, smbc_getdents(), smbc_open()

libsmb_compat.c254 行で定義されています。

参照先 find_fd()_SMBCCTX::readdirstatcont.

参照元 smb_download_dir()tool_list().

00255 {
00256         SMBCFILE * file = find_fd(dh);
00257         return (statcont->readdir)(statcont, file);
00258 }

off_t smbc_telldir ( int  dh  ) 

Get the current directory offset.

smbc_telldir() may be used in conjunction with smbc_readdir() and smbc_lseekdir().

引数:
dh Valid directory as returned by smbc_opendir()
戻り値:
The current location in the directory stream or -1 if an error occur. The current location is not an offset. Becuase of the implementation, it is a handle that allows the library to find the entry later.
  • EBADF dh is not a valid directory handle
  • EINVAL smbc_init() failed or has not been called
  • ENOTDIR if dh is not a directory
参照:
smbc_readdir()

libsmb_compat.c260 行で定義されています。

参照先 find_fd()statcont_SMBCCTX::telldir.

00261 {
00262         SMBCFILE * file = find_fd(dh);
00263         return (statcont->telldir)(statcont, file);
00264 }

int smbc_lseekdir ( int  fd,
off_t  offset 
)

lseek on directories.

smbc_lseekdir() may be used in conjunction with smbc_readdir() and smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))

引数:
fd Valid directory as returned by smbc_opendir()
offset The offset (as returned by smbc_telldir). Can be NULL, in which case we will rewind
戻り値:
0 on success, -1 on failure
  • EBADF dh is not a valid directory handle
  • ENOTDIR if dh is not a directory
  • EINVAL offset did not refer to a valid dirent or smbc_init not called.
参照:
smbc_telldir()
TODO:
In what does the reture and errno values mean?

libsmb_compat.c266 行で定義されています。

参照先 find_fd()_SMBCCTX::lseekdirstatcont.

00267 {
00268         SMBCFILE * file = find_fd(fd);
00269         return (statcont->lseekdir)(statcont, file, offset);
00270 }

int smbc_mkdir ( const char *  durl,
mode_t  mode 
)

Create a directory.

引数:
durl The url of the directory to create
mode Specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask).
戻り値:
0 on success, < 0 on error with errno set:
  • EEXIST directory url already exists
  • EACCES The parent directory does not allow write permission to the process, or one of the directories
  • ENOENT A directory component in pathname does not exist.
  • EINVAL NULL durl passed or smbc_init not called.
  • ENOMEM Insufficient memory was available.
参照:
smbc_rmdir()

libsmb_compat.c272 行で定義されています。

参照先 _SMBCCTX::mkdirstatcont.

参照元 cmd_mput()do_mkdir().

00273 {
00274         return (statcont->mkdir)(statcont, durl, mode);
00275 }

int smbc_rmdir ( const char *  durl  ) 

Remove a directory.

引数:
durl The smb url of the directory to remove
戻り値:
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.
参照:
smbc_mkdir(), smbc_unlink()
TODO:
Are errno values complete and correct?

libsmb_compat.c277 行で定義されています。

参照先 _SMBCCTX::rmdirstatcont.

参照元 cmd_rmdir().

00278 {
00279         return (statcont->rmdir)(statcont, durl);
00280 }

int smbc_urldecode ( char *  dest,
char *  src,
size_t  max_dest_len 
)

Convert strings of xx to their single character equivalent.

引数:
dest A pointer to a buffer in which the resulting decoded string should be placed. This may be a pointer to the same buffer as src_segment.
src A pointer to the buffer containing the URL to be decoded. Any xx sequences herein are converted to their single character equivalent. Each 'x' must be a valid hexadecimal digit, or that % sequence is left undecoded.
max_dest_len The size of the buffer pointed to by dest_segment.
戻り値:
The number of % sequences which could not be converted due to lack of two following hexadecimal digits.

libsmbclient.c146 行で定義されています。

参照先 hex2int().

参照元 smbc_parse_path().

00147 {
00148         int old_length = strlen(src);
00149         int i = 0;
00150         int err_count = 0;
00151         pstring temp;
00152         char * p;
00153 
00154         if ( old_length == 0 ) {
00155                 return 0;
00156         }
00157 
00158         p = temp;
00159         while ( i < old_length ) {
00160                 unsigned char character = src[ i++ ];
00161 
00162                 if (character == '%') {
00163                         int a = i+1 < old_length ? hex2int( src[i] ) : -1;
00164                         int b = i+1 < old_length ? hex2int( src[i+1] ) : -1;
00165 
00166                         /* Replace valid sequence */
00167                         if (a != -1 && b != -1) {
00168 
00169                                 /* Replace valid %xx sequence with %dd */
00170                                 character = (a * 16) + b;
00171 
00172                                 if (character == '\0') {
00173                                         break; /* Stop at %00 */
00174                                 }
00175 
00176                                 i += 2;
00177                         } else {
00178 
00179                                 err_count++;
00180                         }
00181                 }
00182 
00183                 *p++ = character;
00184         }
00185 
00186         *p = '\0';
00187 
00188         strncpy(dest, temp, max_dest_len - 1);
00189         dest[max_dest_len - 1] = '\0';
00190 
00191         return err_count;
00192 }

const char* smbc_version ( void   ) 

Return the version of the linked Samba code, and thus the version of the libsmbclient code.

戻り値:
The version string.

libsmbclient.c6671 行で定義されています。

参照先 samba_version_string().

06672 {
06673         return samba_version_string();
06674 }


Sambaに対してSat Aug 29 21:24:39 2009に生成されました。  doxygen 1.4.7