예제 #1
0
int main(int argc, char *argv[]) {
    if(argc < 3)
        return usage(argv);

    int c;
    int is_se{0};
    char out_mode[4] = "wb";
    opts_t opts;
    while((c = getopt(argc, argv, "m:l:h?sSn")) > -1) {
        switch(c) {
        case 'm': opts.min_trimmed_len = (uint32_t)atoi(optarg); break;
        case 'l': out_mode[2] = *optarg; break;
        case 's': is_se = 1; break;
        case 'S': sprintf(out_mode, "w"); break;
        case 'n': opts.skip_all_ns = 1; break;
        case 'h': case '?': return usage(argv, EXIT_SUCCESS);
        }
    }

    if(argc - 2 != optind) LOG_EXIT("Required: precisely two positional arguments (in bam, out bam).\n");

    dlib::BamHandle inHandle(argv[optind]);
    dlib::BamHandle outHandle(argv[optind + 1], inHandle.header, out_mode);
    is_se ? dlib::abstract_single_iter(inHandle.fp, inHandle.header, outHandle.fp, &trim_ns, (void *)&opts)
          : dlib::abstract_pair_iter(inHandle.fp, inHandle.header, outHandle.fp, &pe_trim_ns, (void *)&opts);
    return EXIT_SUCCESS;
}
예제 #2
0
파일: main.cpp 프로젝트: Rohansi/LoonyOS
exp bool CopyOut(const char* source, const char* dest) {
    // Convert the filename into DOS8.3 format
    char* dosName = new char[12];
    ToDos83Name(source, dosName);

    // Find the file on the disk
    DirectoryEntry* entry = FindEntry(dosName, &directory);
    if (!entry) {
        LastError("CopyOut", "File doesn't exist");
        return false;
    }

    if (!(entry->attrib & ATTRIB_ARCHIVE)) {
        LastError("CopyOut", "This is not a file");
        return false;
    }

    // Update the entry
    UpdateEntry(entry, 0, 0);

    std::ofstream outHandle(dest, std::ios::out | std::ios::binary);
    if (!outHandle.is_open())
        return false;

    // Set up a FatEntry
    FatEntry fatEntry;
    fatEntry.cluster = GetClusterFromEntry(entry);
    fatEntry.sector = GetFATSector(fatEntry.cluster);
    fatEntry.buffer = new char[bpb->bytesPerSector];
    ReadSector(fatEntry.buffer, fatEntry.sector);

    char* sectorData = new char[bpb->bytesPerSector];

    // Read Data
    while (ReadCluster(&fatEntry, sectorData))
        outHandle.write(sectorData, 512);

    if (!(entry->size % bpb->bytesPerSector))
        outHandle.write(sectorData, 512);
    else
        outHandle.write(sectorData, entry->size % bpb->bytesPerSector);

    delete[] fatEntry.buffer;
    delete[] sectorData;
    delete[] dosName;

    outHandle.close();

    return true;
}