[preservefiles] Tidy up permissions code
- superfluous const - add default constructor - Add octal-string accessor to permissions
This commit is contained in:
parent
1c85a648a4
commit
91c94c6022
@ -21,17 +21,21 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "permissions.h"
|
#include "permissions.h"
|
||||||
|
|
||||||
Permissions::Permissions(QString p) :
|
Permissions::Permissions() :
|
||||||
m_username(),
|
m_username(),
|
||||||
m_group(),
|
m_group(),
|
||||||
m_valid(true),
|
m_valid(false),
|
||||||
m_value(0)
|
m_value(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Permissions::Permissions(QString p) : Permissions()
|
||||||
{
|
{
|
||||||
parsePermissions(p);
|
parsePermissions(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void Permissions::parsePermissions(const QString& p) {
|
void Permissions::parsePermissions(const QString& p) {
|
||||||
|
|
||||||
QStringList segments = p.split(":");
|
QStringList segments = p.split(":");
|
||||||
|
|
||||||
|
@ -32,22 +32,25 @@ class Permissions
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Constructor
|
/** @brief Constructor
|
||||||
|
*
|
||||||
* Splits the string @p at the colon (":") into separate elements for
|
* Splits the string @p at the colon (":") into separate elements for
|
||||||
* <user>, <group>, and <value> (permissions), where <value> is returned as
|
* <user>, <group>, and <value> (permissions), where <value> is returned as
|
||||||
* an **octal** integer.
|
* an **octal** integer.
|
||||||
*/
|
*/
|
||||||
Permissions(QString p);
|
Permissions(QString p);
|
||||||
|
|
||||||
|
/** @brief Default constructor of an invalid Permissions. */
|
||||||
|
Permissions();
|
||||||
|
|
||||||
bool isValid() const { return m_valid; }
|
bool isValid() const { return m_valid; }
|
||||||
QString username() const { return m_username; }
|
QString username() const { return m_username; }
|
||||||
QString group() const { return m_group; }
|
QString group() const { return m_group; }
|
||||||
int value() const { return m_value; }
|
int value() const { return m_value; }
|
||||||
|
QString octal() const { return QString::number( m_value, 8 ); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void parsePermissions(QString const &p);
|
||||||
const void parsePermissions(QString const &p);
|
|
||||||
|
|
||||||
QString m_username;
|
QString m_username;
|
||||||
QString m_group;
|
QString m_group;
|
||||||
|
Loading…
Reference in New Issue
Block a user