diff options
author | Joe Onorato <joeo@android.com> | 2009-06-18 20:10:37 -0700 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2009-06-22 13:02:24 -0700 |
commit | 9cda3e02c6154422abec1c3215b93cc6bb70d76a (patch) | |
tree | 1ee13094dcc54121c3c1096d0ec0b9540813e941 /libs | |
parent | 292ae4f642709eb42974d9c1a26ab80921518c54 (diff) | |
download | frameworks_native-9cda3e02c6154422abec1c3215b93cc6bb70d76a.zip frameworks_native-9cda3e02c6154422abec1c3215b93cc6bb70d76a.tar.gz frameworks_native-9cda3e02c6154422abec1c3215b93cc6bb70d76a.tar.bz2 |
Helper API cleanup. Allows multiple helpers to function,
because they'll always go in the same order, and this lets
us not have to write headers to keep them paired.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/BackupData.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libs/utils/BackupData.cpp b/libs/utils/BackupData.cpp index 6a7f056..0868cff 100644 --- a/libs/utils/BackupData.cpp +++ b/libs/utils/BackupData.cpp @@ -99,10 +99,20 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) return amt; } + String8 k; + if (m_keyPrefix.length() > 0) { + k = m_keyPrefix; + k += ":"; + k += key; + } else { + k = key; + } + LOGD("m_keyPrefix=%s key=%s k=%s", m_keyPrefix.string(), key.string(), k.string()); + entity_header_v1 header; ssize_t keyLen; - keyLen = key.length(); + keyLen = k.length(); header.type = tolel(BACKUP_HEADER_ENTITY_V1); header.keyLen = tolel(keyLen); @@ -115,7 +125,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) } m_pos += amt; - amt = write(m_fd, key.string(), keyLen+1); + amt = write(m_fd, k.string(), keyLen+1); if (amt != keyLen+1) { m_status = errno; return m_status; @@ -148,6 +158,11 @@ BackupDataWriter::WriteEntityData(const void* data, size_t size) return NO_ERROR; } +void +BackupDataWriter::SetKeyPrefix(const String8& keyPrefix) +{ + m_keyPrefix = keyPrefix; +} BackupDataReader::BackupDataReader(int fd) @@ -298,7 +313,7 @@ BackupDataReader::ReadEntityData(void* data, size_t size) if (remaining <= 0) { return 0; } - if (size > remaining) { + if (((int)size) > remaining) { size = remaining; } //LOGD(" reading %d bytes", size); |