-
Notifications
You must be signed in to change notification settings - Fork 4
/
path.h
94 lines (83 loc) · 1.71 KB
/
path.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* Reducer.h
*
* The reducer class.
*
* @author Toon Schoenmakers <[email protected]>
* @copyright 2015 - 2016 Copernica BV
*/
/**
* Include guard
*/
#pragma once
/**
* Dependencies
*/
#include <phpcpp.h>
#include "base.h"
/**
* Class definition
*/
class Path : public Php::Base
{
private:
/**
* The underlying fullname class
*/
std::unique_ptr<Yothalot::Fullname> _fullname;
public:
/**
* Constructor
*/
Path() {}
/**
* Destructor
*/
virtual ~Path() {};
/**
* Php constructor
* @param params
*/
void __construct(Php::Parameters ¶ms)
{
try
{
// construct the fullname class
_fullname.reset(new Yothalot::Fullname(base(), params[0].stringValue()));
// check if we're valid, throw otherwise
if (!_fullname || !(*_fullname)) throw Php::Exception(params[0].stringValue() + " is not on a glusterfs mount");
}
catch (const std::runtime_error &error)
{
// pass this on to PHP - where it can be handled
throw Php::Exception(error.what());
}
}
/**
* Return the absolute path
* @return Php::Value
*/
Php::Value absolute() const
{
// return the fullname
return _fullname->full();
}
/**
* Return the relative path
* @return Php::Value
*/
Php::Value relative() const
{
// return the relative path
return _fullname->relative();
}
/**
* Cast to a string
*
* @return The absolute path
*/
Php::Value __toString() const
{
return _fullname->path();
}
};