11 if (!host.isPluginval())
19 std::cout << ex.
what() << std::endl;
34 if (samplesPathDotTxt.exists() !=
true)
36 if (samplesPathDotTxt.create() == Result::ok())
45 throw AssetException(
"Error: Cannot create missing samplesPath.txt",
46 "On init of AssetManager");
51 if (File(factoryAssetPath).isDirectory() !=
true)
54 throw AssetException(
"Error: Factory asset folder does not exist",
55 "On init of factory asset dir");
58 if (!File(dragAndDropPathSetting).isDirectory())
65 if (File(dragAndDropPath).isDirectory() !=
true)
67 if (File(dragAndDropPath).createDirectory() != Result::ok())
69 throw AssetException(
"Error: Cannot find or create Kwidget_Recorder directory",
70 "On init of AssetManager dirs");
78 return File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() +
79 "/Application Support/Krotos/" + JucePlugin_Name +
"/CPM_Manifests";
81 return File(
"C:\\ProgramData\\Krotos\\" JucePlugin_Name
"\\CPM_Manifests");
88 return File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() +
89 "/Application Support/Krotos/" + JucePlugin_Name +
"/samplesPath.txt";
91 return File(
"C:\\ProgramData\\Krotos\\" JucePlugin_Name
"\\samplesPath.txt");
99 const File dir = File(path);
106 Array<File> subDirectories;
107 dir.findChildFiles(subDirectories, File::findDirectories,
false);
109 return subDirectories.size() > expectedDirCount;
116 if (samplesPathDotTxt.exists())
118 return samplesPathDotTxt.loadFileAsString();
131 if (samplesPathDotTxt.exists() && samplesPathDotTxt.hasWriteAccess())
135 if (File(currentFactorySamplesPath).isDirectory()
136 && File(newFactorySamplesPath).isDirectory())
143 throw AssetException(
"Error: Test move failed, aborting asset relocation",
144 "Test move factory assets");
148 auto copySuccessful =
155 "Try to moveFactoryAssets");
158 auto writePathSuccessful = samplesPathDotTxt.replaceWithText(newFactorySamplesPath);
160 if (!writePathSuccessful)
163 "Try to moveFactoryAssets");
169 if (!cleanUpSuccessful)
171 throw AssetException(
"Error: Deleting old factory assets dir failed!",
172 "Try to moveFactoryAssets");
179 throw AssetException(
"Error: Missing source or destination asset directory",
180 "Try to moveFactoryAssets");
185 const String assetsDirectory =
"Factory Assets";
187 String finalPath = newFactorySamplesPath;
191 if (newFactorySamplesPath.contains(assetsDirectory))
193 finalPath = newFactorySamplesPath.upToFirstOccurrenceOf(assetsDirectory,
false,
true);
197 auto writePathSuccessful = samplesPathDotTxt.replaceWithText(finalPath);
199 if (!writePathSuccessful)
202 "Try to write new factory assets path");
210 throw AssetException(
"Error: Missing samplesPath.txt,\nplease restart the plugin",
211 "Try to moveFactoryAssets");
216 const String& newFactorySamplesPath)
219 const String testFile =
"/Factory Assets/samplesPath.test";
221 const String testFile =
"\\Factory Assets\\samplesPath.test";
225 auto oldPathTestCreate = File(currentFactorySamplesPath + testFile).create();
226 auto oldPathTestDelete = File(currentFactorySamplesPath + testFile).deleteRecursively();
228 if (!oldPathTestCreate || !oldPathTestDelete)
230 throw AssetException(
"Error: Test move failed due to access issue with current asset path",
231 "Test move factory assets");
235 auto newPathTestCreate = File(newFactorySamplesPath + testFile).create();
236 auto newPathTestDelete = File(newFactorySamplesPath + testFile).deleteRecursively();
238 if (!newPathTestCreate || !newPathTestDelete)
240 throw AssetException(
"Error: Test move failed due to access issue with desired asset path",
241 "Test move factory assets");
250 auto copySucessful = File(currentFactorySamplesPath +
"/Factory Assets")
251 .copyDirectoryTo(newFactorySamplesPath +
"/Factory Assets");
253 auto copySucessful = File(currentFactorySamplesPath +
"\\Factory Assets")
254 .copyDirectoryTo(newFactorySamplesPath +
"\\Factory Assets");
258 throw AssetException(
"Error: Moving assets failed due to issue copying to new location.\nCheck "
259 "permissions on destination folder.",
260 "Try to moveFactoryAssets");
269 auto deleteSuccessful = File(currentFactorySamplesPath +
"/Factory Assets").deleteRecursively();
271 auto deleteSuccessful = File(currentFactorySamplesPath +
"\\Factory Assets").deleteRecursively();
273 if (!deleteSuccessful)
276 "Error: Deleting old asset path failed.\nMove was successful, please try manual deletion.",
277 "Try to moveFactoryAssets");
288 if (tempDirPath.isDirectory())
290 if (!tempDirPath.deleteRecursively())
292 throw AssetException(
"Error: Cannot delete recorder temp directories",
293 "On call of dev destroy function");
301 "ttpResources",
".ttfEmbCache"))
303 if (!deleteSuccessful)
306 "Error: Cannot delete embeddings cache file",
307 "On call of dev delete cache function");
314 "ttpResources",
".ttfStatus"))
316 if (!deleteSuccessful)
319 "Error: Cannot delete embeddings status file",
320 "On call of dev delete status function");
327 return File::getSpecialLocation(File::tempDirectory).getFullPathName();
329 return File::getSpecialLocation(File::tempDirectory).getFullPathName() +
"\\Krotos\\" + JucePlugin_Name;
348 return File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() +
349 "/Application Support/Krotos/" + JucePlugin_Name +
"/Documentation/EULA/";
351 return File(
"C:\\ProgramData\\Krotos\\" JucePlugin_Name
"\\Documentation\\EULA\\");
358 return File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() +
359 "/Application Support/Krotos/" + JucePlugin_Name +
"/Documentation/Manual/";
361 return File(
"C:\\ProgramData\\Krotos\\" JucePlugin_Name
"\\Documentation\\Manual\\");
395 return File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() +
396 "/Application Support/Krotos/" + JucePlugin_Name;
398 return File(
"C:\\ProgramData\\Krotos\\" JucePlugin_Name);
405 return File::getSpecialLocation(File::userApplicationDataDirectory).getFullPathName() +
406 "/Application Support/Krotos/" + JucePlugin_Name;
408 return File::getSpecialLocation(File::userApplicationDataDirectory).getFullPathName() +
"\\Krotos\\" +
416 return File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() +
417 "/Application Support/Krotos/" + JucePlugin_Name +
"/embeddings_full_paths.csv";
419 return File(
"C:\\ProgramData\\Krotos\\" JucePlugin_Name
"\\embeddings_full_paths.csv");
427 const String outputDirectory =
"Output Assets";
429 String finalPath = newDragAndDropPath;
433 if (newDragAndDropPath.contains(outputDirectory))
435 finalPath = newDragAndDropPath.upToFirstOccurrenceOf(outputDirectory,
false,
true);
445 throw AssetException(
"Error: Missing settings.json file,\nplease restart the plugin",
446 "Try to editDragAndDropPath");
454 if (File(dragAndDropPath).isDirectory())
456 return dragAndDropPath;
467 return File::getSpecialLocation(File::userApplicationDataDirectory).getFullPathName() +
468 "/Application Support/Krotos/" + JucePlugin_Name +
"/OutputAssets/";
470 return File::getSpecialLocation(File::userApplicationDataDirectory).getFullPathName() +
"\\Krotos\\" +
471 JucePlugin_Name +
"\\OutputAssets\\";
477 const String assetsDirectory =
"Factory Assets";
479 Array<File> filesToLoad;
481 for (
auto& file : files)
488 if (file.contains(assetsDirectory))
493 dynamicPath = locatedFile.getFullPathName().fromFirstOccurrenceOf(assetsDirectory,
true,
true);
500 dynamicPath = locatedFile.getFullPathName().fromFirstOccurrenceOf(assetsDirectory,
true,
true);
517 if (finalPath.existsAsFile())
521 if (willLoadSpecificFiles)
523 filesToLoad.add(finalPath);
528 "During loadFiles function");
534 filesToLoad.add(finalPath);
540 if (willLoadSpecificFiles)
547 "During loadFiles function");
550 else if (finalPath.isDirectory())
552 const auto kafFiles = finalPath.findChildFiles(File::TypesOfFileToFind::findFiles,
true,
"*.kaf");
554 const auto wavFiles = finalPath.findChildFiles(File::TypesOfFileToFind::findFiles,
true,
"*.wav");
556 if (!wavFiles.isEmpty() && kafFiles.isEmpty())
558 filesToLoad.add(finalPath);
560 else if ((!wavFiles.isEmpty() &&
562 || (wavFiles.isEmpty() && !kafFiles.isEmpty()))
564 if (willLoadSpecificFiles)
566 filesToLoad.add(finalPath);
571 "During loadFiles function");
577 DBG(
"File not found: " << finalPath.getFileNameWithoutExtension());
585 const String winRoot =
"C:\\ProgramData\\Krotos";
586 const String macRoot =
"/Library/Application Support/Krotos";
589 auto convertedPath = path.replaceFirstOccurrenceOf(macRoot, winRoot).replaceCharacter(
'/',
'\\');
591 auto convertedPath = path.replaceFirstOccurrenceOf(winRoot, macRoot).replaceCharacter(
'\\',
'/');
593 return convertedPath;
598 const String winRoot =
"C:\\ProgramData\\Krotos";
599 const String macRoot =
"/Library/Application Support/Krotos";
600 auto convertedPath = path.replaceFirstOccurrenceOf(winRoot, macRoot).replaceCharacter(
'\\',
'/');
601 return convertedPath;
608 jassert(presetFile.hasFileExtension(
"ksp"));
617 for (
const auto& kwidget : kwidgets)
624 StringArray cleanPaths = StringArray::fromLines(pathsValue.toString());
626 for (
auto& path : cleanPaths)
632 if (path.contains(
"Factory Assets"))
635 dynamicPath = locatedFile.getFullPathName().fromFirstOccurrenceOf(
"Factory Assets",
true,
true);
639 if (!finalPath.isDirectory() && !finalPath.existsAsFile() &&
642 missingFiles += finalPath.getFullPathName() +
"\n";
649 if (File(path).isDirectory() !=
true && File(path).exists() !=
true)
651 missingFiles += path +
"\n";
An exception for asset manager.
Definition AssetManager.h:143
String m_whenDidItHappen
Definition AssetManager.h:156
String when() const
Definition AssetManager.cpp:662
char const * what() const noexcept override
Definition AssetManager.cpp:660
static Array< File > loadFiles(const StringArray &, const bool, const bool willLoadSpecificFiles)
Definition AssetManager.cpp:475
static File getManifestDirectory()
Definition AssetManager.cpp:75
static File getEULADirectory()
Definition AssetManager.cpp:345
static bool cleanUpFactoryAssetsRelocation(const String &)
Definition AssetManager.cpp:266
static void destroyTempDirs()
Definition AssetManager.cpp:283
static String readDragAndDropPath()
Definition AssetManager.cpp:450
static String convertFilePathToOSX(const String &path)
Definition AssetManager.cpp:596
static File getPluginDirectory()
Definition AssetManager.cpp:392
static File getMLEmbeddingsFile()
Definition AssetManager.cpp:413
static File convertFilePath(const String &)
Definition AssetManager.cpp:604
static File getSubscriberAssetDirectory()
Definition AssetManager.cpp:374
static String convertFilePathString(const String &)
Definition AssetManager.cpp:583
static File getUserDataDirectory()
Returns the user data directory, this will be a named manufacturer / plugin subfolder under the File:...
Definition AssetManager.cpp:402
static bool copyFactoryAssets(const String &, const String &)
Definition AssetManager.cpp:247
static File getManualDirectory()
Definition AssetManager.cpp:355
static File getDefaultDragAndDropPath()
Definition AssetManager.cpp:464
static File getDLC1AssetDirectory()
Definition AssetManager.cpp:365
static bool editDragAndDropPath(const String &)
Definition AssetManager.cpp:423
static bool editFactorySamplesPath(const String &, const bool)
Definition AssetManager.cpp:126
void initializeAssetResources()
Definition AssetManager.cpp:25
static File newTempDirectory(const String &)
Definition AssetManager.cpp:333
static const String SupportedAudioTypes
Definition AssetManager.h:112
static void deleteEmbeddingsCacheFile()
Definition AssetManager.cpp:298
static void deleteEmbeddingsStatusFile()
Definition AssetManager.cpp:311
AssetManager()
Definition AssetManager.cpp:5
static bool testFactoryAssetsRelocation(const String &, const String &)
Definition AssetManager.cpp:215
static File getSystemTempDirectory()
Definition AssetManager.cpp:324
static File getAssetDirectory()
Definition AssetManager.cpp:383
static String checkSamplePaths(const File &)
Definition AssetManager.cpp:606
static String readFactorySamplesPath()
Definition AssetManager.cpp:112
static File getSamplesPathDotTxt()
Definition AssetManager.cpp:85
static bool isFactoryContentInstalled(const String &dirPath, const int expectedDirCount)
Check if specific factory content is installed.
Definition AssetManager.cpp:95
An exception for asset manager, specifc to encrypted assets.
Definition AssetManager.h:167
String when() const
Definition AssetManager.cpp:666
String m_whenDidItHappen
Definition AssetManager.h:180
char const * what() const noexcept override
Definition AssetManager.cpp:664
static ValueTree getValueTreeFromFile(const File &presetFile)
Definition PresetManager.cpp:154
static Preset getPresetFromFile(const File &file)
Definition PresetManager.cpp:171
void setSetting(const Identifier &key, const var &value)
Sets the value associated with a given key in the settings.
Definition SettingsFile.cpp:33
var getSetting(const Identifier &key)
Retrieves the value associated with a given key.
Definition SettingsFile.cpp:11
String StringsIntoPath(Args... args)
Joins multiple string arguments into a path string.
Definition helpers.h:25
Definition AirAbsorptionFilter.cpp:2
const String kafFileExtension("kaf")
static const Identifier id
Definition XmlType.h:41
static const Identifier value
Definition XmlType.h:42
static const Identifier type
Definition XmlType.h:43
static const Identifier kwidgets
Definition XmlType.h:22
static const Identifier customParams
Definition XmlType.h:20