Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e05e558 authored by David Anderson's avatar David Anderson
Browse files

liblp: Replace some |const char*| inputs with std::string.

Bug: 134536978
Test: builds
Change-Id: I23dba6747be334f42506f969d6d52b293c69f0bd
parent acf19e80
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -89,8 +89,8 @@ bool WriteToImageFile(int fd, const LpMetadata& input) {
    return true;
}

bool WriteToImageFile(const char* file, const LpMetadata& input) {
    unique_fd fd(open(file, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
bool WriteToImageFile(const std::string& file, const LpMetadata& input) {
    unique_fd fd(open(file.c_str(), O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
    if (fd < 0) {
        PERROR << __PRETTY_FUNCTION__ << " open failed: " << file;
        return false;
@@ -149,8 +149,8 @@ bool ImageBuilder::IsValid() const {
    return device_images_.size() == metadata_.block_devices.size();
}

bool ImageBuilder::Export(const char* file) {
    unique_fd fd(open(file, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
bool ImageBuilder::Export(const std::string& file) {
    unique_fd fd(open(file.c_str(), O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, 0644));
    if (fd < 0) {
        PERROR << "open failed: " << file;
        return false;
@@ -438,7 +438,7 @@ int ImageBuilder::OpenImageFile(const std::string& file) {
    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) {
    ImageBuilder builder(metadata, block_size, images, sparsify);
    return builder.IsValid() && builder.Build() && builder.Export(file);
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ class ImageBuilder {
                 const std::map<std::string, std::string>& images, bool sparsify);

    bool Build();
    bool Export(const char* file);
    bool Export(const std::string& file);
    bool ExportFiles(const std::string& dir);
    bool IsValid() const;

+2 −2
Original line number Diff line number Diff line
@@ -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
// 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);
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> ReadFromImageBlob(const void* data, size_t bytes);