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

Commit 2b3c2f7d authored by Yabin Cui's avatar Yabin Cui Committed by android-build-merger
Browse files

Merge "base: Add TemporaryFile::DoNotRemove()." am: 04bf0237 am: 8e7844d6

am: 2ff3196f

Change-Id: I7f505f375e76059e7f52d11e362b3208f82e53e1
parents a6e21160 2ff3196f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ class TemporaryFile {
  // Release the ownership of fd, caller is reponsible for closing the
  // fd or stream properly.
  int release();
  // Don't remove the temporary file in the destructor.
  void DoNotRemove() { remove_file_ = false; }

  int fd;
  char path[1024];
@@ -38,6 +40,8 @@ class TemporaryFile {
 private:
  void init(const std::string& tmp_dir);

  bool remove_file_ = true;

  DISALLOW_COPY_AND_ASSIGN(TemporaryFile);
};

+3 −1
Original line number Diff line number Diff line
@@ -92,8 +92,10 @@ TemporaryFile::~TemporaryFile() {
  if (fd != -1) {
    close(fd);
  }
  if (remove_file_) {
    unlink(path);
  }
}

int TemporaryFile::release() {
  int result = fd;