MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getTempFileName

Method getTempFileName

src/App/DocumentPyImp.cpp:1027–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1025}
1026
1027PyObject* DocumentPy::getTempFileName(PyObject* args)
1028{
1029 PyObject* value;
1030 if (!PyArg_ParseTuple(args, "O", &value)) {
1031 return nullptr;
1032 }
1033
1034 std::string string;
1035 if (PyUnicode_Check(value)) {
1036 string = PyUnicode_AsUTF8(value);
1037 }
1038 else {
1039 std::string error = std::string("type must be a string!");
1040 error += value->ob_type->tp_name;
1041 throw Py::TypeError(error);
1042 }
1043
1044 // search for a temp file name in the document transient directory
1045 Base::FileInfo fileName(
1046 Base::FileInfo::getTempFileName(string.c_str(), getDocumentPtr()->TransientDir.getValue()));
1047 // delete the created file, we need only the name...
1048 fileName.deleteFile();
1049
1050 PyObject* p =
1051 PyUnicode_DecodeUTF8(fileName.filePath().c_str(), fileName.filePath().size(), nullptr);
1052 if (!p) {
1053 throw Base::UnicodeError("UTF8 conversion failure at PropertyString::getPyObject()");
1054 }
1055 return p;
1056}
1057
1058PyObject* DocumentPy::getCustomAttributes(const char* attr) const
1059{

Callers

nothing calls this directly

Calls 5

c_strMethod · 0.45
getValueMethod · 0.45
deleteFileMethod · 0.45
filePathMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected