summaryrefslogtreecommitdiff
path: root/libs/utils/BackupData.cpp
diff options
context:
space:
mode:
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
commit9cda3e02c6154422abec1c3215b93cc6bb70d76a (patch)
tree1ee13094dcc54121c3c1096d0ec0b9540813e941 /libs/utils/BackupData.cpp
parent292ae4f642709eb42974d9c1a26ab80921518c54 (diff)
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/utils/BackupData.cpp')
-rw-r--r--libs/utils/BackupData.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/libs/utils/BackupData.cpp b/libs/utils/BackupData.cpp
index 6a7f056464..0868cff6c1 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);