Exemple #1
0
    bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes)
    {
        if (file.getSize() == numBytes)
        {
            MemoryInputStream newStream (data, numBytes, false);

            if (calculateStreamHashCode (newStream) == calculateFileHashCode (file))
                return true;
        }

        TemporaryFile temp (file);

        return temp.getFile().appendData (data, numBytes)
                 && temp.overwriteTargetFileWithTemporary();
    }
 int64 calculateFileHashCode (const File& file)
 {
     ScopedPointer <FileInputStream> stream (file.createInputStream());
     return stream != nullptr ? calculateStreamHashCode (*stream) : 0;
 }
Exemple #3
0
 int64 calculateFileHashCode (const File& file)
 {
     std::unique_ptr<FileInputStream> stream (file.createInputStream());
     return stream != nullptr ? calculateStreamHashCode (*stream) : 0;
 }