Пример #1
0
void CatCommand::run(const ResourceFork& rsrc, const Options& options) const {
    const ResourceEntry& entry = rsrc.at(_type).at(_id);
    BytesSlice data = entry.data();
    if (write(1, data.data(), data.size()) < 0) {
        // TODO(sfiera): handle result properly.
    }
}
Пример #2
0
void LsCommand::run(const ResourceFork& rsrc, const Options& options) const {
    if (!_type.has_value()) {
        for (const ResourceType& type : rsrc) {
            pn::format(stdout, "{0}\n", type.code());
        }
        return;
    }

    const ResourceType& type = rsrc.at(*_type);
    if (!_id.has_value()) {
        for (const ResourceEntry& entry : type) {
            pn::format(stdout, "{0}\t{1}\n", entry.id(), entry.name());
        }
        return;
    }

    const ResourceEntry& entry = type.at(*_id);
    pn::format(stdout, "{0}\t{1}\n", entry.id(), entry.name());
}