Skip to content

Commit

Permalink
Allow multiple spellings for Systems and Engines sub-directories. (
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoconni committed Aug 20, 2022
1 parent 186557f commit 4530539
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
9 changes: 5 additions & 4 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ for d in os.scandir('data/aircraft'):
data_files.append(('share/${PROJECT_NAME}/'+dir_name,
list(XML_files(dir_name))))

# Some aircraft folders include a `Systems` and/or an `Engines`
# sub-directory so make sure it is copied in the wheel archive
# (see GH issue #687)
for sub_dir in ('Systems', 'Engines'):
# Some aircraft folders include a "Systems" and/or an "Engines"
# sub-directory (with several alternative spelling) so make sure they
# are copied in the wheel archive (see GH issue #687)
for sub_dir in ('Systems', 'systems', 'Engines', 'engines', 'Engine',
'engine'):
sub_dir_name = dir_name + '/' + sub_dir
subdir_dir_fullname = os.path.join('data', sub_dir_name)
if os.path.exists(subdir_dir_fullname) and os.path.isdir(subdir_dir_fullname):
Expand Down
14 changes: 12 additions & 2 deletions src/models/FGFCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

#include <iomanip>
#include <array>

#include "FGFCS.h"
#include "input_output/FGModelLoader.h"
Expand Down Expand Up @@ -613,8 +614,17 @@ SGPath FGFCS::FindFullPathName(const SGPath& path) const
SGPath name = FGModel::FindFullPathName(path);
if (systype != stSystem || !name.isNull()) return name;

name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Systems"), path);
if (!name.isNull()) return name;
#ifdef _WIN32
const array<string, 1> dir_names = {"Systems"};
#else
// Check alternative capitalization for case sensitive OSes.
const array<string, 2> dir_names = {"Systems", "systems"};
#endif

for(const string& dir_name: dir_names) {
name = CheckPathName(FDMExec->GetFullAircraftPath()/dir_name, path);
if (!name.isNull()) return name;
}

return CheckPathName(FDMExec->GetSystemsPath(), path);
}
Expand Down
23 changes: 18 additions & 5 deletions src/models/FGPropulsion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

#include <iomanip>
#include <array>

#include "FGFDMExec.h"
#include "FGPropulsion.h"
Expand Down Expand Up @@ -457,11 +458,23 @@ bool FGPropulsion::Load(Element* el)

SGPath FGPropulsion::FindFullPathName(const SGPath& path) const
{
if (!ReadingEngine) return FGModel::FindFullPathName(path);

SGPath name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Engines"),
path);
if (!name.isNull()) return name;
SGPath name = FGModel::FindFullPathName(path);
if (!ReadingEngine && !name.isNull()) return name;

#ifdef _WIN32
// Singular and plural are allowed for the folder names for consistency with
// the default engine folder name "engine" and for backward compatibility
// regarding the folder name "Engines".
const array<string, 2> dir_names = {"Engines", "engine"};
#else
// Allow alternative capitalization for case sensitive OSes.
const array<string, 4> dir_names = {"Engines", "engines", "Engine", "engine"};
#endif

for(const string& dir_name: dir_names) {
name = CheckPathName(FDMExec->GetFullAircraftPath()/dir_name, path);
if (!name.isNull()) return name;
}

return CheckPathName(FDMExec->GetEnginePath(), path);
}
Expand Down

0 comments on commit 4530539

Please # to comment.