FreeRDP
Loading...
Searching...
No Matches
Message.c
1
20#include <winpr/config.h>
21
22#include <winpr/crt.h>
23#include <winpr/path.h>
24#include <winpr/file.h>
25#include <winpr/string.h>
26
27#include "wlog.h"
28
29#include "Message.h"
30
31char* WLog_Message_GetOutputFileName(int id, const char* ext)
32{
33 char* FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog");
34 if (!FilePath)
35 return nullptr;
36
37 char* FileName = nullptr;
38 size_t FileNameLen = 0;
39 char* FullFileName = nullptr;
40 if (!winpr_PathFileExists(FilePath))
41 {
42 if (!winpr_PathMakePath(FilePath, nullptr))
43 goto fail;
44 }
45
46 const DWORD ProcessId = GetCurrentProcessId();
47 if (id >= 0)
48 winpr_asprintf(&FileName, &FileNameLen, "%" PRIu32 "-%d.%s", ProcessId, id, ext);
49 else
50 winpr_asprintf(&FileName, &FileNameLen, "%" PRIu32 ".%s", ProcessId, ext);
51
52 FullFileName = GetCombinedPath(FilePath, FileName);
53
54fail:
55 free(FilePath);
56 free(FileName);
57 return FullFileName;
58}