Creates and opens a temporary file in |directory|, returning the file descriptor. |path| is set to the temporary file path. This function does NOT unlink() the file.
| 145 | // file descriptor. |path| is set to the temporary file path. |
| 146 | // This function does NOT unlink() the file. |
| 147 | int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) { |
| 148 | ThreadRestrictions::AssertIOAllowed(); // For call to mkstemp(). |
| 149 | *path = directory.Append(butil::TempFileName()); |
| 150 | const std::string& tmpdir_string = path->value(); |
| 151 | // this should be OK since mkstemp just replaces characters in place |
| 152 | char* buffer = const_cast<char*>(tmpdir_string.c_str()); |
| 153 | |
| 154 | return HANDLE_EINTR(mkstemp(buffer)); |
| 155 | } |
| 156 | |
| 157 | #if defined(OS_LINUX) |
| 158 | // Determine if /dev/shm files can be mapped and then mprotect'd PROT_EXEC. |
no test coverage detected