pxattr 2.1
Enumerations | Functions
pxattr Namespace Reference

Provide a uniform C++ API for extended file attributes on Linux/FreeBSD and MacOSX. More...

Enumerations

enum  nspace { PXATTR_USER }
 nspace might be used in the future if we support multiple namespaces. More...
 
enum  flags { PXATTR_NONE =0 , PXATTR_NOFOLLOW = 1 , PXATTR_CREATE =2 , PXATTR_REPLACE =4 }
 Flags can modify the behaviour of some methods. More...
 

Functions

bool get (const std::string &path, const std::string &name, std::string *value, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 Retrieve the named attribute from path.
 
bool get (int fd, const std::string &name, std::string *value, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 Retrieve the named attribute from open file.
 
bool set (const std::string &path, const std::string &name, const std::string &value, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 Set the named attribute on path.
 
bool set (int fd, const std::string &name, const std::string &value, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 Set the named attribute on open file.
 
bool del (const std::string &path, const std::string &name, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 Delete the named attribute from path.
 
bool del (int fd, const std::string &name, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 Delete the named attribute from open file.
 
bool list (const std::string &path, std::vector< std::string > *names, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 List attribute names from path.
 
bool list (int fd, std::vector< std::string > *names, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
 List attribute names from open file.
 
bool sysname (nspace dom, const std::string &pname, std::string *sname)
 Compute actual/system attribute name from external name (ie: myattr->user.myattr)
 
bool pxname (nspace dom, const std::string &sname, std::string *pname)
 Compute external name from actual/system name (ie: user.myattr->myattr)
 

Detailed Description

Provide a uniform C++ API for extended file attributes on Linux/FreeBSD and MacOSX.

We only deal with user attributes. Other namespaces are very system-specific and would be difficult to use in a portable way.

Linux and FreeBSD treat differently the attributes name space segmentation: Linux uses the first name segment ("user.", "system.", ...), FreeBSD uses an enumeration.

We handle this by using only domain-internal names in the interface: that is, the caller specifies the names as, ie, 'org.myapp.somename' not 'user.org.myapp.somename'. pxattr will deal with adding/removing the 'user.' part as needed.

MacOsX does not segment the attribute name space.

In order to avoid conflicts, it is recommended that attributes names be chosen in a "reverse dns" fashion, ie: org.recoll.indexing.status

The interface provided should work the same way on all 3 systems, it papers over such differences as the "list" output format, the existence of CREATE/UPDATE distinctions, etc.

Diagnostics: all functions return false on error, and preserve the errno value or set it as appropriate.

For path-based interfaces, the PXATTR_NOFOLLOW flag can be set to decide if symbolic links will be acted on or followed.

Enumeration Type Documentation

◆ flags

Flags can modify the behaviour of some methods.

Enumerator
PXATTR_NOFOLLOW 

Act on link instead of following it.

PXATTR_CREATE 

Fail if existing.

PXATTR_REPLACE 

Fail if new.

◆ nspace

nspace might be used in the future if we support multiple namespaces.

Enumerator
PXATTR_USER 

User name space.