MCPcopy Create free account
hub / github.com/3rdparty/libprocess / getTemporaryDirectoryPath

Function getTemporaryDirectoryPath

src/memory_profiler.cpp:280–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278
279
280Try<Path> getTemporaryDirectoryPath() {
281 if (temporaryDirectory.isSome()) {
282 return temporaryDirectory.get();
283 }
284
285 // TODO(bevers): Add a libprocess-specific override for the system-wide
286 // `TMPDIR`, for example `LIBPROCESS_TMPDIR`.
287 const string tmpdir =
288 os::getenv("TMPDIR").getOrElse(LIBPROCESS_DEFAULT_TMPDIR);
289
290 const string pathTemplate = path::join(tmpdir, "libprocess.XXXXXX");
291
292 // TODO(bevers): Add an atexit-handler that cleans up the directory.
293 Try<string> dir = os::mkdtemp(pathTemplate);
294 if (dir.isError()) {
295 return Error(dir.error());
296 }
297
298 temporaryDirectory = dir.get();
299
300 VLOG(1) << "Using path " << dir.get() << " to store temporary files";
301
302 return temporaryDirectory.get();
303}
304
305
306// TODO(alexr): Consider making this asynchronous.

Callers 1

createMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected