Merge "liblp: Replace some |const char*| inputs with std::string."
This commit is contained in:
commit
7a6ce0623f
3 changed files with 8 additions and 8 deletions
|
|
@ -89,8 +89,8 @@ bool WriteToImageFile(int fd, const LpMetadata& input) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteToImageFile(const char* file, const LpMetadata& input) {
|
bool WriteToImageFile(const std::string& file, const LpMetadata& input) {
|
||||||
unique_fd fd(open(file, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
|
unique_fd fd(open(file.c_str(), O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
PERROR << __PRETTY_FUNCTION__ << " open failed: " << file;
|
PERROR << __PRETTY_FUNCTION__ << " open failed: " << file;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -149,8 +149,8 @@ bool ImageBuilder::IsValid() const {
|
||||||
return device_images_.size() == metadata_.block_devices.size();
|
return device_images_.size() == metadata_.block_devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageBuilder::Export(const char* file) {
|
bool ImageBuilder::Export(const std::string& file) {
|
||||||
unique_fd fd(open(file, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
|
unique_fd fd(open(file.c_str(), O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
PERROR << "open failed: " << file;
|
PERROR << "open failed: " << file;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -438,7 +438,7 @@ int ImageBuilder::OpenImageFile(const std::string& file) {
|
||||||
return temp_fds_.back().get();
|
return temp_fds_.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteToImageFile(const char* file, const LpMetadata& metadata, uint32_t block_size,
|
bool WriteToImageFile(const std::string& file, const LpMetadata& metadata, uint32_t block_size,
|
||||||
const std::map<std::string, std::string>& images, bool sparsify) {
|
const std::map<std::string, std::string>& images, bool sparsify) {
|
||||||
ImageBuilder builder(metadata, block_size, images, sparsify);
|
ImageBuilder builder(metadata, block_size, images, sparsify);
|
||||||
return builder.IsValid() && builder.Build() && builder.Export(file);
|
return builder.IsValid() && builder.Build() && builder.Export(file);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class ImageBuilder {
|
||||||
const std::map<std::string, std::string>& images, bool sparsify);
|
const std::map<std::string, std::string>& images, bool sparsify);
|
||||||
|
|
||||||
bool Build();
|
bool Build();
|
||||||
bool Export(const char* file);
|
bool Export(const std::string& file);
|
||||||
bool ExportFiles(const std::string& dir);
|
bool ExportFiles(const std::string& dir);
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,9 @@ std::unique_ptr<LpMetadata> ReadMetadata(const std::string& super_partition, uin
|
||||||
|
|
||||||
// Read/Write logical partition metadata to an image file, for diagnostics or
|
// Read/Write logical partition metadata to an image file, for diagnostics or
|
||||||
// flashing.
|
// flashing.
|
||||||
bool WriteToImageFile(const char* file, const LpMetadata& metadata, uint32_t block_size,
|
bool WriteToImageFile(const std::string& file, const LpMetadata& metadata, uint32_t block_size,
|
||||||
const std::map<std::string, std::string>& images, bool sparsify);
|
const std::map<std::string, std::string>& images, bool sparsify);
|
||||||
bool WriteToImageFile(const char* file, const LpMetadata& metadata);
|
bool WriteToImageFile(const std::string& file, const LpMetadata& metadata);
|
||||||
std::unique_ptr<LpMetadata> ReadFromImageFile(const std::string& image_file);
|
std::unique_ptr<LpMetadata> ReadFromImageFile(const std::string& image_file);
|
||||||
std::unique_ptr<LpMetadata> ReadFromImageBlob(const void* data, size_t bytes);
|
std::unique_ptr<LpMetadata> ReadFromImageBlob(const void* data, size_t bytes);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue