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

file.h File Reference


Detailed Description

Miscellaneous common file routines.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"

Go to the source code of this file.

Data Structures

struct  file_path_t
 This structure is used to identify a file to be saved/restored. More...


Functions

void file_register_fd_reclaimer (reclaim_fd_t callback)
 Register fd reclaiming callback.

FILE * file_config_open_read (const gchar *what, const file_path_t *fv, gint fvcnt)
 Open configuration file, renaming it as ".orig".

FILE * file_config_open_read_norename (const gchar *what, const file_path_t *fv, gint fvcnt)
 Open configuration file, without renaming it.

FILE * file_config_open_read_norename_chosen (const gchar *what, const file_path_t *fv, gint fvcnt, gint *chosen)
 Same as file_config_open_read_norename(), but also returns the index of the path chosen within the array, if a file was opened at all.

FILE * file_config_open_write (const gchar *what, const file_path_t *fv)
 Open configuration file for writing.

gboolean file_config_close (FILE *out, const file_path_t *fv)
 Close configuration file opened for writing, and rename it.

void file_config_preamble (FILE *out, const gchar *what)
 Emit the configuration preamble.

void file_path_set (file_path_t *fp, const char *dir, const char *name)
 Initializes `fp' with directory path `dir' and filename `name'.

gint file_open (const gchar *path, gint flags)
 Open file, returning file descriptor or -1 on error with errno set.

gint file_open_missing (const gchar *path, gint flags)
 Open file, returning file descriptor or -1 on error with errno set.

gint file_create (const gchar *path, gint flags, gint mode)
 Create file, returning file descriptor or -1 on error with errno set.

FILE * file_fopen (const gchar *path, const gchar *mode)
 Open file, returning FILE pointer if success or NULL on error.

FILE * file_fopen_missing (const gchar *path, const gchar *mode)
 Open file, returning FILE pointer if success or NULL on error.


Function Documentation

gboolean file_config_close FILE *  out,
const file_path_t fv
 

Close configuration file opened for writing, and rename it.

Returns:
TRUE on success.

FILE* file_config_open_read const gchar *  what,
const file_path_t fv,
gint  fvcnt
 

Open configuration file, renaming it as ".orig".

If configuration file cannot be found, try opening the ".orig" variant if already present. If not found, try with successive alternatives, if supplied.

Attention:
NB: the supplied `fv' argument is a vector of `fvcnt' elements.
Returns:
opened FILE, or NULL if we were unable to open any.

FILE* file_config_open_read_norename const gchar *  what,
const file_path_t fv,
gint  fvcnt
 

Open configuration file, without renaming it.

If configuration file cannot be found, try opening the ".orig" variant if already present. If not found, try with successive alternatives, if supplied.

Attention:
NB: the supplied `fv' argument is a vector of `fvcnt' elements.
Returns:
opened FILE, or NULL if we were unable to open any.

FILE* file_config_open_read_norename_chosen const gchar *  what,
const file_path_t fv,
gint  fvcnt,
gint *  chosen
 

Same as file_config_open_read_norename(), but also returns the index of the path chosen within the array, if a file was opened at all.

FILE* file_config_open_write const gchar *  what,
const file_path_t fv
 

Open configuration file for writing.

void file_config_preamble FILE *  out,
const gchar *  what
 

Emit the configuration preamble.

gint file_create const gchar *  path,
gint  flags,
gint  mode
 

Create file, returning file descriptor or -1 on error with errno set.

Errors are logged as a warning.

FILE* file_fopen const gchar *  path,
const gchar *  mode
 

Open file, returning FILE pointer if success or NULL on error.

Errors are logged as a warning.

FILE* file_fopen_missing const gchar *  path,
const gchar *  mode
 

Open file, returning FILE pointer if success or NULL on error.

Errors are logged as a warning, unless the file is missing, in which case nothing is logged.

gint file_open const gchar *  path,
gint  flags
 

Open file, returning file descriptor or -1 on error with errno set.

Errors are logged as a warning.

gint file_open_missing const gchar *  path,
gint  flags
 

Open file, returning file descriptor or -1 on error with errno set.

Errors are logged as a warning, unless the file is missing, in which case nothing is logged.

void file_path_set file_path_t fp,
const char *  dir,
const char *  name
 

Initializes `fp' with directory path `dir' and filename `name'.

void file_register_fd_reclaimer reclaim_fd_t  callback  ) 
 

Register fd reclaiming callback.

Use NULL to unregister it.


Generated on Sun Feb 12 10:50:00 2006 for Gtk-Gnutella by doxygen 1.3.6