libdsm  0.0.4-11-g223c1ba
Minimalist and read-only SMB client lib
 All Data Structures Files Functions Typedefs Enumerator Macros
Macros | Functions
smb_stat.h File Reference

File status / listing. More...

#include "bdsm/smb_defs.h"
#include "bdsm/smb_session.h"

Macros

#define SMB_STAT_SIZE   0
 smb_stat_get() OP: Get file size
 
#define SMB_STAT_ALLOC_SIZE   1
 smb_stat_get() OP: Get file allocation size (Size on disk)
 
#define SMB_STAT_ISDIR   2
 smb_stat_get() OP: 0 -> not a directory, != 0 -> directory
 
#define SMB_STAT_CTIME   3
 smb_stat_get() OP: Get file creation time
 
#define SMB_STAT_ATIME   4
 smb_stat_get() OP: Get file last access time
 
#define SMB_STAT_WTIME   5
 smb_stat_get() OP: Get file last write time
 
#define SMB_STAT_MTIME   6
 smb_stat_get() OP: Get file last moditification time
 

Functions

smb_stat_list smb_find (smb_session *s, smb_tid tid, const char *pattern)
 Returns infos about files matching a pattern. More...
 
smb_stat smb_fstat (smb_session *s, smb_tid tid, const char *path)
 Get the status of a file from it's path inside of a share. More...
 
smb_stat smb_stat_fd (smb_session *s, smb_fd fd)
 Get the status of an open file from it's file descriptor. More...
 
void smb_stat_destroy (smb_stat stat)
 Clear a smb_stat object, reclaiming its memory. More...
 
size_t smb_stat_list_count (smb_stat_list list)
 Get the number of item in a smb_stat_list file info. More...
 
smb_stat smb_stat_list_at (smb_stat_list list, size_t index)
 Get the element at the given position. More...
 
void smb_stat_list_destroy (smb_stat_list list)
 Destroy and release a list of file stat returned by smb_find. More...
 
const char * smb_stat_name (smb_stat info)
 Get the name of the file from its status. More...
 
uint64_t smb_stat_get (smb_stat info, int what)
 Get a file attribute. More...
 

Detailed Description

File status / listing.

Function Documentation

smb_stat_list smb_find ( smb_session s,
smb_tid  tid,
const char *  pattern 
)

Returns infos about files matching a pattern.

This functions uses the FIND_FIRST2 SMB operations to list files matching a certain pattern. It's basically used to list folder contents

Parameters
sThe session object
tidThe share inside of which we want to find files obtained by smb_tree_connect()
patternThe pattern to match files. '\*' will list all the files at the root of the share. '\afolder\*' will list all the files inside of the 'afolder' directory.
Returns
An opaque list of smb_stat or NULL in case of error
smb_stat smb_fstat ( smb_session s,
smb_tid  tid,
const char *  path 
)

Get the status of a file from it's path inside of a share.

Parameters
sThe session object
tidThe tree id of a share obtained by smb_tree_connect()
pathThe full path of the file relative to the root of the share (e.g. '\folder\file.ext')
Returns
An opaque smb_stat or NULL in case of error. You need to destory this object with smb_stat_destroy after usage.
void smb_stat_destroy ( smb_stat  stat)

Clear a smb_stat object, reclaiming its memory.

Parameters
statA smb_stat object returned by smb_fstat.
smb_stat smb_stat_fd ( smb_session s,
smb_fd  fd 
)

Get the status of an open file from it's file descriptor.

The file status will be those at the time of open

Parameters
sThe session object
fdThe smb_fd from which you want infos/status
Returns
An opaque smb_stat or NULL in case of error. You don't own this object memory, and then don't have to destory it
uint64_t smb_stat_get ( smb_stat  info,
int  what 
)

Get a file attribute.

This function is a getter that allow you to retrieve various informations about a file on a smb_stat object. You can get its size, various timestamps, etc.

Parameters
infoThe smb_stat object to get info from.
whatThis parameter tells the functions which information to get, can be one of SMB_STAT_SIZE, SMB_STAT_ALLOC_SIZE, SMB_STAT_ISDIR, SMB_STAT_CTIME, SMB_STAT_ATIME, SMB_STAT_MTIME, SMB_STAT_WTIME.
Returns
The meaning of the returned value depends on the 'what' parameter. See each item documentation.
smb_stat smb_stat_list_at ( smb_stat_list  list,
size_t  index 
)

Get the element at the given position.

Parameters
listA stat list
indexThe position of the element you want.
Returns
An opaque smb_stat or NULL in case of error
size_t smb_stat_list_count ( smb_stat_list  list)

Get the number of item in a smb_stat_list file info.

Parameters
listThe list you want the length of
Returns
The length of the list. It returns 0 if the list is invalid
void smb_stat_list_destroy ( smb_stat_list  list)

Destroy and release a list of file stat returned by smb_find.

Parameters
listThe stat_list to free
const char* smb_stat_name ( smb_stat  info)

Get the name of the file from its status.

Parameters
infoA file status
Returns
A null-terminated string in you current locale encoding or NULL.