* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ------------------------------------------------------------------------- */
#ifndef FILE_H
#define FILE_H
#include <fcntl.h>
#include <unistd.h>
#include <fstream>
#include <string>
#include <vector>
#include "ait_logger.h"
#include "const.h"
namespace File
{
bool CreateDir(const std::string& path, bool recursion = false, mode_t mode = MsConst::NORMAL_DIR_MODE_DEFAULT);
bool CheckDir(const std::string& path);
bool IsFileReadable(const std::string& path);
bool IsFileWritable(const std::string& path);
bool IsOtherWritable(const std::string& path);
bool IsPathExist(const std::string& path);
bool IsDir(const std::string& path);
bool CheckOwner(const std::string& path);
std::string GetParentDir(const std::string& path);
std::string GetFullPath(const std::string& originPath);
std::string GetAbsPath(const std::string& originPath);
size_t GetFileSize(const std::string& path);
bool IsPathLengthLegal(const std::string& path);
bool IsPathCharactersValid(const std::string& path);
bool IsPathDepthValid(const std::string& path);
bool IsRegularFile(const std::string& path);
std::string GetFileName(const std::string& path);
mode_t GetPathPermissions(const std::string& path);
std::string GetFileSuffix(const std::string& path);
bool CheckFileSuffixAndSize(const std::string& path, MsConst::SUFFIX type, const size_t maxSize);
bool CheckFileBeforeRead(const std::string& path, MsConst::SUFFIX type, const size_t maxSize);
bool CheckFileBeforeCreateOrWrite(const std::string& path, bool overwrite = false);
bool CheckConfigFile(const std::string& absPath, const size_t maxSize = MsConst::MAX_JSON_SIZE);
bool WriteTextToFile(const std::string& filePath, const std::string& textContent);
};
#endif