Coverage Report

Created: 2026-07-30 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/winpr/libwinpr/utils/wlog/Message.c
Line
Count
Source
1
/**
2
 * WinPR: Windows Portable Runtime
3
 * WinPR Logger
4
 *
5
 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
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
31
char* WLog_Message_GetOutputFileName(int id, const char* ext)
32
0
{
33
0
  char* FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog");
34
0
  if (!FilePath)
35
0
    return nullptr;
36
37
0
  char* FileName = nullptr;
38
0
  size_t FileNameLen = 0;
39
0
  char* FullFileName = nullptr;
40
0
  if (!winpr_PathFileExists(FilePath))
41
0
  {
42
0
    if (!winpr_PathMakePath(FilePath, nullptr))
43
0
      goto fail;
44
0
  }
45
46
0
  const DWORD ProcessId = GetCurrentProcessId();
47
0
  if (id >= 0)
48
0
    winpr_asprintf(&FileName, &FileNameLen, "%" PRIu32 "-%d.%s", ProcessId, id, ext);
49
0
  else
50
0
    winpr_asprintf(&FileName, &FileNameLen, "%" PRIu32 ".%s", ProcessId, ext);
51
52
0
  FullFileName = GetCombinedPath(FilePath, FileName);
53
54
0
fail:
55
0
  free(FilePath);
56
0
  free(FileName);
57
0
  return FullFileName;
58
0
}