Ejemplo n.º 1
0
PWIZ_API_DECL void calculateSourceFileSHA1(SourceFile& sourceFile)
{
    if (sourceFile.hasCVParam(MS_SHA_1)) return;

    const string uriPrefix = "file://";
    if (sourceFile.location.find(uriPrefix) != 0) return;
    bfs::path p(sourceFile.location.substr(uriPrefix.size()));
    p /= sourceFile.name;

    try
    {
        if (!bfs::exists(p))
            // TODO: log warning about source file not available
            return;
    }
    catch (exception&)
    {
        // TODO: log warning about filesystem error
        return;
    }

    string sha1 = SHA1Calculator::hashFile(p.string());
    sourceFile.set(MS_SHA_1, sha1); 
}