xattr.c File Reference

Extended file attribute support, particularly for MIME types. More...

#include "rox-clib.h"
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <gtk/gtk.h>
#include "rox.h"
#include "mime.h"
#include "xattr.h"

Functions

void rox_xattr_init (void)
int rox_xattr_supported (const char *path)
int rox_xattr_have (const char *path)
gchar * rox_xattr_get (const char *path, const char *attr, int *len)
int rox_xattr_set (const char *path, const char *attr, const char *value, int value_len)
GList * rox_xattr_list (const char *path)
int rox_xattr_delete (const char *path, const char *attr)
gboolean rox_xattr_name_valid (const char *attr)
gboolean rox_xattr_binary_value_supported (void)
ROXMIMETyperox_xattr_type_get (const char *path)
int rox_xattr_type_set (const char *path, const ROXMIMEType *type)


Detailed Description

Extended file attribute support, particularly for MIME types.

This provides an abstract interface to the supported extended attribute API. Both getxattr() and attropen() are supported, as is a fallback no-op implementation.

Version:
Id
xattr.c,v 1.2 2006/11/06 18:19:49 stephen Exp
Author:
Stephen Watson, Thomas Leonard

Function Documentation

gboolean rox_xattr_binary_value_supported ( void   ) 

Returns:
TRUE if the value of an extended attribute can include the ASCII '\0' character.

int rox_xattr_delete ( const char *  path,
const char *  attr 
)

Remove an extended attributes from a file.

Parameters:
[in] path name of file to check
[in] attr name of attribute to check
Returns:
0 for success, or non-zero for an error (check errno). If the attribute was not set then this returns non-zero but sets errno to 0.

gchar* rox_xattr_get ( const char *  path,
const char *  attr,
int *  len 
)

Get the value of an extended attribute. The returned value should be freed with g_free() when done.

Parameters:
[in] path file to get extended attribute from.
[in] attr name of the attribute
[out] len if not NULL then the length of the data returned is stored here, but if the function returns NULL then the contents of len are not changed.
Returns:
the value of the extended attribute attr (pass to g_free() when done, or NULL if attr is not present or if an error occurred (check errno).

int rox_xattr_have ( const char *  path  ) 

Check for the presence of extended attributes on a file.

Parameters:
[in] path file to check
Returns:
TRUE if extended attributes are present, FALSE if not or if an error occurred (check errno for ENOENT etc.).

void rox_xattr_init ( void   ) 

Initialize the extended attrubute system.

GList* rox_xattr_list ( const char *  path  ) 

Return a list of extended attributes set on a file.

Parameters:
[in] path name of file to check
Returns:
List of attribute names, pass to rox_basedir_free_paths() when done, or NULL if no attributes found or an error occurred (check errno).

gboolean rox_xattr_name_valid ( const char *  attr  ) 

Check validity of an extended attribute name.

Some implementations of extended attributes enforce restrictions on valid attribute names. This checks the name against the current rules.

Parameters:
[in] attr name of attribute to check
Returns:
TRUE if the name is valid

int rox_xattr_set ( const char *  path,
const char *  attr,
const char *  value,
int  value_len 
)

Set the value of an extended attribute.

Parameters:
[in] path file to set extended attribute on.
[in] attr name of the attribute
[in] value value of the attribute to set
[in] value_len length of data in value, or -1 if value is a string in which case strlen(value) will be used.
Returns:
0 for success, or non-zero for an error (check errno).

int rox_xattr_supported ( const char *  path  ) 

Check for extended attribute support on the system or a specific file.

Parameters:
[in] path If NULL then check for support on the system, otherwise check for xattr support on the named file name.
Returns:
TRUE if extended attributes are supported.

ROXMIMEType* rox_xattr_type_get ( const char *  path  ) 

Convinience function to check a file for the ROX_XATTR_MIME_TYPE attribute and return the appropriate ROXMIMEType.

Parameters:
[in] path file to check
Returns:
MIME type, or NULL if not set or an error occurred (check errno).

int rox_xattr_type_set ( const char *  path,
const ROXMIMEType type 
)

Convinience function to set the ROX_XATTR_MIME_TYPE attribute on a file.

Parameters:
[in] path file to set MIME type of
[in] type type to set.
Returns:
0 for success, or non-zero for an error (check errno).


Generated on Sat Oct 13 17:22:46 2007 for ROX-CLib by  doxygen 1.5.0