MCPcopy Create free account
hub / github.com/apache/brpc / CreateAndOpenFdForTemporaryFile

Function CreateAndOpenFdForTemporaryFile

src/butil/file_util_posix.cc:147–155  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

145// file descriptor. |path| is set to the temporary file path.
146// This function does NOT unlink() the file.
147int 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.

Callers 4

CreateTemporaryFileFunction · 0.85
CreateTemporaryFileInDirFunction · 0.85

Calls 5

AssertIOAllowedFunction · 0.85
TempFileNameFunction · 0.85
AppendMethod · 0.45
valueMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected