当前位置: 首页>>代码示例>>C++>>正文


C++ Path::AsString方法代码示例

本文整理汇总了C++中Path::AsString方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::AsString方法的具体用法?C++ Path::AsString怎么用?C++ Path::AsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path::AsString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

File_SDMC::File_SDMC(const Archive_SDMC* archive, const Path& path, const Mode mode) {
    // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass
    // the root directory we set while opening the archive.
    // For example, opening /../../etc/passwd can give the emulated program your users list.
    this->path = archive->GetMountPoint() + path.AsString();
    this->mode.hex = mode.hex;
}
开发者ID:Denu8thell,项目名称:citra,代码行数:7,代码来源:file_sdmc.cpp

示例2:

PathParser::PathParser(const Path& path) {
    if (path.GetType() != LowPathType::Char && path.GetType() != LowPathType::Wchar) {
        is_valid = false;
        return;
    }

    auto path_string = path.AsString();
    if (path_string.size() == 0 || path_string[0] != '/') {
        is_valid = false;
        return;
    }

    // Filter out invalid characters for the host system.
    // Although some of these characters are valid on 3DS, they are unlikely to be used by games.
    if (std::find_if(path_string.begin(), path_string.end(), [](char c) {
            static const std::set<char> invalid_chars{'<', '>', '\\', '|', ':', '\"', '*', '?'};
            return invalid_chars.find(c) != invalid_chars.end();
        }) != path_string.end()) {
        is_valid = false;
        return;
    }

    Common::SplitString(path_string, '/', path_sequence);

    auto begin = path_sequence.begin();
    auto end = path_sequence.end();
    end = std::remove_if(begin, end, [](std::string& str) { return str == "" || str == "."; });
    path_sequence = std::vector<std::string>(begin, end);

    // checks if the path is out of bounds.
    int level = 0;
    for (auto& node : path_sequence) {
        if (node == "..") {
            --level;
            if (level < 0) {
                is_valid = false;
                return;
            }
        } else {
            ++level;
        }
    }

    is_valid = true;
    is_root = level == 0;
}
开发者ID:DaMan69,项目名称:citra,代码行数:46,代码来源:path_parser.cpp

示例3: CreateDirectory

ResultCode SaveDataArchive::CreateDirectory(const Path& path) const {
    const PathParser path_parser(path);

    if (!path_parser.IsValid()) {
        LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
        return ERROR_INVALID_PATH;
    }

    const auto full_path = path_parser.BuildHostPath(mount_point);

    switch (path_parser.GetHostStatus(mount_point)) {
    case PathParser::InvalidMountPoint:
        LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
        return ERROR_FILE_NOT_FOUND;
    case PathParser::PathNotFound:
        LOG_ERROR(Service_FS, "Path not found {}", full_path);
        return ERROR_PATH_NOT_FOUND;
    case PathParser::FileInPath:
        LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path);
        return ERROR_UNEXPECTED_FILE_OR_DIRECTORY;
    case PathParser::DirectoryFound:
    case PathParser::FileFound:
        LOG_ERROR(Service_FS, "{} already exists", full_path);
        return ERROR_DIRECTORY_ALREADY_EXISTS;
    case PathParser::NotFound:
        break; // Expected 'success' case
    }

    if (FileUtil::CreateDir(mount_point + path.AsString())) {
        return RESULT_SUCCESS;
    }

    LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point);
    return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled,
                      ErrorLevel::Status);
}
开发者ID:Dragios,项目名称:Citra,代码行数:36,代码来源:savedata_archive.cpp

示例4: CreateDirectory

/**
 * Create a directory specified by its path
 * @param path Path relative to the archive
 * @return Whether the directory could be created
 */
bool Archive_SDMC::CreateDirectory(const Path& path) const {
    return FileUtil::CreateDir(GetMountPoint() + path.AsString());
}
开发者ID:Denu8thell,项目名称:citra,代码行数:8,代码来源:archive_sdmc.cpp

示例5: RenameDirectory

bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
    return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString());
}
开发者ID:HT395925N,项目名称:citra,代码行数:3,代码来源:disk_archive.cpp

示例6: CreateDirectory

bool DiskArchive::CreateDirectory(const Path& path) const {
    return FileUtil::CreateDir(mount_point + path.AsString());
}
开发者ID:HT395925N,项目名称:citra,代码行数:3,代码来源:disk_archive.cpp

示例7: DeleteFile

bool DiskArchive::DeleteFile(const Path& path) const {
    return FileUtil::Delete(mount_point + path.AsString());
}
开发者ID:HT395925N,项目名称:citra,代码行数:3,代码来源:disk_archive.cpp

示例8: directory

DiskDirectory::DiskDirectory(const DiskArchive& archive, const Path& path) : directory() {
    // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass
    // the root directory we set while opening the archive.
    // For example, opening /../../usr/bin can give the emulated program your installed programs.
    this->path = archive.mount_point + path.AsString();
}
开发者ID:HT395925N,项目名称:citra,代码行数:6,代码来源:disk_archive.cpp


注:本文中的Path::AsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。