Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

File Functions
[SB Library]

File Functions. More...

Functions

int sb_file_is_fifo (const char *filepath)
 Test if path is a FIFO.
int sb_file_is_file (const char *filepath)
 Test if file is OK.
int sb_file_get_stamp (const char *filepath)
 Get file creation timestamp.
int sb_file_get_size (const char *filepath)
 Get file size.
char * sb_file_read (const char *filepath)
 Read data from given file.
int sb_file_write (const char *filepath, char *data)
 Write data to given file.
int sb_file_remove (const char *filepath)
 remove given file
int sb_file_open (const char *filepath, int flags)
 Open given file.
int sb_file_open_ext (const char *filepath, int flags, mode_t mode)
 Open given file.
int sb_file_close (int fd)
 Close given file descriptor.
int sb_file_set_lock (int fd, int type, int wait)
 Wrapper for setting the locks.
int sb_file_lock_acquire_read (int fd)
 Acquire read lock for given file descriptor.
int sb_file_lock_acquire_read_wait (int fd)
 Wait until file descriptor can be read locked, and than do it.
int sb_file_lock_acquire_write (int fd)
 Acquire write lock for given file descriptor.
int sb_file_lock_acquire_write_wait (int fd)
 Wait until file descriptor can be write locked, and than do it.
int sb_file_lock_release (int fd)
 Release lock from given file descriptor.

Detailed Description

File Functions.

This module provides functions for handling files.


Function Documentation

int sb_file_close int  fd  ) 
 

Close given file descriptor.

Wrapper around libcs close() function.

Set locks will be released automatically. So you don't need to call the release function, but it's good coding style to do it.

Parameters:
fd File descriptor
Returns:
0 if successful, -1 if error

Definition at line 234 of file file.c.

Referenced by sb_daemon_is_running().

int sb_file_get_size const char *  filepath  ) 
 

Get file size.

Parameters:
filepath Filepath
Returns:
size if successful, -1 otherwise

Definition at line 99 of file file.c.

Referenced by mntd_volume_config_parse(), and sb_file_read().

int sb_file_get_stamp const char *  filepath  ) 
 

Get file creation timestamp.

Parameters:
filepath Filepath
Returns:
timestamp if successful, -1 otherwise

Definition at line 81 of file file.c.

int sb_file_is_fifo const char *  filepath  ) 
 

Test if path is a FIFO.

Parameters:
filepath Filepath
Returns:
CTRUE if file is there, CFALSE otherwise

Definition at line 45 of file file.c.

int sb_file_is_file const char *  filepath  ) 
 

Test if file is OK.

Parameters:
filepath Filepath
Returns:
CTRUE if file is there, CFALSE otherwise

Definition at line 63 of file file.c.

Referenced by main(), mntd_volume_config_parse(), sb_dir_rmdirs(), and sb_file_remove().

int sb_file_lock_acquire_read int  fd  ) 
 

Acquire read lock for given file descriptor.

Parameters:
fd File descriptor
Returns:
0 if successful, -1 if error

Definition at line 261 of file file.c.

References sb_file_set_lock().

int sb_file_lock_acquire_read_wait int  fd  ) 
 

Wait until file descriptor can be read locked, and than do it.

Parameters:
fd File descriptor
Returns:
0 if successful, -1 if error

Definition at line 269 of file file.c.

References sb_file_set_lock().

int sb_file_lock_acquire_write int  fd  ) 
 

Acquire write lock for given file descriptor.

Parameters:
fd File descriptor
Returns:
0 if successful, -1 if error

Definition at line 277 of file file.c.

References sb_file_set_lock().

Referenced by sb_daemon_pidfile_create_and_lock().

int sb_file_lock_acquire_write_wait int  fd  ) 
 

Wait until file descriptor can be write locked, and than do it.

Parameters:
fd File descriptor
Returns:
0 if successful, -1 if error

Definition at line 285 of file file.c.

References sb_file_set_lock().

int sb_file_lock_release int  fd  ) 
 

Release lock from given file descriptor.

Parameters:
fd File descriptor
Returns:
0 if successful, -1 if error

Definition at line 293 of file file.c.

References sb_file_set_lock().

int sb_file_open const char *  filepath,
int  flags
 

Open given file.

Wrapper around libcs open() function.

Parameters:
filepath Filepath
flags Flags to pass to open()
Returns:
0 if successful, -1 if error

Definition at line 206 of file file.c.

Referenced by sb_daemon_pidfile_create_and_lock(), and sb_daemon_pidfile_read().

int sb_file_open_ext const char *  filepath,
int  flags,
mode_t  mode
 

Open given file.

Wrapper around libcs open() function.

Parameters:
filepath Filepath
flags Flags to pass to open()
mode Mode to pass to open()
Returns:
0 if successful, -1 if error

Definition at line 220 of file file.c.

Referenced by sb_daemon_pidfile_create_and_lock().

char* sb_file_read const char *  filepath  ) 
 

Read data from given file.

Parameters:
filepath Filepath
Returns:
String if successful, NULL otherwise

Definition at line 117 of file file.c.

References sb_file_get_size().

Referenced by mntd_volume_config_parse().

int sb_file_remove const char *  filepath  ) 
 

remove given file

Parameters:
filepath Filepath
Returns:
CTRUE if successful, CFALSE otherwise

Definition at line 193 of file file.c.

References sb_file_is_file().

Referenced by sb_daemon_destroy(), sb_daemon_is_running(), and sb_dir_rmdirs().

int sb_file_set_lock int  fd,
int  type,
int  wait
 

Wrapper for setting the locks.

Private function, that you don't need to call.

Parameters:
fd File descriptor
type Type of lock (read | write)
wait Wait for acquired lock (1 for wait, 0 for not)
Returns:
0 if successful, -1 if error

Definition at line 242 of file file.c.

Referenced by sb_file_lock_acquire_read(), sb_file_lock_acquire_read_wait(), sb_file_lock_acquire_write(), sb_file_lock_acquire_write_wait(), and sb_file_lock_release().

int sb_file_write const char *  filepath,
char *  data
 

Write data to given file.

Parameters:
filepath Filepath
data data
Returns:
1 if successful, 0 otherwise

Definition at line 165 of file file.c.


Generated on Wed Mar 30 13:43:27 2005 for Mntd by  doxygen 1.3.9.1