Skip to content

Commit

Permalink
Set app directory name using #define
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Jan 14, 2023
1 parent dba277f commit ae89f3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions SourceSampler/Source/SourceSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SourceSampler::SourceSampler():
serverInterface ([this]{return getGlobalContext();})
{
std::cout << "Creating needed directories" << std::endl;
createDirectories();
createDirectories(APP_DIRECTORY_NAME);

std::cout << "Configuring app" << std::endl;
if(audioFormatManager.getNumKnownFormats() == 0){ audioFormatManager.registerBasicFormats(); }
Expand Down Expand Up @@ -120,18 +120,18 @@ void SourceSampler::bindState()
sounds = std::make_unique<SourceSoundList>(state.getChildWithName(SourceIDs::PRESET), [this]{return getGlobalContext();});
}

void SourceSampler::createDirectories()
void SourceSampler::createDirectories(const juce::String& appDirectoryName)
{
#if ELK_BUILD
sourceDataLocation = juce::File(ELK_SOURCE_DATA_BASE_LOCATION);
soundsDownloadLocation = juce::File(ELK_SOURCE_SOUNDS_LOCATION);
presetFilesLocation = juce::File(ELK_SOURCE_PRESETS_LOCATION);
tmpFilesLocation = juce::File(ELK_SOURCE_TMP_LOCATION);
#else
sourceDataLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile("SourceSampler/");
soundsDownloadLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile("SourceSampler/sounds");
presetFilesLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile("SourceSampler/presets");
tmpFilesLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile("SourceSampler/tmp");
sourceDataLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile(appDirectoryName);
soundsDownloadLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile(appDirectoryName + "/sounds");
presetFilesLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile(appDirectoryName + "/presets");
tmpFilesLocation = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile(appDirectoryName + "/tmp");
#endif

if (!sourceDataLocation.exists()){
Expand Down
2 changes: 1 addition & 1 deletion SourceSampler/Source/SourceSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SourceSampler: public juce::ActionBroadcaster,
void bindState();
GlobalContextStruct getGlobalContext();

void createDirectories();
void createDirectories(const juce::String& appDirectoryName);

//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock);
Expand Down
1 change: 1 addition & 0 deletions SourceSampler/Source/defines_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define MAIN_TIMER_HZ 15 // Run main timer tasks at this rate (this includes removing sounds that need to be removed and possibly other tasks)
#define SAFE_SOUND_DELETION_TIME_MS 200

#define APP_DIRECTORY_NAME "SourceSampler" // Note this is ignored in ELK builds
#define ELK_SOURCE_DATA_BASE_LOCATION "/udata/source/"
#define ELK_SOURCE_SOUNDS_LOCATION "/udata/source/sounds/"
#define ELK_SOURCE_PRESETS_LOCATION "/udata/source/presets/"
Expand Down

0 comments on commit ae89f3a

Please sign in to comment.