scoped_temporary_file.h 906 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SANDBOX_LINUX_TESTS_SCOPED_TEMPORARY_FILE_H_
  5. #define SANDBOX_LINUX_TESTS_SCOPED_TEMPORARY_FILE_H_
  6. namespace sandbox {
  7. // Creates and open a temporary file on creation and closes
  8. // and removes it on destruction.
  9. // Unlike base/ helpers, this does not require JNI on Android.
  10. class ScopedTemporaryFile {
  11. public:
  12. ScopedTemporaryFile();
  13. ScopedTemporaryFile(const ScopedTemporaryFile&) = delete;
  14. ScopedTemporaryFile& operator=(const ScopedTemporaryFile&) = delete;
  15. ~ScopedTemporaryFile();
  16. int fd() const { return fd_; }
  17. const char* full_file_name() const { return full_file_name_; }
  18. private:
  19. int fd_;
  20. char full_file_name_[128];
  21. };
  22. } // namespace sandbox
  23. #endif // SANDBOX_LINUX_TESTS_SCOPED_TEMPORARY_FILE_H_