diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/include/eina_xattr.h | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_xattr.h b/libraries/eina/src/include/eina_xattr.h new file mode 100644 index 0000000..8ddb30a --- /dev/null +++ b/libraries/eina/src/include/eina_xattr.h | |||
@@ -0,0 +1,168 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2011 Cedric Bail | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; | ||
16 | * if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef EINA_XATTR_H_ | ||
20 | #define EINA_XATTR_H_ | ||
21 | |||
22 | #include "eina_types.h" | ||
23 | |||
24 | /** | ||
25 | * @addtogroup Eina_Tools_Group Tools | ||
26 | * | ||
27 | * @{ | ||
28 | */ | ||
29 | |||
30 | /** | ||
31 | * @typedef Eina_Xattr_Flags | ||
32 | * define extended attribute creation | ||
33 | * | ||
34 | * @since 1.1 | ||
35 | */ | ||
36 | typedef enum { | ||
37 | EINA_XATTR_INSERT, /**< This is the default behaviour, it will either create or replace the extended attribute */ | ||
38 | EINA_XATTR_REPLACE, /**< This will only succeed if the extended attribute previously existed */ | ||
39 | EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */ | ||
40 | } Eina_Xattr_Flags; | ||
41 | |||
42 | |||
43 | /** | ||
44 | * @brief Get an iterator that list all extended attribute of a file. | ||
45 | * | ||
46 | * @param file The filename to retrieve the extended attribute list from. | ||
47 | * @return an iterator. | ||
48 | * | ||
49 | * The iterator will not allocate any data during the iteration step, so you need to copy them yourself | ||
50 | * if you need. | ||
51 | * | ||
52 | * @since 1.1 | ||
53 | */ | ||
54 | EAPI Eina_Iterator *eina_xattr_ls(const char *file); | ||
55 | |||
56 | /** | ||
57 | * @brief Retrieve an extended attribute from a file. | ||
58 | * | ||
59 | * @param file The file to retrieve the extended attribute from. | ||
60 | * @param atttribute The extended attribute name to retrieve. | ||
61 | * @param size The size of the retrieved extended attribute. | ||
62 | * @return the allocated data that hold the extended attribute value. | ||
63 | * | ||
64 | * It will return NULL and *size will be @c 0 if it fails. | ||
65 | * | ||
66 | * @since 1.1 | ||
67 | */ | ||
68 | EAPI void *eina_xattr_get(const char *file, const char *attribute, ssize_t *size); | ||
69 | |||
70 | /** | ||
71 | * @brief Set an extended attribute on a file. | ||
72 | * | ||
73 | * @param file The file to set the extended attribute to. | ||
74 | * @param attribute The attribute to set. | ||
75 | * @param data The data to set. | ||
76 | * @param length The length of the data to set. | ||
77 | * @param flags Define the set policy. | ||
78 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | ||
79 | * | ||
80 | * @since 1.1 | ||
81 | */ | ||
82 | EAPI Eina_Bool eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_t length, Eina_Xattr_Flags flags); | ||
83 | |||
84 | /** | ||
85 | * @brief Set a string as a extended attribute properties. | ||
86 | * | ||
87 | * @param file The file to set the string to. | ||
88 | * @param attribute The attribute to set. | ||
89 | * @param data The NULL terminated string to set. | ||
90 | * @param flags Define the set policy. | ||
91 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | ||
92 | * | ||
93 | * @since 1.1 | ||
94 | */ | ||
95 | EAPI Eina_Bool eina_xattr_string_set(const char *file, const char *attribute, const char *data, Eina_Xattr_Flags flags); | ||
96 | |||
97 | /** | ||
98 | * @brief Get a string from an extended attribute properties. | ||
99 | * | ||
100 | * @param file The file to get the string from. | ||
101 | * @param attribute The attribute to get. | ||
102 | * @return a valid string on success, NULL otherwise. | ||
103 | * | ||
104 | * This call check that the string is properly NULL-terminated before returning it. | ||
105 | * | ||
106 | * @since 1.1 | ||
107 | */ | ||
108 | EAPI char *eina_xattr_string_get(const char *file, const char *attribute); | ||
109 | |||
110 | /** | ||
111 | * @brief Set a double as a extended attribute properties. | ||
112 | * | ||
113 | * @param file The file to set the double to. | ||
114 | * @param attribute The attribute to set. | ||
115 | * @param data The NULL terminated double to set. | ||
116 | * @param flags Define the set policy. | ||
117 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | ||
118 | * | ||
119 | * @since 1.1 | ||
120 | */ | ||
121 | EAPI Eina_Bool eina_xattr_double_set(const char *file, const char *attribute, double value, Eina_Xattr_Flags flags); | ||
122 | |||
123 | /** | ||
124 | * @brief Get a double from an extended attribute properties. | ||
125 | * | ||
126 | * @param file The file to get the string from. | ||
127 | * @param attribute The attribute to get. | ||
128 | * @param value Where to put the extracted value | ||
129 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | ||
130 | * | ||
131 | * This call check that the double is correctly set. | ||
132 | * | ||
133 | * @since 1.1 | ||
134 | */ | ||
135 | EAPI Eina_Bool eina_xattr_double_get(const char *file, const char *attribute, double *value); | ||
136 | |||
137 | /** | ||
138 | * @brief Set an int as a extended attribute properties. | ||
139 | * | ||
140 | * @param file The file to set the int to. | ||
141 | * @param attribute The attribute to set. | ||
142 | * @param data The NULL terminated int to set. | ||
143 | * @param flags Define the set policy. | ||
144 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | ||
145 | * | ||
146 | * @since 1.1 | ||
147 | */ | ||
148 | EAPI Eina_Bool eina_xattr_int_set(const char *file, const char *attribute, int value, Eina_Xattr_Flags flags); | ||
149 | |||
150 | /** | ||
151 | * @brief Get a int from an extended attribute properties. | ||
152 | * | ||
153 | * @param file The file to get the string from. | ||
154 | * @param attribute The attribute to get. | ||
155 | * @param value Where to put the extracted value | ||
156 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | ||
157 | * | ||
158 | * This call check that the int is correctly set. | ||
159 | * | ||
160 | * @since 1.1 | ||
161 | */ | ||
162 | EAPI Eina_Bool eina_xattr_int_get(const char *file, const char *attribute, int *value); | ||
163 | |||
164 | /** | ||
165 | * @} | ||
166 | */ | ||
167 | |||
168 | #endif | ||