1 /** 2 * Copyright 2019 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_UTILS_SYSTEM_ENV_H_ 18 #define MINDSPORE_CCSRC_UTILS_SYSTEM_ENV_H_ 19 20 #include <memory> 21 #include "utils/system/base.h" 22 #include "utils/log_adapter.h" 23 #include "utils/system/file_system.h" 24 25 namespace mindspore { 26 namespace system { 27 // Confirm the system env and create the filesystem, time... 28 class Env { 29 public: Env()30 Env() { platform_ = Platform::get_platform(); } 31 virtual ~Env() = default; 32 GetFileSystem()33 static std::shared_ptr<FileSystem> GetFileSystem() { 34 #if defined(SYSTEM_ENV_POSIX) 35 auto fs = std::make_shared<PosixFileSystem>(); 36 return fs; 37 #elif defined(SYSTEM_ENV_WINDOWS) 38 auto fs = std::make_shared<WinFileSystem>(); 39 return fs; 40 #else 41 MS_LOG(EXCEPTION) << "Now not support the platform."; 42 #endif 43 } 44 45 private: 46 PlatformDefine platform_; 47 }; 48 49 } // namespace system 50 } // namespace mindspore 51 52 #endif // MINDSPORE_CCSRC_UTILS_SYSTEM_ENV_H_ 53