Skip to content

Commit

Permalink
Reimplementing findAndAddDefaultAssetPath() in terms of findAncestorD…
Browse files Browse the repository at this point in the history
…ir()
  • Loading branch information
andrewfb committed Jul 11, 2024
1 parent 19d94d3 commit 7aaca15
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/cinder/app/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "cinder/app/Platform.h"
#include "cinder/CinderAssert.h"
#include "cinder/Utilities.h"

#if defined( CINDER_COCOA )
#include "cinder/app/cocoa/PlatformCocoa.h"
Expand Down Expand Up @@ -145,20 +146,9 @@ const vector<fs::path>& Platform::getAssetDirectories() const

void Platform::findAndAddDefaultAssetPath()
{
// first search the local directory, then its parent, up to ASSET_SEARCH_DEPTH levels up
// check at least the app path, even if it has no parent directory
auto execPath = getExecutablePath();
size_t parentCt = 0;
for( fs::path curPath = execPath; curPath.has_parent_path() || ( curPath == execPath ); curPath = curPath.parent_path(), ++parentCt ) {
if( parentCt >= ASSET_SEARCH_DEPTH )
break;

const fs::path curAssetDir = curPath / fs::path( "assets" );
if( fs::exists( curAssetDir ) && fs::is_directory( curAssetDir ) ) {
addAssetDirectory( curAssetDir );
break;
}
}
std::filesystem::path assetDir = findAncestorDir( getExecutablePath().parent_path(), "assets", ASSET_SEARCH_DEPTH );
if( ! assetDir.empty() )
addAssetDirectory( assetDir );
}

std::ostream& Platform::console()
Expand Down

0 comments on commit 7aaca15

Please sign in to comment.