• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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 
16 #include "js_ability.h"
17 
18 #include <cstdlib>
19 
20 #include "js_logger.h"
21 
22 namespace OHOS {
23 namespace PreferencesJsKit {
Context()24 Context::Context()
25 {
26     std::string baseDir = "";
27 #ifdef WINDOWS_PLATFORM
28     baseDir = getenv("TEMP");
29     if (!baseDir.empty()) {
30         preferencesDir_ = baseDir + "\\HuaweiDevEcoStudioPreferences";
31     }
32 #endif
33 
34 #ifdef MAC_PLATFORM
35     baseDir = getenv("LOGNAME");
36     baseDir = "/Users/" + baseDir + "/Library/Caches";
37     if (!baseDir.empty()) {
38         preferencesDir_ = baseDir + "/HuaweiDevEcoStudioPreferences";
39     }
40 #endif
41 }
42 
GetPreferencesDir()43 std::string Context::GetPreferencesDir()
44 {
45     return preferencesDir_;
46 }
47 
CheckContext(napi_env env,napi_callback_info info)48 bool JSAbility::CheckContext(napi_env env, napi_callback_info info)
49 {
50     return true;
51 }
52 
GetContext(napi_env env,napi_value value)53 std::shared_ptr<Context> JSAbility::GetContext(napi_env env, napi_value value)
54 {
55     return std::make_shared<Context>();
56 }
57 } // namespace PreferencesJsKit
58 } // namespace OHOS
59