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

Commit 92542d13 authored by Greg Kaiser's avatar Greg Kaiser Committed by Martin Brabham
Browse files

[DO NOT MERGE] btif: Lighter weight file existence check

We switch from the heavier weight fopen() to using access() to
check for file existence and readability.  This avoids some of
the file opening overhead we don't need here.

Bug: b/117993149
Test: TreeHugger
Change-Id: Ib47b24e9d96803b7822535f9f566aa7818b38953
Merged-In: Ib47b24e9d96803b7822535f9f566aa7818b38953
parent eb2db286
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -604,11 +604,8 @@ static std::string hash_file(const char* filename) {


static std::string read_checksum_file(const char* checksum_filename) {
static std::string read_checksum_file(const char* checksum_filename) {
  // Ensure file exists
  // Ensure file exists
  FILE* fp = fopen(checksum_filename, "rb");
  if (access(checksum_filename, R_OK) != 0) {
  if (!fp) {
    return "";
    return "";
  } else {
    fclose(fp);
  }
  }
  std::string output = btifKeystore.Decrypt(checksum_filename);
  std::string output = btifKeystore.Decrypt(checksum_filename);
  return output;
  return output;