pxattr 2.1
pxattr.h
1#ifndef _pxattr_h_included_
2#define _pxattr_h_included_
3
4/* @(#$Id: pxattr.h,v 1.5 2009-01-20 13:48:34 dockes Exp $ (C) 2009 J.F.Dockes
5 Copyright (c) 2009 Jean-Francois Dockes
6
7 Permission is hereby granted, free of charge, to any person
8 obtaining a copy of this software and associated documentation
9 files (the "Software"), to deal in the Software without
10 restriction, including without limitation the rights to use,
11 copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following
14 conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 OTHER DEALINGS IN THE SOFTWARE.
27*/
28#include <string>
29#include <vector>
30
63namespace pxattr {
69
71enum flags {PXATTR_NONE=0,
78};
79
83bool get(const std::string& path, const std::string& name, std::string* value,
84 flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
88bool get(int fd, const std::string& name, std::string* value,
89 flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
93bool set(const std::string& path, const std::string& name, const std::string& value,
94 flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
98bool set(int fd, const std::string& name, const std::string& value,
99 flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
103bool del(const std::string& path, const std::string& name, flags flags = PXATTR_NONE,
104 nspace dom = PXATTR_USER);
108bool del(int fd, const std::string& name, flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
112bool list(const std::string& path, std::vector<std::string>* names,
113 flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
117bool list(int fd, std::vector<std::string>* names,
118 flags flags = PXATTR_NONE, nspace dom = PXATTR_USER);
119
124bool sysname(nspace dom, const std::string& pname, std::string* sname);
129bool pxname(nspace dom, const std::string& sname, std::string* pname);
130
131} // namespace pxattr
132
133
134#endif /* _pxattr_h_included_ */
Provide a uniform C++ API for extended file attributes on Linux/FreeBSD and MacOSX.
Definition pxattr.h:63
bool list(const std::string &path, std::vector< std::string > *names, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
List attribute names from path.
flags
Flags can modify the behaviour of some methods.
Definition pxattr.h:71
@ PXATTR_REPLACE
Fail if new.
Definition pxattr.h:77
@ PXATTR_NOFOLLOW
Act on link instead of following it.
Definition pxattr.h:73
@ PXATTR_CREATE
Fail if existing.
Definition pxattr.h:75
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 del(const std::string &path, const std::string &name, flags flags=PXATTR_NONE, nspace dom=PXATTR_USER)
Delete the named attribute from path.
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 pxname(nspace dom, const std::string &sname, std::string *pname)
Compute external name from actual/system name (ie: user.myattr->myattr)
nspace
nspace might be used in the future if we support multiple namespaces.
Definition pxattr.h:65
@ PXATTR_USER
User name space.
Definition pxattr.h:67
bool sysname(nspace dom, const std::string &pname, std::string *sname)
Compute actual/system attribute name from external name (ie: myattr->user.myattr)