# Manipulation of asset directories

**URL:** <https://discourse.libcinder.org/t/manipulation-of-asset-directories/364>\
**Category:** Using Cinder\
**Created:** [October 31, 2016, 11:26pm UTC](https://discourse.libcinder.org/t/manipulation-of-asset-directories/364 "2016-10-31T23:26:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [October 31, 2016, 11:26pm UTC](https://discourse.libcinder.org/t/manipulation-of-asset-directories/364/1 "2016-10-31T23:26:40Z")

</div>

Hi all.

I’m implementing orientation awareness into an existing desktop application (because clients, ugh). When it comes to loading assets, I thought i’d try to be clever and just add an asset directory based on the current orientation, so that assets are automatically loaded from `assets/{orientation}/asset.ext`, for example. This is fine and dandy, except that there’s no way I can see to remove asset directories once they’ve been added. `getAssetDirectories()` returns a const ref, and there’s no `removeAssetDirectory` counterpart.

Before i go hacking this functionality into my fork of cinder, is there any particular reason why asset directories shouldn’t be meddled with at runtime? I’d rather spend my time coming up with a different solution than diving around the cinder source all afternoon if at all possible.

Thanks,

A.

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [November 1, 2016, 12:08am UTC](https://discourse.libcinder.org/t/manipulation-of-asset-directories/364/2 "2016-11-01T00:08:25Z")

</div>

I’m not sure about the reasons of a missing `removeAssetDirectory`, but I don’t think you’d need one. Why not just concatenate the path in your app?

```auto
auto path = getAssetPath("") / mOrientation / "asset.ext";
auto src = loadFile( path );

```

---

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [November 1, 2016, 12:23am UTC](https://discourse.libcinder.org/t/manipulation-of-asset-directories/364/3 "2016-11-01T00:23:54Z")

</div>

Well because with my method, i don’t have to duplicate assets that are common to both orientations, the asset system will naturally fall back to a common asset in `/assets/`.

I’ve just added a non-const `getAssetDirectories()` in `Platform.h` which suits my purposes for now, i just wanted to make sure there wasn’t any threading issues to be aware of. I think highly enough of the cinder codebase that when something that could be perceived as an oversight such as this crops up, i tend to assume it’s by design.

Thanks mate.

---

<div class="post-metadata">

**Author:** ![rich.e](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/rich.e/32/1025_2.png) [@rich.e](https://discourse.libcinder.org/u/rich.e)\
**Post date:** [November 1, 2016, 12:43am UTC](https://discourse.libcinder.org/t/manipulation-of-asset-directories/364/4 "2016-11-01T00:43:08Z")

</div>

I’d say the simple reason is that it hasn’t come up. I think it would be fine to add it, with the caveat that it isn’t thread-safe - you should do all asset directory manipulation before any background threads start trying to load assets, or pause your loaders.

I think adding a `removeAssetDirectory()` method would be cleaner than making `getAssetDirectories()` non-const.

---

<div class="post-metadata">

**Author:** ![Andrew](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Andrew](https://discourse.libcinder.org/u/Andrew)\
**Post date:** [April 13, 2017, 2:06am UTC](https://discourse.libcinder.org/t/manipulation-of-asset-directories/364/5 "2017-04-13T02:06:37Z")

</div>

"The first time you attempt to load an asset or get its path, your Cinder application automatically attempts to find its assets directory. It begins by searching in the same folder in which your .app bundle or .exe lives. Next it searches its parent, on up 5 levels… loadAsset() and getAssetPath() will search the primary assets folder first, followed by any supplemental asset directories the user may have provided. "

(- [https://libcinder.org/docs/guides/resources/index.html](https://libcinder.org/docs/guides/resources/index.html))

For the record, I don’t like this kind of behavior, especially when it can’t be turned off, and especially if it searches 5 directories up before searching the manual override directory.
