自动创建文件夹

class test {
private:
    test();
    ~test();  
    bool EnsureDirectoryExists(const std::string& path);
    static const std::string filePath;  
};

const std::string test::FilePath = "\database\\";

bool test::EnsureDirectoryExists(const std::string& path)
{
    if (_access(path.c_str(), 0) != 0) {
        if (_mkdir(path.c_str()) != 0) {
            LOGGER_ERROR("Failed to create directory.");
            return false;
        }
    }
    return true;
}

 

posted @ 2024-08-01 20:38  素装写淡定  阅读(24)  评论(0)    收藏  举报