Browse Source

Clean water File(const String&) usage

Signed-off-by: falkTX <falktx@falktx.com>
pull/1898/head
falkTX 6 months ago
parent
commit
51186c9f7c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
15 changed files with 81 additions and 158 deletions
  1. +3
    -19
      source/backend/CarlaStandaloneNSM.cpp
  2. +11
    -14
      source/backend/engine/CarlaEngine.cpp
  3. +6
    -20
      source/backend/engine/CarlaEngineBridge.cpp
  4. +4
    -20
      source/backend/plugin/CarlaPlugin.cpp
  5. +8
    -8
      source/backend/plugin/CarlaPluginBridge.cpp
  6. +4
    -4
      source/backend/plugin/CarlaPluginJSFX.cpp
  7. +2
    -2
      source/backend/utils/CachedPlugins.cpp
  8. +5
    -5
      source/backend/utils/PluginDiscovery.cpp
  9. +3
    -17
      source/bridges-plugin/CarlaBridgePlugin.cpp
  10. +3
    -3
      source/includes/CarlaNativePrograms.hpp
  11. +2
    -2
      source/modules/water/files/DirectoryIterator.cpp
  12. +18
    -24
      source/modules/water/files/File.cpp
  13. +6
    -12
      source/modules/water/files/File.h
  14. +2
    -3
      source/native-plugins/midi-file.cpp
  15. +4
    -5
      source/utils/CarlaDssiUtils.cpp

+ 3
- 19
source/backend/CarlaStandaloneNSM.cpp View File

@@ -1,19 +1,5 @@
/*
* Carla Standalone
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
// SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
// SPDX-License-Identifier: GPL-2.0-or-later

#include "CarlaHostImpl.hpp"

@@ -318,9 +304,7 @@ protected:
fProjectPath = projectPath;
fProjectPath += ".carxp";

const String jfilename = String(CharPointer_UTF8(fProjectPath));

if (File(jfilename).existsAsFile())
if (File(fProjectPath).existsAsFile())
carla_load_project(handle, fProjectPath);
}



+ 11
- 14
source/backend/engine/CarlaEngine.cpp View File

@@ -1220,8 +1220,7 @@ bool CarlaEngine::loadFile(const char* const filename)
CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename");
carla_debug("CarlaEngine::loadFile(\"%s\")", filename);

const String jfilename = String(CharPointer_UTF8(filename));
File file(jfilename);
File file(filename);
CARLA_SAFE_ASSERT_RETURN_ERR(file.exists(), "Requested file does not exist or is not a readable");

CarlaString baseName(file.getFileNameWithoutExtension().toRawUTF8());
@@ -1392,8 +1391,7 @@ bool CarlaEngine::loadProject(const char* const filename, const bool setAsCurren
CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename");
carla_debug("CarlaEngine::loadProject(\"%s\")", filename);

const String jfilename = String(CharPointer_UTF8(filename));
const File file(jfilename);
const File file(filename);
CARLA_SAFE_ASSERT_RETURN_ERR(file.existsAsFile(), "Requested file does not exist or is not a readable file");

if (setAsCurrentProject)
@@ -1454,8 +1452,7 @@ bool CarlaEngine::saveProject(const char* const filename, const bool setAsCurren
MemoryOutputStream out;
saveProjectInternal(out);

const String jfilename = String(CharPointer_UTF8(filename));
File file(jfilename);
File file(filename);

if (file.replaceWithData(out.getData(), out.getDataSize()))
return true;
@@ -2604,7 +2601,7 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c
jbinary = jbinary.substring(2).replaceCharacter('\\', '/');
#endif

String filename = File(jbinary).getFileName();
String filename = File(jbinary.toRawUTF8()).getFileName();

int searchFlags = File::findFiles|File::ignoreHiddenFiles;

@@ -2618,10 +2615,10 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c
std::vector<File> results;
for (const String *it=searchPaths.begin(), *end=searchPaths.end(); it != end; ++it)
{
const File path(*it);
const File path(it->toRawUTF8());

results.clear();
path.findChildFiles(results, searchFlags, true, filename);
path.findChildFiles(results, searchFlags, true, filename.toRawUTF8());

if (!results.empty())
return results.front().getFullPathName();
@@ -2630,23 +2627,23 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c
// try changing extension
#if defined(CARLA_OS_MAC)
if (filename.endsWithIgnoreCase(".dll") || filename.endsWithIgnoreCase(".so"))
filename = File(jbinary).getFileNameWithoutExtension() + ".dylib";
filename = File(jbinary.toRawUTF8()).getFileNameWithoutExtension() + ".dylib";
#elif defined(CARLA_OS_WIN)
if (filename.endsWithIgnoreCase(".dylib") || filename.endsWithIgnoreCase(".so"))
filename = File(jbinary).getFileNameWithoutExtension() + ".dll";
filename = File(jbinary.toRawUTF8()).getFileNameWithoutExtension() + ".dll";
#else
if (filename.endsWithIgnoreCase(".dll") || filename.endsWithIgnoreCase(".dylib"))
filename = File(jbinary).getFileNameWithoutExtension() + ".so";
filename = File(jbinary.toRawUTF8()).getFileNameWithoutExtension() + ".so";
#endif
else
return String();

for (const String *it=searchPaths.begin(), *end=searchPaths.end(); it != end; ++it)
{
const File path(*it);
const File path(it->toRawUTF8());

results.clear();
path.findChildFiles(results, searchFlags, true, filename);
path.findChildFiles(results, searchFlags, true, filename.toRawUTF8());

if (!results.empty())
return results.front().getFullPathName();


+ 6
- 20
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -1,19 +1,5 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
// SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
// SPDX-License-Identifier: GPL-2.0-or-later

#ifndef BUILD_BRIDGE
# error This file should not be compiled if not building bridge
@@ -947,7 +933,7 @@ public:
bigValueFilePath = bigValueFilePath.replaceSection(0, 1, "Z:\\").replace("/", "\\");
#endif

File bigValueFile(bigValueFilePath);
File bigValueFile(bigValueFilePath.toRawUTF8());
CARLA_SAFE_ASSERT_BREAK(bigValueFile.existsAsFile());

plugin->setCustomData(type.text, key.text, bigValueFile.loadFileAsString().toRawUTF8(), true);
@@ -988,7 +974,7 @@ public:
chunkFilePath = chunkFilePath.replaceSection(0, 1, "Z:\\").replace("/", "\\");
#endif

File chunkFile(chunkFilePath);
File chunkFile(chunkFilePath.toRawUTF8());
CARLA_SAFE_ASSERT_BREAK(chunkFile.existsAsFile());

String chunkDataBase64(chunkFile.loadFileAsString());
@@ -1122,7 +1108,7 @@ public:
filePath += CARLA_OS_SEP_STR ".CarlaCustomData_";
filePath += fShmAudioPool.getFilenameSuffix();

if (File(filePath).replaceWithText(cdata.value))
if (File(filePath.toRawUTF8()).replaceWithText(cdata.value))
{
const uint32_t ulength(static_cast<uint32_t>(filePath.length()));

@@ -1160,7 +1146,7 @@ public:
filePath += CARLA_OS_SEP_STR ".CarlaChunk_";
filePath += fShmAudioPool.getFilenameSuffix();

if (File(filePath).replaceWithText(dataBase64.buffer()))
if (File(filePath.toRawUTF8()).replaceWithText(dataBase64.buffer()))
{
const uint32_t ulength(static_cast<uint32_t>(filePath.length()));



+ 4
- 20
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1,19 +1,5 @@
/*
* Carla Plugin
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
// SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
// SPDX-License-Identifier: GPL-2.0-or-later

#include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"
@@ -987,8 +973,7 @@ bool CarlaPlugin::saveStateToFile(const char* const filename)
out << streamState;
out << "</CARLA-PRESET>\n";

const String jfilename = String(CharPointer_UTF8(filename));
File file(jfilename);
File file(filename);

if (file.replaceWithData(out.getData(), out.getDataSize()))
return true;
@@ -1004,8 +989,7 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename)
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
carla_debug("CarlaPlugin::loadStateFromFile(\"%s\")", filename);

const String jfilename = String(CharPointer_UTF8(filename));
File file(jfilename);
File file(filename);
CARLA_SAFE_ASSERT_RETURN(file.existsAsFile(), false);

XmlDocument xml(file);


+ 8
- 8
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Bridge
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -60,7 +60,7 @@ static String findWinePrefix(const String filename, const int recursionLimit = 1

const String path(filename.upToLastOccurrenceOf("/", false, false));

if (File(path + "/dosdevices").isDirectory())
if (File(String(path + "/dosdevices").toRawUTF8()).isDirectory())
return path;

return findWinePrefix(path, recursionLimit-1);
@@ -204,7 +204,7 @@ protected:

if (fBridgeBinary.endsWithIgnoreCase("64.exe")
&& options.wine.executable[0] == CARLA_OS_SEP
&& File(wineCMD + "64").existsAsFile())
&& File(String(wineCMD + "64").toRawUTF8()).existsAsFile())
wineCMD += "64";
}
else
@@ -996,7 +996,7 @@ public:
filePath += CARLA_OS_SEP_STR ".CarlaCustomData_";
filePath += fShmAudioPool.getFilenameSuffix();

if (File(filePath).replaceWithText(value))
if (File(filePath.toRawUTF8()).replaceWithText(value))
{
const uint32_t ulength = static_cast<uint32_t>(filePath.length());

@@ -1034,7 +1034,7 @@ public:
filePath += CARLA_OS_SEP_STR ".CarlaChunk_";
filePath += fShmAudioPool.getFilenameSuffix();

if (File(filePath).replaceWithText(dataBase64.buffer()))
if (File(filePath.toRawUTF8()).replaceWithText(dataBase64.buffer()))
{
const uint32_t ulength = static_cast<uint32_t>(filePath.length());

@@ -2550,7 +2550,7 @@ public:
}
#endif

const File bigValueFile(realBigValueFilePath);
const File bigValueFile(realBigValueFilePath.toRawUTF8());
CARLA_SAFE_ASSERT_BREAK(bigValueFile.existsAsFile());

CarlaPlugin::setCustomData(type.text, key.text, bigValueFile.loadFileAsString().toRawUTF8(), false);
@@ -2591,7 +2591,7 @@ public:
}
#endif

const File chunkFile(realChunkFilePath);
const File chunkFile(realChunkFilePath.toRawUTF8());
CARLA_SAFE_ASSERT_BREAK(chunkFile.existsAsFile());

fInfo.chunk = carla_getChunkFromBase64String(chunkFile.loadFileAsString().toRawUTF8());
@@ -3245,7 +3245,7 @@ private:
filePath += CARLA_OS_SEP_STR ".CarlaChunk_";
filePath += fShmAudioPool.getFilenameSuffix();

if (File(filePath).replaceWithText(dataBase64.buffer()))
if (File(filePath.toRawUTF8()).replaceWithText(dataBase64.buffer()))
{
const uint32_t ulength(static_cast<uint32_t>(filePath.length()));



+ 4
- 4
source/backend/plugin/CarlaPluginJSFX.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla JSFX Plugin
* Copyright (C) 2021-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -943,7 +943,7 @@ public:
// find which engine search path we're in, and use this as the root
for (int i = 0; i < splitPaths.size() && !fUnit; ++i)
{
const File currentPath(splitPaths[i]);
const File currentPath(splitPaths[i].toRawUTF8());
if (file.isAChildOf(currentPath))
fUnit = CarlaJsfxUnit(currentPath, file);
}
@@ -957,10 +957,10 @@ public:
// search a matching file in plugin paths
for (int i = 0; i < splitPaths.size() && !fUnit; ++i)
{
const File currentPath(splitPaths[i]);
const File currentPath(splitPaths[i].toRawUTF8());
const File currentFile = currentPath.getChildFile(CharPointer_UTF8(label));
const CarlaJsfxUnit currentUnit(currentPath, currentFile);
if (File(currentUnit.getFilePath()).existsAsFile())
if (File(currentUnit.getFilePath().toRawUTF8()).existsAsFile())
fUnit = currentUnit;
}
}


+ 2
- 2
source/backend/utils/CachedPlugins.cpp View File

@@ -79,7 +79,7 @@ static void findSFZs(const char* const sfzPaths)
{
std::vector<water::File> results;

if (water::File(*it).findChildFiles(results, water::File::findFiles|water::File::ignoreHiddenFiles, true, "*.sfz") > 0)
if (water::File(it->toRawUTF8()).findChildFiles(results, water::File::findFiles|water::File::ignoreHiddenFiles, true, "*.sfz") > 0)
{
gSFZs.reserve(gSFZs.size() + results.size());
gSFZs.insert(gSFZs.end(), results.begin(), results.end());
@@ -107,7 +107,7 @@ static void findJSFXs(const char* const jsfxPaths)
for (water::String *it = splitPaths.begin(), *end = splitPaths.end(); it != end; ++it)
{
std::vector<water::File> results;
const water::File path(*it);
const water::File path(it->toRawUTF8());

if (path.findChildFiles(results, water::File::findFiles|water::File::ignoreHiddenFiles, true, "*") > 0)
{


+ 5
- 5
source/backend/utils/PluginDiscovery.cpp View File

@@ -27,7 +27,7 @@ static water::String findWinePrefix(const water::String filename, const int recu

const water::String path(filename.upToLastOccurrenceOf("/", false, false));

if (water::File(path + "/dosdevices").isDirectory())
if (water::File(water::String(path + "/dosdevices").toRawUTF8()).isDirectory())
return path;

return findWinePrefix(path, recursionLimit-1);
@@ -419,7 +419,7 @@ private:
{
helperTool = options.wine.executable.buffer();

if (helperTool.isNotEmpty() && helperTool[0] == CARLA_OS_SEP && File(helperTool + "64").existsAsFile())
if (helperTool.isNotEmpty() && helperTool[0] == CARLA_OS_SEP && File(String(helperTool + "64").toRawUTF8()).existsAsFile())
helperTool += "64";
}
else
@@ -606,7 +606,7 @@ static bool findDirectories(std::vector<water::File>& files, const char* const p

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

if (dir.findChildFiles(results, File::findDirectories|File::ignoreHiddenFiles, true, wildcard) > 0)
@@ -638,7 +638,7 @@ static bool findFiles(std::vector<water::File>& files,

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

if (dir.findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard) > 0)
@@ -681,7 +681,7 @@ static bool findVST3s(std::vector<water::File>& files,

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

if (dir.findChildFiles(results, flags|File::ignoreHiddenFiles, true, "*.vst3") > 0)


+ 3
- 17
source/bridges-plugin/CarlaBridgePlugin.cpp View File

@@ -1,19 +1,5 @@
/*
* Carla Bridge Plugin
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
// SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
// SPDX-License-Identifier: GPL-2.0-or-later

#ifndef BUILD_BRIDGE
# error This file should not be compiled if not building bridge
@@ -215,7 +201,7 @@ public:
if (! File::isAbsolutePath(gProjectFilename))
gProjectFilename = File::getCurrentWorkingDirectory().getChildFile(gProjectFilename).getFullPathName();

if (File(gProjectFilename).existsAsFile())
if (File(gProjectFilename.toRawUTF8()).existsAsFile())
{
if (carla_load_plugin_state(gHostHandle, 0, gProjectFilename.toRawUTF8()))
carla_stdout("Plugin state loaded successfully");


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

@@ -1,6 +1,6 @@
/*
* Carla Native Plugin API (C++)
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -64,7 +64,7 @@ struct NativePluginPresetManager {
{
std::vector<File> results;

if (const uint count = File(*it).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard))
if (const uint count = File(it->toRawUTF8()).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard))
{
for (uint i=0; i<count; ++i)
filenames.add(results[i].getFullPathName());
@@ -126,7 +126,7 @@ protected:
const NativePluginPresetManagerType& pm(kPrograms.get());
CARLA_SAFE_ASSERT_RETURN(index < pm.filenames.size(), nullptr);

fRetMidiProgramName = File(pm.filenames.strings.getUnchecked(index)).getFileNameWithoutExtension();
fRetMidiProgramName = File(pm.filenames.strings.getUnchecked(index).toRawUTF8()).getFileNameWithoutExtension();

fRetMidiProgram.bank = 0;
fRetMidiProgram.program = uindex;


+ 2
- 2
source/modules/water/files/DirectoryIterator.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2024 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -149,7 +149,7 @@ const File& DirectoryIterator::getFile() const
float DirectoryIterator::getEstimatedProgress() const
{
if (totalNumFiles < 0)
totalNumFiles = File (path).getNumberOfChildFiles (File::findFilesAndDirectories);
totalNumFiles = File (path.toRawUTF8()).getNumberOfChildFiles (File::findFilesAndDirectories);
if (totalNumFiles <= 0)
return 0.0f;


+ 18
- 24
source/modules/water/files/File.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017-2023 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2024 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -57,8 +57,8 @@ File::File () noexcept
{
}
File::File (const String& fullPathName)
: fullPath (parseAbsolutePath (fullPathName))
File::File (const char* const absolutePath)
: fullPath (parseAbsolutePath (absolutePath))
{
}
@@ -74,9 +74,9 @@ File::File (const File& other)
{
}
File& File::operator= (const String& newPath)
File& File::operator= (const char* const newAbsolutePath)
{
fullPath = parseAbsolutePath (newPath);
fullPath = parseAbsolutePath (newAbsolutePath);
return *this;
}
@@ -420,7 +420,7 @@ File File::getChildFile (StringRef relativePath) const
CharPointer_UTF8 r = relativePath.text;
if (isAbsolutePath (r))
return File (String (r));
return File (r);
#ifdef CARLA_OS_WIN
if (r.indexOf ((water_uchar) '/') >= 0)
@@ -467,7 +467,7 @@ File File::getChildFile (StringRef relativePath) const
path = addTrailingSeparator (path);
path.appendCharPointer (r);
return File (path);
return File (path.toRawUTF8());
}
File File::getSiblingFile (StringRef fileName) const
@@ -572,16 +572,11 @@ String File::loadFileAsString() const
: String();
}
void File::readLines (StringArray& destLines) const
{
destLines.addLines (loadFileAsString());
}
//==============================================================================
uint File::findChildFiles (std::vector<File>& results,
const int whatToLookFor,
const bool searchRecursively,
const String& wildCardPattern) const
const char* const wildCardPattern) const
{
uint total = 0;
@@ -594,7 +589,7 @@ uint File::findChildFiles (std::vector<File>& results,
return total;
}
uint File::getNumberOfChildFiles (const int whatToLookFor, const String& wildCardPattern) const
uint File::getNumberOfChildFiles (const int whatToLookFor, const char* const wildCardPattern) const
{
uint total = 0;
@@ -1443,7 +1438,7 @@ File water_getExecutableFile()
for (int i=paths.size(); --i>=0;)
{
const File filepath (File (paths[i]).getChildFile (filename));
const File filepath (File (paths[i].toRawUTF8()).getChildFile (filename));
if (filepath.existsAsFile())
return filepath.getFullPathName();
@@ -1457,7 +1452,7 @@ File water_getExecutableFile()
};
static String filename (DLAddrReader::getFilename());
return filename;
return filename.toRawUTF8();
}
#ifdef CARLA_OS_MAC
@@ -1511,9 +1506,9 @@ File File::getSpecialLocation (const SpecialLocationType type)
case tempDirectory:
{
File tmp ("~/Library/Caches/" + water_getExecutableFile().getFileNameWithoutExtension());
File tmp (String("~/Library/Caches/" + water_getExecutableFile().getFileNameWithoutExtension()).toRawUTF8());
tmp.createDirectory();
return File (tmp.getFullPathName());
return File (tmp.getFullPathName().toRawUTF8());
}
case currentExecutableFile:
@@ -1522,11 +1517,10 @@ File File::getSpecialLocation (const SpecialLocationType type)
case hostApplicationPath:
{
unsigned int size = 8192;
HeapBlock<char> buffer;
buffer.calloc (size + 8);
_NSGetExecutablePath (buffer.getData(), &size);
return File (String::fromUTF8 (buffer, (int) size));
char* const buffer = new char[size + 8];
_NSGetExecutablePath (buffer, &size);
buffer[size] = 0;
return File (buffer);
}
default:
@@ -1535,7 +1529,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
}
if (resultPath.isNotEmpty())
return File (resultPath.convertToPrecomposedUnicode());
return File (resultPath.convertToPrecomposedUnicode().toRawUTF8());
return File();
}


+ 6
- 12
source/modules/water/files/File.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017-2023 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2024 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -26,7 +26,6 @@
#ifndef WATER_FILE_H_INCLUDED
#define WATER_FILE_H_INCLUDED
#include "../containers/Array.h"
#include "../misc/Result.h"
#include "../text/String.h"
@@ -69,7 +68,7 @@ public:
On the Mac/Linux, the path can include "~" notation for referring to
user home directories.
*/
File (const String& absolutePath);
File (const char* absolutePath);
/** Creates a copy of another file object. */
File (const File&);
@@ -87,7 +86,7 @@ public:
On the Mac/Linux, the path can include "~" notation for referring to
user home directories.
*/
File& operator= (const String& newAbsolutePath);
File& operator= (const char* newAbsolutePath);
/** Copies from another file object. */
File& operator= (const File& otherFile);
@@ -469,7 +468,7 @@ public:
Assuming that this file is a directory, this method will search it
for either files or subdirectories whose names match a filename pattern.
@param results an array to which File objects will be added for the
@param results an vector to which File objects will be added for the
files that the search comes up with
@param whatToLookFor a value from the TypesOfFileToFind enum, specifying whether to
return files, directories, or both. If the ignoreHiddenFiles flag
@@ -484,7 +483,7 @@ public:
uint findChildFiles (std::vector<File>& results,
int whatToLookFor,
bool searchRecursively,
const String& wildCardPattern = "*") const;
const char* wildCardPattern = "*") const;
/** Searches inside a directory and counts how many files match a wildcard pattern.
@@ -503,7 +502,7 @@ public:
@see findChildFiles, DirectoryIterator
*/
uint getNumberOfChildFiles (int whatToLookFor,
const String& wildCardPattern = "*") const;
const char* wildCardPattern = "*") const;
/** Returns true if this file is a directory that contains one or more subdirectories.
@see isDirectory, findChildFiles
@@ -553,11 +552,6 @@ public:
*/
String loadFileAsString() const;
/** Reads the contents of this file as text and splits it into lines, which are
appended to the given StringArray.
*/
void readLines (StringArray& destLines) const;
//==============================================================================
/** Appends a block of binary data to the end of the file.


+ 2
- 3
source/native-plugins/midi-file.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -365,8 +365,7 @@ private:

using namespace water;

const String jfilename = String(CharPointer_UTF8(filename));
File file(jfilename);
File file(filename);

if (! file.existsAsFile())
return;


+ 4
- 5
source/utils/CarlaDssiUtils.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla DSSI utils
* Copyright (C) 2013-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -32,7 +32,7 @@ const char* find_dssi_ui(const char* const filename, const char* const label) no
water::String pluginDir(water::String(filename).upToLastOccurrenceOf(".", false, false));

water::String checkLabel(label);
water::String checkSName(water::File(pluginDir).getFileName());
water::String checkSName(water::File(pluginDir.toRawUTF8()).getFileName());

if (checkSName.endsWithIgnoreCase("dssi"))
{
@@ -47,9 +47,8 @@ const char* find_dssi_ui(const char* const filename, const char* const label) no

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

if (const uint count = water::File(pluginDir).findChildFiles(results,
water::File::findFiles|water::File::ignoreHiddenFiles,
false))
if (const uint count = water::File(pluginDir.toRawUTF8()).findChildFiles(
results, water::File::findFiles|water::File::ignoreHiddenFiles, false))
{
for (uint i=0; i<count; ++i)
{


Loading…
Cancel
Save