99#endif
1010
1111#include < QDebug>
12- #include < QProcess>
12+ // #include <QProcess>
1313#include < QStandardPaths>
1414
1515#define XATTR_NAMESPACE " user"
@@ -110,7 +110,7 @@ QString getAttributeValueQString(const QString &path, const QString &attribute,
110110bool setAttributeValueQString (const QString &path, const QString &attribute, const QString &value)
111111{
112112 // set the value from the extended attribute for the path
113-
113+ /*
114114 QString candidateProgram = QStandardPaths::findExecutable("setextattr"); // FreeBSD
115115 if (candidateProgram.isEmpty())
116116 QStandardPaths::findExecutable("setxattr"); // Linux
@@ -128,24 +128,24 @@ bool setAttributeValueQString(const QString &path, const QString &attribute, con
128128 return false;
129129 }
130130 return true;
131-
131+ */
132132 // The following does not work on read-only files, e.g., at /usr
133- // #if defined(BSD)
134- // ssize_t bytesSet = extattr_set_file(path.toLatin1().data(), EXTATTR_NAMESPACE_USER,
135- // attribute.toLatin1().data(), value.toLatin1().data(),
136- // value.length() + 1); // include \0 termination char
137- // // check if we set the attribute value
138- // return (bytesSet > 0);
139- // #else
140- // QString namespacedAttr;
141- // namespacedAttr.append(XATTR_NAMESPACE).append(".").append(attribute);
142- // int success = setxattr(path.toLatin1().data(),
143- // namespacedAttr.toLatin1().data(),
144- // value.toLatin1().data(), value.length() + 1, 0); //
145- // include \0 termination char
146- // // check if we set the attribute value
147- // return (success == 0);
148- // #endif
133+ #if defined(BSD)
134+ ssize_t bytesSet = extattr_set_file (path.toLatin1 ().data (), EXTATTR_NAMESPACE_USER,
135+ attribute.toLatin1 ().data (), value.toLatin1 ().data (),
136+ value.length () + 1 ); // include \0 termination char
137+ // check if we set the attribute value
138+ return (bytesSet > 0 );
139+ #else
140+ QString namespacedAttr;
141+ namespacedAttr.append (XATTR_NAMESPACE).append (" ." ).append (attribute);
142+ int success = setxattr (path.toLatin1 ().data (),
143+ namespacedAttr.toLatin1 ().data (),
144+ value.toLatin1 ().data (), value.length () + 1 , 0 ); //
145+ include \0 termination char
146+ // check if we set the attribute value
147+ return (success == 0 );
148+ #endif
149149}
150150
151151} // namespace Fm
0 commit comments