Browse Source

Continue cleanup

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.5.0
falkTX 2 years ago
parent
commit
5385595764
7 changed files with 31 additions and 27 deletions
  1. +5
    -5
      source/backend/engine/CarlaEngine.cpp
  2. +0
    -1
      source/backend/plugin/CarlaPluginNative.cpp
  3. +9
    -6
      source/backend/utils/CachedPlugins.cpp
  4. +4
    -4
      source/includes/CarlaNativePrograms.hpp
  5. +9
    -9
      source/modules/water/files/File.cpp
  6. +3
    -1
      source/modules/water/files/File.h
  7. +1
    -1
      source/utils/CarlaDssiUtils.cpp

+ 5
- 5
source/backend/engine/CarlaEngine.cpp View File

@@ -2579,7 +2579,7 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c
searchFlags |= File::findDirectories;
#endif

Array<File> results;
std::vector<File> results;
for (const String *it=searchPaths.begin(), *end=searchPaths.end(); it != end; ++it)
{
const File path(*it);
@@ -2587,8 +2587,8 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c
results.clear();
path.findChildFiles(results, searchFlags, true, filename);

if (results.size() > 0)
return results.getFirst().getFullPathName();
if (!results.empty())
return results.front().getFullPathName();
}

// try changing extension
@@ -2612,8 +2612,8 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c
results.clear();
path.findChildFiles(results, searchFlags, true, filename);

if (results.size() > 0)
return results.getFirst().getFullPathName();
if (!results.empty())
return results.front().getFullPathName();
}

return String();


+ 0
- 1
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -25,7 +25,6 @@
#include "water/misc/Time.h"
#include "water/text/StringArray.h"

using water::jmax;
using water::String;
using water::StringArray;



+ 9
- 6
source/backend/utils/CachedPlugins.cpp View File

@@ -72,11 +72,11 @@ _CarlaCachedPluginInfo::_CarlaCachedPluginInfo() noexcept

// -------------------------------------------------------------------------------------------------------------------

static water::Array<water::File> gSFZs;
static std::vector<water::File> gSFZs;

static void findSFZs(const char* const sfzPaths)
{
gSFZs.clearQuick();
gSFZs.clear();

CARLA_SAFE_ASSERT_RETURN(sfzPaths != nullptr,);

@@ -87,10 +87,13 @@ static void findSFZs(const char* const sfzPaths)

for (water::String *it = splitPaths.begin(), *end = splitPaths.end(); it != end; ++it)
{
water::Array<water::File> results;
std::vector<water::File> results;

if (water::File(*it).findChildFiles(results, water::File::findFiles|water::File::ignoreHiddenFiles, true, "*.sfz") > 0)
gSFZs.addArray(results);
{
gSFZs.reserve(gSFZs.size() + results.size());
gSFZs.insert(gSFZs.end(), results.begin(), results.end());
}
}
}

@@ -699,8 +702,8 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(CB::PluginType ptype,
#endif

case CB::PLUGIN_SFZ: {
CARLA_SAFE_ASSERT_BREAK(index < static_cast<uint>(gSFZs.size()));
return get_cached_plugin_sfz(gSFZs.getUnchecked(static_cast<int>(index)));
CARLA_SAFE_ASSERT_BREAK(index < gSFZs.size());
return get_cached_plugin_sfz(gSFZs[index]);
}

default:


+ 4
- 4
source/includes/CarlaNativePrograms.hpp View File

@@ -63,12 +63,12 @@ struct NativePluginPresetManager {

for (String *it = splitPaths.begin(), *end = splitPaths.end(); it != end; ++it)
{
Array<File> results;
std::vector<File> results;

if (File(*it).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard) > 0)
if (const int count = File(*it).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard))
{
for (File *it2 = results.begin(), *end2 = results.end(); it2 != end2; ++it2)
filenames.add(it2->getFullPathName());
for (int i=0; i<count; ++i)
filenames.add(results[i].getFullPathName());
}
}



+ 9
- 9
source/modules/water/files/File.cpp View File

@@ -263,11 +263,11 @@ bool File::deleteRecursively() const
if (isDirectory())
{
Array<File> subFiles;
std::vector<File> subFiles;
findChildFiles (subFiles, File::findFilesAndDirectories, false);
for (int i = subFiles.size(); --i >= 0;)
worked = subFiles.getReference(i).deleteRecursively() && worked;
worked = subFiles[i].deleteRecursively() && worked;
}
return deleteFile() && worked;
@@ -315,12 +315,12 @@ bool File::copyDirectoryTo (const File& newDirectory) const
{
if (isDirectory() && newDirectory.createDirectory())
{
Array<File> subFiles;
std::vector<File> subFiles;
findChildFiles (subFiles, File::findFiles, false);
for (int i = 0; i < subFiles.size(); ++i)
for (size_t i = 0; i < subFiles.size(); ++i)
{
const File& src (subFiles.getReference(i));
const File& src (subFiles[i]);
const File& dst (newDirectory.getChildFile (src.getFileName()));
if (src.isSymbolicLink())
@@ -338,8 +338,8 @@ bool File::copyDirectoryTo (const File& newDirectory) const
subFiles.clear();
findChildFiles (subFiles, File::findDirectories, false);
for (int i = 0; i < subFiles.size(); ++i)
if (! subFiles.getReference(i).copyDirectoryTo (newDirectory.getChildFile (subFiles.getReference(i).getFileName())))
for (size_t i = 0; i < subFiles.size(); ++i)
if (! subFiles[i].copyDirectoryTo (newDirectory.getChildFile (subFiles[i].getFileName())))
return false;
return true;
@@ -556,7 +556,7 @@ void File::readLines (StringArray& destLines) const
}
//==============================================================================
int File::findChildFiles (Array<File>& results,
int File::findChildFiles (std::vector<File>& results,
const int whatToLookFor,
const bool searchRecursively,
const String& wildCardPattern) const
@@ -565,7 +565,7 @@ int File::findChildFiles (Array<File>& results,
for (DirectoryIterator di (*this, searchRecursively, wildCardPattern, whatToLookFor); di.next();)
{
results.add (di.getFile());
results.push_back (di.getFile());
++total;
}


+ 3
- 1
source/modules/water/files/File.h View File

@@ -30,6 +30,8 @@
#include "../misc/Result.h"
#include "../text/String.h"
#include <vector>
namespace water {
//==============================================================================
@@ -492,7 +494,7 @@ public:
@see getNumberOfChildFiles, DirectoryIterator
*/
int findChildFiles (Array<File>& results,
int findChildFiles (std::vector<File>& results,
int whatToLookFor,
bool searchRecursively,
const String& wildCardPattern = "*") const;


+ 1
- 1
source/utils/CarlaDssiUtils.cpp View File

@@ -45,7 +45,7 @@ const char* find_dssi_ui(const char* const filename, const char* const label) no
if (! checkLabel.endsWithChar('_')) checkLabel += "_";
if (! checkSName.endsWithChar('_')) checkSName += "_";

water::Array<water::File> results;
std::vector<water::File> results;

for (int i=water::File(pluginDir).findChildFiles(results,
water::File::findFiles|water::File::ignoreHiddenFiles, false); --i >= 0;)


Loading…
Cancel
Save