MiKTeX 26.5-next
A scalable TeX distribution
Loading...
Searching...
No Matches
internal.h
1/* internal.h: internal definitions -*- C++ -*-
2
3 Copyright (C) 2001-2024 Christian Schenk
4
5 This file is part of MiKTeX Package Manager.
6
7 MiKTeX Package Manager is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2, or
10 (at your option) any later version.
11
12 MiKTeX Package Manager is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with MiKTeX Package Manager; if not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#if !defined(D02AFD831E4F4B9E8394D2B294DF4582)
23#define D02AFD831E4F4B9E8394D2B294DF4582
24
25#include <ctime>
26
27#include <string>
28
29#include <miktex/Util/PathName>
30#include <miktex/Core/Paths>
31#include <miktex/Core/Session>
32#include <miktex/Core/VersionNumber>
33
34#include "text.h"
35
36#if !defined(UNUSED)
37# if !defined(NDEBUG)
38# define UNUSED(x)
39# else
40# define UNUSED(x) static_cast<void>(x)
41# endif
42#endif
43
44#if !defined(UNUSED_ALWAYS)
45# define UNUSED_ALWAYS(x) static_cast<void>(x)
46#endif
47
48#define UNIMPLEMENTED() MIKTEX_INTERNAL_ERROR()
49
50#if defined(MIKTEX_WINDOWS) && 1
51#define LOCTRACE() OutputDebugString((std::string(__FILE__) + ":" + std::to_string(__LINE__)).c_str())
52#define TRACE(msg) OutputDebugString(msg)
53#else
54#define LOCTRACE()
55#define TRACE(msg)
56#endif
57
60MPM_INTERNAL_BEGIN_NAMESPACE;
61
62inline std::string GetMpmAgent()
63{
64 return "MPM/" + MiKTeX::Core::VersionNumber(MIKTEX_COMPONENT_VERSION_STR).ToString();
65}
66
67// the trailing slash should not be removed
68constexpr const char* TEXMF_PREFIX_DIRECTORY = "texmf" MIKTEX_PATH_DIRECTORY_DELIMITER_STRING;
69
71{
72public:
73 std::size_t operator()(const std::string& str) const
74 {
75 return MiKTeX::Util::PathName(str).GetHash();
76 }
77};
78
80{
81public:
82 bool operator()(const std::string& str1, const std::string& str2) const
83 {
84 return MiKTeX::Util::PathName::Equals(MiKTeX::Util::PathName(str1), MiKTeX::Util::PathName(str2));
85 }
86};
87
88inline void DbgView(const std::string& s)
89{
90#if defined(_WIN32)
91 OutputDebugStringW(UW_("MiKTeX MPM: " + s));
92#endif
93}
94
95inline bool StripPrefix(const std::string& str, const char* prefix, std::string& result)
96{
97 std::size_t n = strlen(prefix);
99 {
100 return false;
101 }
102 result = str.c_str() + n;
103 return true;
104}
105
106#if defined(StrCmp)
107# undef StrCmp
108#endif
109
110inline int StrCmp(const char* lpsz1, const char* lpsz2)
111{
112 return strcmp(lpsz1, lpsz2);
113}
114
115inline int StrCmp(const wchar_t* lpsz1, const wchar_t* lpsz2)
116{
117 return wcscmp(lpsz1, lpsz2);
118}
119
120inline bool IsNewer(const MiKTeX::Util::PathName& path1, const MiKTeX::Util::PathName& path2)
121{
123}
124
125bool IsUrl(const std::string& url);
126
127std::string MakeUrl(const std::string& base, const std::string& rel);
128
129MPM_INTERNAL_END_NAMESPACE;
130
131#endif
static time_t GetLastWriteTime(const MiKTeX::Util::PathName &path)
Definition File.h:419
static bool Exists(const MiKTeX::Util::PathName &path, FileExistsOptionSet options)
Instances of this class can be used to store path names.
Definition PathName.h:64
static int ComparePrefixes(const PathName &path1, const PathName &path2, std::size_t count)
An instance of this struct represents a version number.
Definition VersionNumber.h:36
std::string ToString() const