XAttrs.cpp
author František Kučera <franta-hg@frantovo.cz>
Sat, 06 Jan 2024 01:06:28 +0100
branchv_0
changeset 39 2068a992e97e
parent 29 dc3c102e1264
permissions -rw-r--r--
xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
29
dc3c102e1264 derive OHP3D from ShaderShark
František Kučera <franta-hg@frantovo.cz>
parents: 27
diff changeset
     2
 * OHP3D
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info)
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#include <string>
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    19
#include <cstring>
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <stdexcept>
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    21
#include <vector>
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    22
#include <sys/xattr.h>
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    23
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    24
#include "XAttrs.h"
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    26
std::string xattrGet(
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    27
		const std::string fileName,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    28
		const std::string name,
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    29
		bool* exists = nullptr,
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    30
		bool* supported = nullptr) {
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    31
	std::string buffer;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    32
	ssize_t size = getxattr(fileName.c_str(), name.c_str(), nullptr, 0);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    33
	if (size > 0) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    34
		buffer.resize(size);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    35
		getxattr(fileName.c_str(), name.c_str(), buffer.data(), buffer.size());
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    36
		if (exists) *exists = true;
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    37
		if (supported) *supported = true;
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    38
		return buffer;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    39
	} else if (size == 0) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    40
		if (exists) *exists = true;
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    41
		if (supported) *supported = true;
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    42
		return "";
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    43
	} else if (errno == ENODATA) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    44
		if (exists) *exists = false;
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    45
		if (supported) *supported = true;
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    46
		return "";
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    47
	} else if (errno == ERANGE) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    48
		// rare race condition - the value has changed between the two calls
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    49
		return xattrGet(fileName, name, exists);
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    50
	} else if (errno == ENOTSUP) {
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    51
		if (supported) *supported = false;
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    52
		return "";
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    53
	} else {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    54
		throw std::logic_error(
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    55
				std::string("Unable to get extended attribute: ")
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    56
				+ strerror(errno));
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    57
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    58
}
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    60
bool xattrSet(const std::string fileName,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    61
		const std::string name,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    62
		const std::string value,
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    63
		bool exists = true,
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    64
		bool* supported = nullptr) {
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    65
	int result;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    66
	if (exists) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    67
		result = setxattr(
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    68
				fileName.c_str(),
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    69
				name.c_str(),
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    70
				value.c_str(),
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    71
				value.size(),
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    72
				0);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    73
	} else {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    74
		result = removexattr(fileName.c_str(), name.c_str());
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    75
		if (result < 0 && errno == ENODATA) return false;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    76
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    77
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    78
	if (result < 0 && errno == ENOTSUP && supported) *supported = false;
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    79
	else if (result < 0) throw std::logic_error(
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    80
			std::string("Unable to set extended attribute: ")
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    81
			+ strerror(errno));
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    82
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    83
	return true;
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    84
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    85
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    86
std::vector<std::string>
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    87
xattrList(const std::string fileName, bool* supported = nullptr) {
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    88
	std::string buffer;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    89
	ssize_t size = listxattr(fileName.c_str(), nullptr, 0);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    90
	if (size >= 0) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    91
		buffer.resize(size);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    92
		listxattr(fileName.c_str(), buffer.data(), buffer.size());
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    93
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    94
		std::vector<std::string> result;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    95
		for (const char* k = buffer.c_str(); strlen(k); k += strlen(k) + 1) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    96
			result.push_back(k);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    97
		}
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    98
		if (supported) *supported = true;
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    99
		return result;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   100
	} else if (errno == ERANGE) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   101
		// rare race condition - the list has changed between the two calls
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   102
		return xattrList(fileName);
39
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
   103
	} else if (errno == ENOTSUP) {
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
   104
		if (supported) *supported = false;
2068a992e97e xattr: tolerate ENOTSUP (behave like there are no attributes when not supported on given FS)
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
   105
		return std::vector<std::string>();
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   106
	} else {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   107
		throw std::logic_error(
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   108
				std::string("Unable to list extended attributes: ")
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   109
				+ strerror(errno));
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   110
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   111
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   112
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   113
class XAttrs::Attribute::Impl {
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   114
public:
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   115
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   116
	Impl() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   117
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   118
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   119
	virtual ~Impl() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   120
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   121
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   122
	std::shared_ptr<XAttrs::Impl> xattrs;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   123
	std::string name;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   124
	std::string value;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   125
	bool exists = true;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   126
	bool loaded = false;
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   127
};
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   128
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   129
class XAttrs::Impl {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   130
public:
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   131
	std::string nameSpace;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   132
	std::string fileName;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   133
	std::vector<Attribute> attributes;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   134
	bool loaded = false;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   135
	const XAttrs::Attribute& save(const XAttrs::Attribute& attribute);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   136
	XAttrs::Attribute& load(XAttrs::Attribute& attribute);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   137
};
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   138
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   139
XAttrs::XAttrs(const std::string& fileName, const std::string& nameSpace) :
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   140
impl(std::make_shared<Impl>()) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   141
	impl->nameSpace = nameSpace;
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   142
	impl->fileName = fileName;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   143
}
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   144
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   145
XAttrs::~XAttrs() {
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   146
}
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   147
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   148
const std::string XAttrs::getFileName() const {
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   149
	return impl->fileName;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   150
}
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   151
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   152
size_t XAttrs::size(bool reload) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   153
	if (reload || !impl->loaded) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   154
		impl->attributes.clear();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   155
		std::vector<std::string> names = xattrList(impl->fileName);
27
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   156
		const std::string prefix = impl->nameSpace + ".";
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   157
		for (const std::string& name : names) {
27
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   158
			if (name.starts_with(prefix)) {
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   159
				Attribute a;
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   160
				a.impl->xattrs = impl;
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   161
				a.impl->name = name.substr(prefix.size());
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   162
				a.impl->value = xattrGet(impl->fileName, name, &a.impl->exists);
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   163
				impl->attributes.push_back(a);
2a156cb51479 xattr: list attribute names without the namespace prefix 'user.'
František Kučera <franta-hg@frantovo.cz>
parents: 24
diff changeset
   164
			}
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   165
		}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   166
		impl->loaded = true;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   167
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   168
	return impl->attributes.size();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   169
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   170
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   171
XAttrs::Attribute* XAttrs::begin() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   172
	size();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   173
	return &impl->attributes[0];
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   174
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   175
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   176
XAttrs::Attribute* XAttrs::end() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   177
	size();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   178
	return &impl->attributes[impl->attributes.size()];
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   179
}
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   180
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   181
const XAttrs::Attribute&
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   182
XAttrs::Impl::save(const XAttrs::Attribute& attribute) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   183
	xattrSet(
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   184
			fileName,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   185
			nameSpace + "." + attribute.impl->name,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   186
			attribute.impl->value,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   187
			attribute.impl->exists);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   188
	loaded &= attribute.impl->exists;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   189
	return attribute;
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   190
}
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   191
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   192
XAttrs::Attribute&
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   193
XAttrs::Impl::load(XAttrs::Attribute& attribute) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   194
	attribute.impl->value = xattrGet(fileName,
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   195
			nameSpace + "." + attribute.impl->name, &attribute.impl->exists);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   196
	return attribute;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   197
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   198
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   199
XAttrs::Attribute& XAttrs::operator[](std::string name) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   200
	for (XAttrs::Attribute& a : impl->attributes) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   201
		if (a.getName() == name) return a; // impl->load(a);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   202
	}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   203
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   204
	XAttrs::Attribute a;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   205
	a.impl->xattrs = impl;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   206
	a.impl->name = name;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   207
	a.impl->exists = false;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   208
	// impl->load(a);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   209
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   210
	impl->attributes.push_back(a);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   211
	return impl->attributes.back();
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   212
}
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   213
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   214
XAttrs::Attribute& XAttrs::operator[](std::size_t index) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   215
	if (impl->attributes.empty()) size();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   216
	return impl->attributes[index];
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   217
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   218
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   219
XAttrs::Attribute::Attribute() : impl(std::make_shared<Impl>()) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   220
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   221
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   222
XAttrs::Attribute::~Attribute() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   223
}
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   224
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   225
const std::string XAttrs::Attribute::getName() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   226
	return impl->name;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   227
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   228
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   229
const std::string XAttrs::Attribute::getValue(bool reload) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   230
	if (reload || !impl->loaded) impl->xattrs->load(*this);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   231
	return impl->value;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   232
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   233
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   234
bool XAttrs::Attribute::exists(bool reload) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   235
	if (reload || !impl->loaded) impl->xattrs->load(*this);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   236
	return impl->exists;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   237
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   238
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   239
bool XAttrs::Attribute::missing(bool reload) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   240
	return !exists(reload);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   241
}
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   242
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   243
XAttrs::Attribute& XAttrs::Attribute::operator=(const std::string& value) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   244
	impl->value = value;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   245
	impl->exists = true;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   246
	impl->xattrs->save(*this);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   247
	return *this;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   248
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   249
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   250
XAttrs::Attribute& XAttrs::Attribute::
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   251
		operator=(const XAttrs::Attribute& value) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   252
	impl->value = value.impl->value;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   253
	impl->exists = value.impl->exists;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   254
	impl->xattrs->save(*this);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   255
	return *this;
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   256
}
24
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   257
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   258
XAttrs::Attribute::operator std::string() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   259
	impl->xattrs->load(*this);
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   260
	return impl->value;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   261
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   262
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   263
std::ostream& operator<<(std::ostream& s, XAttrs::Attribute& a) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   264
	s << a.getValue().c_str();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   265
	return s;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   266
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   267
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   268
std::ostream& operator>>(XAttrs::Attribute& a, std::ostream& s) {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   269
	s << a.getValue().c_str();
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   270
	return s;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   271
}
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   272
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   273
XAttrs::Null::Null() {
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   274
	impl->exists = false;
98d033d3ef7c xattr: XAttrs class that read/write/list extended attributes
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   275
}