[preservefiles] Tidy up permissions code

- superfluous const
 - add default constructor
 - Add octal-string accessor to permissions
This commit is contained in:
Adriaan de Groot 2018-10-01 10:51:21 +02:00
parent 1c85a648a4
commit 91c94c6022
2 changed files with 18 additions and 11 deletions

View File

@ -21,17 +21,21 @@
#include <QStringList>
#include "permissions.h"
Permissions::Permissions(QString p) :
Permissions::Permissions() :
m_username(),
m_group(),
m_valid(true),
m_valid(false),
m_value(0)
{
}
Permissions::Permissions(QString p) : Permissions()
{
parsePermissions(p);
}
const void Permissions::parsePermissions(const QString& p) {
void Permissions::parsePermissions(const QString& p) {
QStringList segments = p.split(":");

View File

@ -32,22 +32,25 @@ class Permissions
public:
/** Constructor
/** @brief Constructor
*
* Splits the string @p at the colon (":") into separate elements for
* <user>, <group>, and <value> (permissions), where <value> is returned as
* an **octal** integer.
*/
Permissions(QString p);
/** @brief Default constructor of an invalid Permissions. */
Permissions();
bool isValid() const { return m_valid; }
QString username() const { return m_username; }
QString group() const { return m_group; }
int value() const { return m_value; }
QString octal() const { return QString::number( m_value, 8 ); }
private:
const void parsePermissions(QString const &p);
void parsePermissions(QString const &p);
QString m_username;
QString m_group;