1 /* 2 * Copyright (c) 2021-2024 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 #ifndef PANDA_FILESYSTEM_H 17 #define PANDA_FILESYSTEM_H 18 19 #include "libpandabase/macros.h" 20 #include <string> 21 22 #if defined(PANDA_TARGET_WINDOWS) 23 #ifndef NAME_MAX 24 constexpr size_t NAME_MAX = 255; 25 #endif // NAME_MAX 26 #elif defined(USE_STD_FILESYSTEM) 27 #include <filesystem> 28 #else 29 #include <experimental/filesystem> 30 #endif 31 32 namespace ark::os { 33 34 PANDA_PUBLIC_API std::string GetAbsolutePath(std::string_view path); 35 36 PANDA_PUBLIC_API void CreateDirectories(const std::string &folderName); 37 38 PANDA_PUBLIC_API bool IsFileExists(const std::string &filepath); 39 40 PANDA_PUBLIC_API std::string GetParentDir(const std::string &filepath); 41 42 PANDA_PUBLIC_API bool IsDirExists(const std::string &dirpath); 43 44 PANDA_PUBLIC_API std::string RemoveExtension(const std::string &filepath); 45 46 PANDA_PUBLIC_API std::string NormalizePath(const std::string &filepath); 47 48 // Get the current working directory of the running process 49 PANDA_PUBLIC_API std::string GetCurrentWorkingDirectory(); 50 51 // Change current working directory of the running process 52 PANDA_PUBLIC_API void ChangeCurrentWorkingDirectory(const std::string &path); 53 54 } // namespace ark::os 55 56 #endif // PANDA_FILESYSTEM_H 57