/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
c10
/
util
/
/usr/local/lib64/python3.6/site-packages/torch/include/c10/util
mkdir
upload
Name
Size
Mode
Actions
accumulate.h
4205
0644
edit
dl
rm
AlignOf.h
4835
0644
edit
dl
rm
Array.h
11354
0644
edit
dl
rm
ArrayRef.h
9058
0644
edit
dl
rm
Backtrace.h
364
0644
edit
dl
rm
BFloat16-inl.h
9222
0644
edit
dl
rm
BFloat16-math.h
5217
0644
edit
dl
rm
BFloat16.h
2372
0644
edit
dl
rm
Bitset.h
3414
0644
edit
dl
rm
C++17.h
13329
0644
edit
dl
rm
complex.h
17542
0644
edit
dl
rm
complex_math.h
10902
0644
edit
dl
rm
complex_utils.h
958
0644
edit
dl
rm
ConstexprCrc.h
6633
0644
edit
dl
rm
copysign.h
866
0644
edit
dl
rm
DeadlockDetection.h
1920
0644
edit
dl
rm
Deprecated.h
3579
0644
edit
dl
rm
either.h
6423
0644
edit
dl
rm
env.h
835
0644
edit
dl
rm
Exception.h
24723
0644
edit
dl
rm
ExclusivelyOwned.h
4759
0644
edit
dl
rm
Flags.h
10056
0644
edit
dl
rm
flat_hash_map.h
61655
0644
edit
dl
rm
FunctionRef.h
2301
0644
edit
dl
rm
Half-inl.h
8674
0644
edit
dl
rm
Half.h
18965
0644
edit
dl
rm
hash.h
5084
0644
edit
dl
rm
IdWrapper.h
2348
0644
edit
dl
rm
intrusive_ptr.h
35563
0644
edit
dl
rm
in_place.h
350
0644
edit
dl
rm
irange.h
2679
0644
edit
dl
rm
LeftRight.h
6016
0644
edit
dl
rm
llvmMathExtras.h
29168
0644
edit
dl
rm
Logging.h
11256
0644
edit
dl
rm
logging_is_google_glog.h
2031
0644
edit
dl
rm
logging_is_not_google_glog.h
8271
0644
edit
dl
rm
MathConstants.h
858
0644
edit
dl
rm
math_compat.h
7296
0644
edit
dl
rm
MaybeOwned.h
6689
0644
edit
dl
rm
Metaprogramming.h
15288
0644
edit
dl
rm
numa.h
696
0644
edit
dl
rm
Optional.h
35592
0644
edit
dl
rm
order_preserving_flat_hash_map.h
65482
0644
edit
dl
rm
overloaded.h
709
0644
edit
dl
rm
python_stub.h
56
0644
edit
dl
rm
qint8.h
472
0644
edit
dl
rm
qint32.h
319
0644
edit
dl
rm
quint4x2.h
366
0644
edit
dl
rm
quint8.h
320
0644
edit
dl
rm
Registry.h
12242
0644
edit
dl
rm
reverse_iterator.h
8796
0644
edit
dl
rm
ScopeExit.h
1345
0644
edit
dl
rm
signal_handler.h
3154
0644
edit
dl
rm
SmallBuffer.h
1243
0644
edit
dl
rm
SmallVector.h
34456
0644
edit
dl
rm
sparse_bitset.h
26511
0644
edit
dl
rm
StringUtil.h
4538
0644
edit
dl
rm
string_utils.h
3989
0644
edit
dl
rm
string_view.h
20189
0644
edit
dl
rm
tempfile.h
6029
0644
edit
dl
rm
ThreadLocal.h
3883
0644
edit
dl
rm
ThreadLocalDebugInfo.h
2603
0644
edit
dl
rm
thread_name.h
148
0644
edit
dl
rm
Type.h
607
0644
edit
dl
rm
TypeCast.h
6972
0644
edit
dl
rm
typeid.h
18793
0644
edit
dl
rm
TypeIndex.h
5251
0644
edit
dl
rm
TypeList.h
16901
0644
edit
dl
rm
TypeTraits.h
5368
0644
edit
dl
rm
Unicode.h
295
0644
edit
dl
rm
UniqueVoidPtr.h
4117
0644
edit
dl
rm
Unroll.h
667
0644
edit
dl
rm
variant.h
95182
0644
edit
dl
rm
win32-headers.h
858
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/c10/util/tempfile.h
(6029B)
#pragma once #include <c10/util/Exception.h> #include <c10/util/Optional.h> #include <cerrno> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <utility> #include <vector> #if !defined(_WIN32) #include <unistd.h> #else // defined(_WIN32) #include <Windows.h> #include <fileapi.h> #endif // defined(_WIN32) namespace c10 { namespace detail { // Creates the filename pattern passed to and completed by `mkstemp`. // Returns std::vector<char> because `mkstemp` needs a (non-const) `char*` and // `std::string` only provides `const char*` before C++17. #if !defined(_WIN32) inline std::vector<char> make_filename(std::string name_prefix) { // The filename argument to `mkstemp` needs "XXXXXX" at the end according to // http://pubs.opengroup.org/onlinepubs/009695399/functions/mkstemp.html static const std::string kRandomPattern = "XXXXXX"; // We see if any of these environment variables is set and use their value, or // else default the temporary directory to `/tmp`. static const char* env_variables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"}; std::string tmp_directory = "/tmp"; for (const char* variable : env_variables) { if (const char* path = getenv(variable)) { tmp_directory = path; break; } } std::vector<char> filename; filename.reserve( tmp_directory.size() + name_prefix.size() + kRandomPattern.size() + 2); filename.insert(filename.end(), tmp_directory.begin(), tmp_directory.end()); filename.push_back('/'); filename.insert(filename.end(), name_prefix.begin(), name_prefix.end()); filename.insert(filename.end(), kRandomPattern.begin(), kRandomPattern.end()); filename.push_back('\0'); return filename; } #endif // !defined(_WIN32) } // namespace detail struct TempFile { #if !defined(_WIN32) TempFile() : fd(-1) {} TempFile(std::string name, int fd) : fd(fd), name(std::move(name)) {} TempFile(const TempFile&) = delete; TempFile(TempFile&& other) noexcept : fd(other.fd), name(std::move(other.name)) { other.fd = -1; other.name.clear(); } TempFile& operator=(const TempFile&) = delete; TempFile& operator=(TempFile&& other) { fd = other.fd; name = std::move(other.name); other.fd = -1; other.name.clear(); return *this; } ~TempFile() { if (fd >= 0) { unlink(name.c_str()); close(fd); } } int fd; #endif // !defined(_WIN32) std::string name; }; struct TempDir { TempDir() = default; explicit TempDir(std::string name) : name(std::move(name)) {} TempDir(const TempDir&) = delete; TempDir(TempDir&& other) noexcept : name(std::move(other.name)) { other.name.clear(); } TempDir& operator=(const TempDir&) = delete; TempDir& operator=(TempDir&& other) { name = std::move(other.name); other.name.clear(); return *this; } ~TempDir() { if (!name.empty()) { #if !defined(_WIN32) rmdir(name.c_str()); #else // defined(_WIN32) RemoveDirectoryA(name.c_str()); #endif // defined(_WIN32) } } std::string name; }; /// Attempts to return a temporary file or returns `nullopt` if an error /// occurred. /// /// The file returned follows the pattern /// `<tmp-dir>/<name-prefix><random-pattern>`, where `<tmp-dir>` is the value of /// the `"TMPDIR"`, `"TMP"`, `"TEMP"` or /// `"TEMPDIR"` environment variable if any is set, or otherwise `/tmp`; /// `<name-prefix>` is the value supplied to this function, and /// `<random-pattern>` is a random sequence of numbers. /// On Windows, `name_prefix` is ignored and `tmpnam` is used. inline c10::optional<TempFile> try_make_tempfile( std::string name_prefix = "torch-file-") { #if defined(_WIN32) return TempFile{std::tmpnam(nullptr)}; #else std::vector<char> filename = detail::make_filename(std::move(name_prefix)); const int fd = mkstemp(filename.data()); if (fd == -1) { return c10::nullopt; } // Don't make the string from string(filename.begin(), filename.end(), or // there will be a trailing '\0' at the end. return TempFile(filename.data(), fd); #endif // defined(_WIN32) } /// Like `try_make_tempfile`, but throws an exception if a temporary file could /// not be returned. inline TempFile make_tempfile(std::string name_prefix = "torch-file-") { if (auto tempfile = try_make_tempfile(std::move(name_prefix))) { return std::move(*tempfile); } TORCH_CHECK(false, "Error generating temporary file: ", std::strerror(errno)); } /// Attempts to return a temporary directory or returns `nullopt` if an error /// occurred. /// /// The directory returned follows the pattern /// `<tmp-dir>/<name-prefix><random-pattern>/`, where `<tmp-dir>` is the value /// of the `"TMPDIR"`, `"TMP"`, `"TEMP"` or /// `"TEMPDIR"` environment variable if any is set, or otherwise `/tmp`; /// `<name-prefix>` is the value supplied to this function, and /// `<random-pattern>` is a random sequence of numbers. /// On Windows, `name_prefix` is ignored and `tmpnam` is used. inline c10::optional<TempDir> try_make_tempdir( std::string name_prefix = "torch-dir-") { #if defined(_WIN32) while (true) { const char* dirname = std::tmpnam(nullptr); if (!dirname) { return c10::nullopt; } if (CreateDirectoryA(dirname, NULL)) { return TempDir(dirname); } if (GetLastError() != ERROR_ALREADY_EXISTS) { return c10::nullopt; } } return c10::nullopt; #else std::vector<char> filename = detail::make_filename(std::move(name_prefix)); const char* dirname = mkdtemp(filename.data()); if (!dirname) { return c10::nullopt; } return TempDir(dirname); #endif // defined(_WIN32) } /// Like `try_make_tempdir`, but throws an exception if a temporary directory /// could not be returned. inline TempDir make_tempdir(std::string name_prefix = "torch-dir-") { if (auto tempdir = try_make_tempdir(std::move(name_prefix))) { return std::move(*tempdir); } TORCH_CHECK( false, "Error generating temporary directory: ", std::strerror(errno)); } } // namespace c10
Save
cmd:
run