1 // Copyright (C) 2015 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include "aemu/base/files/PathUtils.h"
18 #include "aemu/base/system/System.h"
19 #include "aemu/base/threads/Thread.h"
20 
21 #include "TestTempDir.h"
22 
23 namespace android {
24 namespace base {
25 
26 class TestSystem {
27 public:
getTempRoot()28     TestTempDir* getTempRoot() const {
29         if (!mTempDir) {
30             mTempDir = new TestTempDir("TestSystem");
31             mTempRootPrefix = PathUtils::addTrailingDirSeparator(mTempDir->pathString());
32         }
33         return mTempDir;
34     }
35 
~TestSystem()36     ~TestSystem() {
37         if (mTempDir) delete mTempDir;
38     }
39 private:
40 
41     mutable TestTempDir* mTempDir = nullptr;
42     mutable std::string mTempRootPrefix;
43 };
44 
45 }  // namespace base
46 }  // namespace android
47