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 5 #ifndef SANDBOX_LINUX_TESTS_SCOPED_TEMPORARY_FILE_H_ 6 #define SANDBOX_LINUX_TESTS_SCOPED_TEMPORARY_FILE_H_ 7 8 #include "base/macros.h" 9 10 namespace sandbox { 11 // Creates and open a temporary file on creation and closes 12 // and removes it on destruction. 13 // Unlike base/ helpers, this does not require JNI on Android. 14 class ScopedTemporaryFile { 15 public: 16 ScopedTemporaryFile(); 17 ~ScopedTemporaryFile(); 18 fd()19 int fd() const { return fd_; } full_file_name()20 const char* full_file_name() const { return full_file_name_; } 21 22 private: 23 int fd_; 24 char full_file_name_[128]; 25 DISALLOW_COPY_AND_ASSIGN(ScopedTemporaryFile); 26 }; 27 28 } // namespace sandbox 29 30 #endif // SANDBOX_LINUX_TESTS_SCOPED_TEMPORARY_FILE_H_ 31