OpenVAS Libraries  4.0+rc3.SVN
Functions
base/openvas_file.c File Reference

File utilities. More...

#include "openvas_file.h"
#include <sys/stat.h>
#include <glib/gstdio.h>

Functions

int openvas_file_check_is_dir (const char *name)
 Checks whether a file is a directory or not.
int openvas_file_remove_recurse (const gchar *pathname)
 Recursively removes files and directories.
gchar * openvas_file_read_b64_encode (const gchar *filename)
 Reads in contents of file, and returns it, base64-encoded.

Detailed Description

File utilities.


Function Documentation

int openvas_file_check_is_dir ( const char *  name)

Checks whether a file is a directory or not.

This is a replacement for the g_file_test functionality which is reported to be unreliable under certain circumstances, for example if this application and glib are compiled with a different libc.

Todo:
FIXME: handle symbolic links
Parameters:
[in]nameName of file or directory.
Returns:
1 if parameter is directory, 0 if it is not, -1 if it does not exist or could not be accessed.
gchar* openvas_file_read_b64_encode ( const gchar *  filename)

Reads in contents of file, and returns it, base64-encoded.

This function does neither log any occuring error, nor does it make it available, it will just return NULL.

Parameters:
[in]filenameFile to read in.
Returns:
NULL if any error occurred, content of file, base64 encoded, freshly allocated, free with g_free.
int openvas_file_remove_recurse ( const gchar *  pathname)

Recursively removes files and directories.

This function will recursively call itself to delete a path and any contents of this path.

Parameters:
[in]pathnameThe name of the file to be deleted from the filesystem.
Returns:
0 if the name was successfully deleted, -1 if an error occurred. Please note that errno is currently not guaranteed to contain the correct value if -1 is returned.
Todo:
Set errno when we return -1 to maintain remove() compatibility.