MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / xnLogCreateNewFile

Function xnLogCreateNewFile

Source/OpenNI/XnLog.cpp:234–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234XN_C_API XnStatus XN_C_DECL xnLogCreateNewFile(const XnChar* strName, XnBool bSessionBased, XnChar* csFullPath, XnUInt32 nPathBufferSize, XN_FILE_HANDLE* phFile)
235{
236 XnStatus nRetVal = XN_STATUS_OK;
237
238 LogData& logData = LogData::GetInstance();
239
240 // set log directory
241 if (logData.strLogDir[0] == '\0')
242 {
243 nRetVal = xnLogSetOutputFolder(XN_LOG_DIR_NAME);
244 XN_IS_STATUS_OK(nRetVal);
245 }
246
247 if (logData.strSessionTimestamp[0] == '\0')
248 {
249 time_t currtime;
250 time(&currtime);
251 strftime(logData.strSessionTimestamp, sizeof(logData.strSessionTimestamp)-1, "%Y_%m_%d__%H_%M_%S", localtime(&currtime));
252 }
253
254 XN_PROCESS_ID nProcID = 0;
255 xnOSGetCurrentProcessID(&nProcID);
256
257 // create full path file name - add process start time and process ID
258 XnUInt32 nPathSize = 0;
259 XnUInt32 nCharsWritten = 0;
260 nRetVal = xnOSStrFormat(csFullPath, nPathBufferSize - nPathSize, &nCharsWritten, "%s", logData.strLogDir);
261 XN_IS_STATUS_OK(nRetVal);
262 nPathSize += nCharsWritten;
263
264 if (bSessionBased)
265 {
266 nRetVal = xnOSStrFormat(csFullPath + nPathSize, nPathBufferSize - nPathSize, &nCharsWritten, "%s_%u.", logData.strSessionTimestamp, nProcID);
267 XN_IS_STATUS_OK(nRetVal);
268 nPathSize += nCharsWritten;
269 }
270
271 nRetVal = xnOSStrFormat(csFullPath + nPathSize, nPathBufferSize - nPathSize, &nCharsWritten, "%s", strName);
272 XN_IS_STATUS_OK(nRetVal);
273 nPathSize += nCharsWritten;
274
275 // and open the file
276 nRetVal = xnOSOpenFile(csFullPath, XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE, phFile);
277 XN_IS_STATUS_OK(nRetVal);
278
279 return (XN_STATUS_OK);
280}
281
282static void xnLogCreateFilterChangedMessage(XnBufferedLogEntry* pEntry)
283{

Callers 5

xnDumpCreateFunction · 0.85
xnLogCreateFileFunction · 0.85
xnLogCreateFileExFunction · 0.85
OpenFileMethod · 0.85
OpenFileMethod · 0.85

Calls 4

xnLogSetOutputFolderFunction · 0.85
xnOSStrFormatFunction · 0.85
xnOSGetCurrentProcessIDFunction · 0.50
xnOSOpenFileFunction · 0.50

Tested by

no test coverage detected