2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_SOURCE_ROOT_INFO_H_
18 #define incl_HPHP_SOURCE_ROOT_INFO_H_
20 #include "hphp/runtime/base/type-array.h"
21 #include "hphp/runtime/base/type-string.h"
22 #include "hphp/runtime/debugger/debugger_base.h"
25 ///////////////////////////////////////////////////////////////////////////////
29 struct SourceRootInfo
{
30 explicit SourceRootInfo(Transport
* transport
);
31 SourceRootInfo(const std::string
&user
, const std::string
&sandbox
);
32 void createFromUserConfig();
33 void createFromCommonRoot(const String
&sandboxName
);
37 // Set SERVER variables in array, and return the modified version.
38 // You'll likely want to ensure the array coming in is a temporary
39 // (so it can be modified in place).
40 Array
setServerVariables(Array server
) const;
42 std::string
path() const;
44 bool sandboxOn() const {
45 return m_sandboxCond
== SandboxCondition::On
;
56 return m_sandboxCond
== SandboxCondition::Error
;
58 void handleError(Transport
*t
);
59 static const std::string
&GetCurrentSourceRoot() {
60 return s_path
.isNull() ? RuntimeOption::SourceRoot
: *s_path
;
63 static String
RelativeToPhpRoot(const String
& path
) {
64 String ret
= GetCurrentSourceRoot();
69 Eval::DSandboxInfo
getSandboxInfo() const;
72 static const std::string
& GetCurrentPhpRoot() {
73 return s_phproot
.isNull() ? initPhpRoot() : *s_phproot
;
80 enum class SandboxCondition
{
86 static THREAD_LOCAL_NO_CHECK(std::string
, s_path
);
87 static THREAD_LOCAL_NO_CHECK(std::string
, s_phproot
);
89 static std::string
& initPhpRoot();
90 std::string
parseSandboxServerVariable(const std::string
&format
) const;
93 ///////////////////////////////////////////////////////////////////////////////
96 #endif // incl_HPHP_SOURCE_ROOT_INFO_H_