示例#1
0
//!
//! Add files in given directory to the zip. A compression level can be specified to
//! dictate how much the files will be compressed. Use -1 for default compression, 0
//! for no compression, and 1 through 9 for minimal to maximal compression. Behavior
//! is unpredictable for other compression levels. Return true if successful.
//!
bool Zipped::addDirectory(const wchar_t* inDir, int compressionLevel)
{
    wchar_t normalized[MAX_PATH_LENGTH + MAX_BASENAME_LENGTH + 1];
    size_t length = normalizeDir(normalized, inDir);
    wchar_t* basename = normalized + length;
    wcscpy_s(basename, MAX_BASENAME_LENGTH + 1, L"*.*");

    WIN32_FIND_DATAW found;
    HANDLE h = FindFirstFileW(normalized, &found);
    bool ok = (h != INVALID_HANDLE_VALUE);
    if (!ok)
    {
        return ok;
    }

    do
    {
        if ((found.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
        {
            filetime_t filetime = {found.ftLastWriteTime};
            wcscpy_s(basename, MAX_BASENAME_LENGTH + 1, found.cFileName);
            bool readOnly = true;
            MappedFile item(normalized, readOnly, mapSize_);
            ok = zipItem(item, basename, compressionLevel, filetime.ft64);
        }
    } while (ok && (FindNextFileW(h, &found) != 0));

    FindClose(h);
    return ok;
}
示例#2
0
文件: coleitr.cpp 项目: winlibs/icu4c
UBool CollationElementIterator::operator==(
                                    const CollationElementIterator& that) const
{
    if (this == &that) {
        return TRUE;
    }

    return
        (rbc_ == that.rbc_ || *rbc_ == *that.rbc_) &&
        otherHalf_ == that.otherHalf_ &&
        normalizeDir() == that.normalizeDir() &&
        string_ == that.string_ &&
        *iter_ == *that.iter_;
}