libdsm 0.4.3
Minimalist and read-only SMB client lib
|
File operations. More...
#include "bdsm/smb_session.h"
Functions | |
BDSM_EXPORT int | smb_fopen (smb_session *s, smb_tid tid, const char *path, uint32_t mod, smb_fd *fd) |
Open a file on a share. | |
BDSM_EXPORT void | smb_fclose (smb_session *s, smb_fd fd) |
Close an open file. | |
BDSM_EXPORT ssize_t | smb_fread (smb_session *s, smb_fd fd, void *buf, size_t buf_size) |
Read from an open file. | |
BDSM_EXPORT ssize_t | smb_fwrite (smb_session *s, smb_fd fd, void *buf, size_t buf_size) |
Write to an open file. | |
BDSM_EXPORT ssize_t | smb_fseek (smb_session *s, smb_fd fd, off_t offset, int whence) |
Sets/Moves/Get the read/write pointer for a given file. | |
BDSM_EXPORT int | smb_file_rm (smb_session *s, smb_tid tid, const char *path) |
remove a file on a share. | |
BDSM_EXPORT int | smb_file_mv (smb_session *s, smb_tid tid, const char *old_path, const char *new_path) |
move/rename a file/directory on a share. | |
File operations.
BDSM_EXPORT void smb_fclose | ( | smb_session * | s, |
smb_fd | fd ) |
Close an open file.
The smb_fd is invalidated and MUST not be use it anymore. You can give it the 0 value.
s | The session object |
fd | The SMB file descriptor |
BDSM_EXPORT int smb_file_mv | ( | smb_session * | s, |
smb_tid | tid, | ||
const char * | old_path, | ||
const char * | new_path ) |
move/rename a file/directory on a share.
Use this function to move and/or rename a file/directory
s | The session object |
tid | The tid of the share the file is in, obtained via smb_tree_connect() |
old_path | The current path of the file/directory to move/rename |
new_path | The new path of the file/directory |
BDSM_EXPORT int smb_file_rm | ( | smb_session * | s, |
smb_tid | tid, | ||
const char * | path ) |
remove a file on a share.
Use this function to delete a file
s | The session object |
tid | The tid of the share the file is in, obtained via smb_tree_connect() |
path | The path of the file to delete |
BDSM_EXPORT int smb_fopen | ( | smb_session * | s, |
smb_tid | tid, | ||
const char * | path, | ||
uint32_t | mod, | ||
smb_fd * | fd ) |
Open a file on a share.
Use this function to obtain an smb_fd, necesary for file operations
s | The session object |
tid | The tid of the share the file is in, obtained via smb_tree_connect() |
path | The path of the file to open |
mod | The access modes requested (example: SMB_MOD_RO) |
fd | The pointer to the smb file description that can be used for further file operations |
BDSM_EXPORT ssize_t smb_fread | ( | smb_session * | s, |
smb_fd | fd, | ||
void * | buf, | ||
size_t | buf_size ) |
Read from an open file.
The semantics is basically the same that the unix read() one. At most 'buf_size' bytes are read from the current seek offset and copied into the memory pointed by 'buf' from the open file represented by the smb file descriptor 'fd'.
[in] | s | The session object |
[in] | fd | [description] |
[out] | buf | can be NULL in order to skip buf_size bytes |
[in] | buf_size | [description] |
BDSM_EXPORT ssize_t smb_fseek | ( | smb_session * | s, |
smb_fd | fd, | ||
off_t | offset, | ||
int | whence ) |
Sets/Moves/Get the read/write pointer for a given file.
The behavior of this function is the same as the Unix fseek() function, except the SEEK_END argument isn't supported.
This functions adjust the read/write pointer depending on the value of offset and whence.
s | The session object |
fd | The file descriptors for which the read pointer is to be adjusted |
offset | Set/Adjust quantity |
whence | Which action to perform. Supported operations are SMB_SEEK_SET and SMB_SEEK_CUR |
BDSM_EXPORT ssize_t smb_fwrite | ( | smb_session * | s, |
smb_fd | fd, | ||
void * | buf, | ||
size_t | buf_size ) |
Write to an open file.
At most 'buf_size' bytes from memory pointed by 'buf' are written to the current seek offset of the open file represented by the smb file descriptor 'fd'.
[in] | s | The session object |
[in] | fd | [description] |
[out] | buf | [description] |
[in] | buf_size | [description] |