diff options
Diffstat (limited to 'applypatch/include')
-rw-r--r-- | applypatch/include/applypatch/applypatch.h | 26 | ||||
-rw-r--r-- | applypatch/include/applypatch/imgdiff_image.h | 7 |
2 files changed, 20 insertions, 13 deletions
diff --git a/applypatch/include/applypatch/applypatch.h b/applypatch/include/applypatch/applypatch.h index 2a3b3ef39..6d7ffd78c 100644 --- a/applypatch/include/applypatch/applypatch.h +++ b/applypatch/include/applypatch/applypatch.h @@ -36,16 +36,16 @@ struct FileContents { struct stat st; }; -// When there isn't enough room on the target filesystem to hold the -// patched version of the file, we copy the original here and delete -// it to free up space. If the expected source file doesn't exist, or -// is corrupted, we look to see if this file contains the bits we want -// and use it as the source instead. -#define CACHE_TEMP_SOURCE "/cache/saved.file" +// When there isn't enough room on the target filesystem to hold the patched version of the file, +// we copy the original here and delete it to free up space. If the expected source file doesn't +// exist, or is corrupted, we look to see if the cached file contains the bits we want and use it as +// the source instead. The default location for the cached source is "/cache/saved.file". +extern std::string cache_temp_source; using SinkFn = std::function<size_t(const unsigned char*, size_t)>; // applypatch.cpp + int ShowLicenses(); size_t FreeSpaceForFile(const char* filename); int CacheSizeCheck(size_t bytes); @@ -67,15 +67,25 @@ int LoadFileContents(const char* filename, FileContents* file); int SaveFileContents(const char* filename, const FileContents* file); // bspatch.cpp + void ShowBSDiffLicense(); -int ApplyBSDiffPatch(const unsigned char* old_data, size_t old_size, const Value* patch, + +// Applies the bsdiff-patch given in 'patch' (from offset 'patch_offset' to the end) to the source +// data given by (old_data, old_size). Writes the patched output through the given 'sink', and +// updates the SHA-1 context with the output data. Returns 0 on success. +int ApplyBSDiffPatch(const unsigned char* old_data, size_t old_size, const Value& patch, size_t patch_offset, SinkFn sink, SHA_CTX* ctx); // imgpatch.cpp -int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value* patch, SinkFn sink, + +// Applies the imgdiff-patch given in 'patch' to the source data given by (old_data, old_size), with +// the optional bonus data. Writes the patched output through the given 'sink', and updates the +// SHA-1 context with the output data. Returns 0 on success. +int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value& patch, SinkFn sink, SHA_CTX* ctx, const Value* bonus_data); // freecache.cpp + int MakeFreeSpaceOnCache(size_t bytes_needed); #endif diff --git a/applypatch/include/applypatch/imgdiff_image.h b/applypatch/include/applypatch/imgdiff_image.h index 00a84f3a9..0f74420f0 100644 --- a/applypatch/include/applypatch/imgdiff_image.h +++ b/applypatch/include/applypatch/imgdiff_image.h @@ -62,10 +62,7 @@ class ImageChunk { const uint8_t* DataForPatch() const; size_t DataLengthForPatch() const; - void Dump() const { - printf("type: %d, start: %zu, len: %zu, name: %s\n", type_, start_, DataLengthForPatch(), - entry_name_.c_str()); - } + void Dump(size_t index) const; void SetUncompressedData(std::vector<uint8_t> data); bool SetBonusData(const std::vector<uint8_t>& bonus_data); @@ -140,7 +137,7 @@ class PatchChunk { private: size_t GetHeaderSize() const; - size_t WriteHeaderToFd(int fd, size_t offset) const; + size_t WriteHeaderToFd(int fd, size_t offset, size_t index) const; // The patch chunk type is the same as the target chunk type. The only exception is we change // the |type_| to CHUNK_RAW if target length is smaller than the patch size. |