summaryrefslogtreecommitdiff
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
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.
-rw-r--r--include/utils/BackupHelpers.h3
-rw-r--r--libs/utils/BackupData.cpp21
2 files changed, 21 insertions, 3 deletions
diff --git a/include/utils/BackupHelpers.h b/include/utils/BackupHelpers.h
index c78b99a8dc..a21359f55e 100644
--- a/include/utils/BackupHelpers.h
+++ b/include/utils/BackupHelpers.h
@@ -71,6 +71,8 @@ public:
status_t WriteEntityHeader(const String8& key, size_t dataSize);
status_t WriteEntityData(const void* data, size_t size);
+ void SetKeyPrefix(const String8& keyPrefix);
+
private:
explicit BackupDataWriter();
status_t write_padding_for(int n);
@@ -79,6 +81,7 @@ private:
status_t m_status;
ssize_t m_pos;
int m_entityCount;
+ String8 m_keyPrefix;
};
/**
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);