2013-10-02 21:38:21 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* WinPR Logger
|
|
|
|
*
|
|
|
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2013-10-02 23:41:46 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/path.h>
|
2013-12-05 21:35:31 +04:00
|
|
|
#include <winpr/file.h>
|
2013-10-02 23:41:46 +04:00
|
|
|
|
2015-11-09 19:56:44 +03:00
|
|
|
#include "wlog.h"
|
2013-10-02 21:38:21 +04:00
|
|
|
|
2015-11-09 19:56:44 +03:00
|
|
|
#include "Message.h"
|
2013-10-02 21:38:21 +04:00
|
|
|
|
2013-10-02 23:41:46 +04:00
|
|
|
char* WLog_Message_GetOutputFileName(int id, const char* ext)
|
|
|
|
{
|
|
|
|
DWORD ProcessId;
|
|
|
|
char* FilePath;
|
|
|
|
char* FileName;
|
|
|
|
char* FullFileName;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!(FileName = (char*)malloc(256)))
|
2015-04-03 17:21:01 +03:00
|
|
|
return NULL;
|
2013-10-02 23:41:46 +04:00
|
|
|
|
|
|
|
FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog");
|
|
|
|
|
2013-12-05 08:46:58 +04:00
|
|
|
if (!PathFileExistsA(FilePath))
|
2015-04-03 17:21:01 +03:00
|
|
|
{
|
2015-06-03 12:47:40 +03:00
|
|
|
if (!PathMakePathA(FilePath, NULL))
|
2015-04-03 17:21:01 +03:00
|
|
|
{
|
|
|
|
free(FileName);
|
|
|
|
free(FilePath);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-10-09 07:43:57 +04:00
|
|
|
|
2015-04-03 17:21:01 +03:00
|
|
|
ProcessId = GetCurrentProcessId();
|
2013-10-09 07:43:57 +04:00
|
|
|
if (id >= 0)
|
2019-11-06 17:24:51 +03:00
|
|
|
sprintf_s(FileName, 256, "%" PRIu32 "-%d.%s", ProcessId, id, ext);
|
2013-10-09 07:43:57 +04:00
|
|
|
else
|
2019-11-06 17:24:51 +03:00
|
|
|
sprintf_s(FileName, 256, "%" PRIu32 ".%s", ProcessId, ext);
|
2013-10-02 23:41:46 +04:00
|
|
|
|
|
|
|
FullFileName = GetCombinedPath(FilePath, FileName);
|
|
|
|
|
|
|
|
free(FileName);
|
|
|
|
free(FilePath);
|
|
|
|
|
|
|
|
return FullFileName;
|
|
|
|
}
|