Skip to content

Commit aa7de09

Browse files
RobertLauferElektrobitcarneywebMichael Carney
authored
* I161 (CppMicroServices#1097) Fixes CppMicroServices#161 * found spots to modify. * issue 161.2 coded. * fixed a logic error in issue 161.2 * Added a "-Wno-missing-template-arg-list-after-template-kw" With apple's latest clang implementation, this warning fired as an error when including boost::nowide. Turn the warning off. * Issue 161.3: Early check for absolute path when adding resource files. * i161.3: Alternate code for mingw. std::filesystem not compatible. --------- Co-authored-by: Michael Carney <carney@macmini.mynetworksettings.com> * adapt for C++14 --------- Co-authored-by: carneyweb <mike@carneyweb.com> Co-authored-by: Michael Carney <carney@macmini.mynetworksettings.com>
1 parent e5ed312 commit aa7de09

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ if (US_COMPILER_CLANG OR US_COMPILER_APPLE_CLANG)
178178
if (HAS_MISSING_BRACES_FLAG)
179179
add_compile_options(-Wno-missing-braces)
180180
endif()
181+
182+
check_cxx_compiler_flag(-Wno-missing-template-arg-list-after-template-kw HAS_MISSING_TEMPLATE_KW_FLAG)
183+
if (HAS_MISSING_TEMPLATE_KW_FLAG)
184+
add_compile_options(-Wno-missing-template-arg-list-after-template-kw)
185+
endif()
181186
endif()
182187

183188
if(US_BUILD_TESTING)

tools/rc/ResourceCompiler.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
#include <utility>
3838
#include <vector>
3939

40+
#ifdef __MINGW32__
41+
#include <Shlwapi.h>
42+
#endif
43+
4044
#include <nowide/args.hpp>
4145
#include <nowide/fstream.hpp>
4246

@@ -415,6 +419,7 @@ ZipArchive::AddManifestFile(Json::Value const& manifest)
415419
std::string styledManifestJson(manifest.toStyledString());
416420
std::string archiveEntry(bundleName + "/manifest.json");
417421

422+
// Issue 161.1: Check for file exists first and throw a more desriptive runtime error
418423
CheckAndAddToArchivedNames(archiveEntry);
419424

420425
if (MZ_FALSE
@@ -434,6 +439,19 @@ ZipArchive::AddResourceFile(std::string const& resFileName, bool isManifest)
434439
{
435440
std::string archiveName = resFileName;
436441

442+
bool pathToResIsAbsolute = false;
443+
444+
#ifndef __MINGW32__
445+
// Issue 161.3: check to see if resFileName is relative or not, and exit early if it is not.
446+
pathToResIsAbsolute = resFileName[0] == '/';
447+
#else
448+
pathToResIsAbsolute = !PathIsRelativeA(resFileName.c_str());
449+
#endif
450+
451+
if (pathToResIsAbsolute) {
452+
throw std::runtime_error("Relatvie path to resource file required. " + resFileName + " is absolute");
453+
}
454+
437455
// This check exists solely to maintain a deprecated way of adding manifest.json
438456
// through the --res-add option.
439457
if (isManifest || resFileName == std::string("manifest.json"))
@@ -534,7 +552,9 @@ ZipArchive::AddResourcesFromArchive(std::string const& archiveFileName)
534552
{
535553
if (numBytes > 1)
536554
{
537-
if (archiveName[numBytes - 2] != '/') // The last character is '\0' in the array
555+
// Issue 161.2: change to use mz_zip_read_is_file_a_directory() instead of checking
556+
// for the format of the string.
557+
if (MZ_FALSE == mz_zip_reader_is_file_a_directory(&currZipArchive, currZipIndex))
538558
{
539559
if (!archivedNames.insert(archiveName).second)
540560
{

0 commit comments

Comments
 (0)