ReactOS
0.4.17-dev-940-g8bd6e85
CRecentFileEntry.cpp
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS Management Console
3
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4
* PURPOSE: Recent file entry class
5
* COPYRIGHT: Copyright 2026 Eric Kohl (eric.kohl@reactos.org)
6
*/
7
8
#include "
precomp.h
"
9
10
#define NDEBUG
11
#include <debug.h>
12
13
CRecentFileEntry::CRecentFileEntry
(
const
CAtlString
&
FileName
)
14
{
15
m_FileName
=
FileName
;
16
BuildDisplayName
();
17
}
18
19
CRecentFileEntry::~CRecentFileEntry
()
20
{
21
delete
m_FileName
;
22
delete
m_DisplayName
;
23
}
24
25
void
26
CRecentFileEntry::BuildDisplayName
()
27
{
28
WCHAR
SystemDirectory[
MAX_PATH
];
29
UINT
Length
;
30
31
Length
=
::GetSystemDirectoryW
(SystemDirectory,
MAX_PATH
);
32
33
if
(
_wcsnicmp
(
m_FileName
.
GetString
(), SystemDirectory,
Length
) == 0)
34
{
35
m_DisplayName
=
m_FileName
.
Mid
(
Length
+ 1);
36
}
37
else
38
{
39
PWSTR
pBackslash1 =
NULL
, pBackslash2 =
NULL
, pBackslash3 =
NULL
;
40
41
pBackslash1 =
wcschr
(
m_FileName
.
GetString
(),
L
'\\'
);
42
43
if
(pBackslash1)
44
pBackslash2 =
wcschr
(pBackslash1 + 1,
L
'\\'
);
45
46
if
(pBackslash2)
47
pBackslash3 =
wcsrchr
(
m_FileName
.
GetString
(),
L
'\\'
);
48
49
if
(pBackslash1 && pBackslash2 && pBackslash3 && (pBackslash2 != pBackslash3))
50
{
51
int
prefixLength = pBackslash2 -
m_FileName
.
GetString
();
52
CAtlString
str
(
m_FileName
.
Left
(prefixLength + 1));
53
str
.Append(
L
"..."
);
54
str
.Append(pBackslash3);
55
m_DisplayName
=
str
;
56
}
57
else
58
{
59
m_DisplayName
=
m_FileName
;
60
}
61
}
62
}
ATL::CSimpleStringT::GetString
PXSTR GetString() noexcept
Definition:
atlsimpstr.h:367
ATL::CStringT
Definition:
cstringt.h:419
ATL::CStringT::Left
CStringT Left(int nCount) const
Definition:
cstringt.h:776
ATL::CStringT::Mid
CStringT Mid(int iFirst, int nCount) const
Definition:
cstringt.h:748
CRecentFileEntry::CRecentFileEntry
CRecentFileEntry(const CAtlString &FileName)
Definition:
CRecentFileEntry.cpp:13
CRecentFileEntry::~CRecentFileEntry
~CRecentFileEntry()
Definition:
CRecentFileEntry.cpp:19
CRecentFileEntry::m_FileName
CAtlString m_FileName
Definition:
CRecentFileEntry.h:13
CRecentFileEntry::FileName
const CAtlString & FileName() const
Definition:
CRecentFileEntry.h:22
CRecentFileEntry::m_DisplayName
CAtlString m_DisplayName
Definition:
CRecentFileEntry.h:14
CRecentFileEntry::BuildDisplayName
void BuildDisplayName()
Definition:
CRecentFileEntry.cpp:26
NULL
#define NULL
Definition:
types.h:112
wcschr
#define wcschr
Definition:
compat.h:17
wcsrchr
#define wcsrchr
Definition:
compat.h:16
MAX_PATH
#define MAX_PATH
Definition:
compat.h:34
GetSystemDirectoryW
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition:
path.c:2331
_wcsnicmp
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition:
wcs.c:200
L
#define L(x)
Definition:
resources.c:13
UINT
unsigned int UINT
Definition:
sysinfo.c:13
Length
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition:
ntddpcm.h:102
WCHAR
short WCHAR
Definition:
pedump.c:58
str
const WCHAR * str
Definition:
rpc_transport.c:2696
_FileName
Definition:
filecomp.c:348
PWSTR
uint16_t * PWSTR
Definition:
typedefs.h:56
precomp.h
base
applications
mmc_new
CRecentFileEntry.cpp
Generated on Sun Sep 27 2026 06:03:10 for ReactOS by
1.9.6