@@ -224,7 +224,7 @@ public: | |||||
bool getLabel(char* const strBuf) const noexcept override | bool getLabel(char* const strBuf) const noexcept override | ||||
{ | { | ||||
std::strncpy(strBuf, fUnit.getFileId().toRawUTF8(), STR_MAX); | |||||
std::strncpy(strBuf, fUnit.getFileId(), STR_MAX); | |||||
return true; | return true; | ||||
} | } | ||||
@@ -960,7 +960,7 @@ public: | |||||
const File currentPath(splitPaths[i].toRawUTF8()); | const File currentPath(splitPaths[i].toRawUTF8()); | ||||
const File currentFile = currentPath.getChildFile(CharPointer_UTF8(label)); | const File currentFile = currentPath.getChildFile(CharPointer_UTF8(label)); | ||||
const CarlaJsfxUnit currentUnit(currentPath, currentFile); | const CarlaJsfxUnit currentUnit(currentPath, currentFile); | ||||
if (File(currentUnit.getFilePath().toRawUTF8()).existsAsFile()) | |||||
if (File(currentUnit.getFilePath()).existsAsFile()) | |||||
fUnit = currentUnit; | fUnit = currentUnit; | ||||
} | } | ||||
} | } | ||||
@@ -977,12 +977,12 @@ public: | |||||
ysfx_config_u config(ysfx_config_new()); | ysfx_config_u config(ysfx_config_new()); | ||||
CARLA_SAFE_ASSERT_RETURN(config != nullptr, false); | CARLA_SAFE_ASSERT_RETURN(config != nullptr, false); | ||||
const water::String rootPath = fUnit.getRootPath(); | |||||
const water::String filePath = fUnit.getFilePath(); | |||||
const CarlaString rootPath = fUnit.getRootPath(); | |||||
const CarlaString filePath = fUnit.getFilePath(); | |||||
ysfx_register_builtin_audio_formats(config.get()); | ysfx_register_builtin_audio_formats(config.get()); | ||||
ysfx_set_import_root(config.get(), rootPath.toRawUTF8()); | |||||
ysfx_guess_file_roots(config.get(), filePath.toRawUTF8()); | |||||
ysfx_set_import_root(config.get(), rootPath); | |||||
ysfx_guess_file_roots(config.get(), filePath); | |||||
ysfx_set_log_reporter(config.get(), &CarlaJsfxLogging::logAll); | ysfx_set_log_reporter(config.get(), &CarlaJsfxLogging::logAll); | ||||
ysfx_set_user_data(config.get(), (intptr_t)this); | ysfx_set_user_data(config.get(), (intptr_t)this); | ||||
@@ -993,7 +993,7 @@ public: | |||||
// get info | // get info | ||||
{ | { | ||||
if (! ysfx_load_file(fEffect, filePath.toRawUTF8(), 0)) | |||||
if (! ysfx_load_file(fEffect, filePath, 0)) | |||||
{ | { | ||||
pData->engine->setLastError("Failed to load JSFX"); | pData->engine->setLastError("Failed to load JSFX"); | ||||
return false; | return false; | ||||
@@ -1021,7 +1021,7 @@ public: | |||||
pData->name = carla_strdup(ysfx_get_name(fEffect)); | pData->name = carla_strdup(ysfx_get_name(fEffect)); | ||||
} | } | ||||
pData->filename = carla_strdup(filePath.toRawUTF8()); | |||||
pData->filename = filePath.dup(); | |||||
// --------------------------------------------------------------- | // --------------------------------------------------------------- | ||||
// register client | // register client | ||||
@@ -627,17 +627,17 @@ static const CarlaCachedPluginInfo* get_cached_plugin_jsfx(const CB::CarlaJsfxUn | |||||
ysfx_config_u config(ysfx_config_new()); | ysfx_config_u config(ysfx_config_new()); | ||||
const water::String rootPath = unit.getRootPath(); | |||||
const water::String filePath = unit.getFilePath(); | |||||
const CarlaString rootPath = unit.getRootPath(); | |||||
const CarlaString filePath = unit.getFilePath(); | |||||
ysfx_register_builtin_audio_formats(config.get()); | ysfx_register_builtin_audio_formats(config.get()); | ||||
ysfx_set_import_root(config.get(), rootPath.toRawUTF8()); | |||||
ysfx_guess_file_roots(config.get(), filePath.toRawUTF8()); | |||||
ysfx_set_import_root(config.get(), rootPath); | |||||
ysfx_guess_file_roots(config.get(), filePath); | |||||
ysfx_set_log_reporter(config.get(), &CB::CarlaJsfxLogging::logErrorsOnly); | ysfx_set_log_reporter(config.get(), &CB::CarlaJsfxLogging::logErrorsOnly); | ||||
ysfx_u effect(ysfx_new(config.get())); | ysfx_u effect(ysfx_new(config.get())); | ||||
if (! ysfx_load_file(effect.get(), filePath.toRawUTF8(), 0)) | |||||
if (! ysfx_load_file(effect.get(), filePath, 0)) | |||||
{ | { | ||||
info.valid = false; | info.valid = false; | ||||
return &info; | return &info; | ||||
@@ -654,11 +654,11 @@ static const CarlaCachedPluginInfo* get_cached_plugin_jsfx(const CB::CarlaJsfxUn | |||||
} | } | ||||
static CarlaString name, label, maker; | static CarlaString name, label, maker; | ||||
label = unit.getFileId().toRawUTF8(); | |||||
label = unit.getFileId(); | |||||
name = ysfx_get_name(effect.get()); | name = ysfx_get_name(effect.get()); | ||||
maker = ysfx_get_author(effect.get()); | maker = ysfx_get_author(effect.get()); | ||||
info.valid = true; | |||||
info.valid = true; | |||||
info.category = CB::CarlaJsfxCategories::getFromEffect(effect.get()); | info.category = CB::CarlaJsfxCategories::getFromEffect(effect.get()); | ||||
@@ -24,7 +24,6 @@ | |||||
*/ | */ | ||||
#include "DirectoryIterator.h" | #include "DirectoryIterator.h" | ||||
#include "../text/StringArray.h" | |||||
namespace water { | namespace water { | ||||
@@ -146,18 +145,4 @@ const File& DirectoryIterator::getFile() const | |||||
return currentFile; | return currentFile; | ||||
} | } | ||||
float DirectoryIterator::getEstimatedProgress() const | |||||
{ | |||||
if (totalNumFiles < 0) | |||||
totalNumFiles = File (path.toRawUTF8()).getNumberOfChildFiles (File::findFilesAndDirectories); | |||||
if (totalNumFiles <= 0) | |||||
return 0.0f; | |||||
const float detailedIndex = (subIterator != nullptr) ? index + subIterator->getEstimatedProgress() | |||||
: (float) index; | |||||
return detailedIndex / totalNumFiles; | |||||
} | |||||
} | } |
@@ -3,7 +3,7 @@ | |||||
This file is part of the Water library. | This file is part of the Water library. | ||||
Copyright (c) 2016 ROLI Ltd. | Copyright (c) 2016 ROLI Ltd. | ||||
Copyright (C) 2017-2022 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 | Permission is granted to use this software under the terms of the ISC license | ||||
http://www.isc.org/downloads/software-support-policy/isc-license/ | http://www.isc.org/downloads/software-support-policy/isc-license/ | ||||
@@ -109,13 +109,6 @@ public: | |||||
*/ | */ | ||||
const File& getFile() const; | const File& getFile() const; | ||||
/** Returns a guess of how far through the search the iterator has got. | |||||
@returns a value 0.0 to 1.0 to show the progress, although this won't be | |||||
very accurate. | |||||
*/ | |||||
float getEstimatedProgress() const; | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
class NativeIterator | class NativeIterator | ||||
@@ -124,8 +117,7 @@ private: | |||||
NativeIterator (const File& directory, const String& wildCard); | NativeIterator (const File& directory, const String& wildCard); | ||||
~NativeIterator(); | ~NativeIterator(); | ||||
bool next (String& filenameFound, | |||||
bool* isDirectory, int64* fileSize, bool* isReadOnly); | |||||
bool next (String& filenameFound, bool* isDirectory, int64* fileSize, bool* isReadOnly); | |||||
class Pimpl; | class Pimpl; | ||||
@@ -151,7 +151,7 @@ String File::parseAbsolutePath (const String& p) | |||||
// Check if path is valid under Wine | // Check if path is valid under Wine | ||||
String testpath ("Z:" + path); | String testpath ("Z:" + path); | ||||
if (File(testpath).exists()) | |||||
if (File(testpath.toRawUTF8()).exists()) | |||||
{ | { | ||||
path = testpath; | path = testpath; | ||||
} | } | ||||
@@ -181,7 +181,7 @@ String File::parseAbsolutePath (const String& p) | |||||
*/ | */ | ||||
carla_safe_assert(path.toRawUTF8(), __FILE__, __LINE__); | carla_safe_assert(path.toRawUTF8(), __FILE__, __LINE__); | ||||
return File::getCurrentWorkingDirectory().getChildFile (path).getFullPathName(); | |||||
return File::getCurrentWorkingDirectory().getChildFile (path.toRawUTF8()).getFullPathName(); | |||||
} | } | ||||
#else | #else | ||||
// Mac or Linux.. | // Mac or Linux.. | ||||
@@ -424,7 +424,7 @@ File File::getChildFile (const char* const relativePath) const | |||||
#ifdef CARLA_OS_WIN | #ifdef CARLA_OS_WIN | ||||
if (r.indexOf ((water_uchar) '/') >= 0) | if (r.indexOf ((water_uchar) '/') >= 0) | ||||
return getChildFile (String (r).replaceCharacter ('/', '\\')); | |||||
return getChildFile (String (r).replaceCharacter ('/', '\\').toRawUTF8()); | |||||
#endif | #endif | ||||
String path (fullPath); | String path (fullPath); | ||||
@@ -992,7 +992,7 @@ namespace WindowsFileHelpers | |||||
CHAR apath [MAX_PATH + 256]; | CHAR apath [MAX_PATH + 256]; | ||||
if (WideCharToMultiByte (CP_UTF8, 0, wpath, -1, apath, numElementsInArray (apath), nullptr, nullptr)) | if (WideCharToMultiByte (CP_UTF8, 0, wpath, -1, apath, numElementsInArray (apath), nullptr, nullptr)) | ||||
return File (String (apath)); | |||||
return File (apath); | |||||
} | } | ||||
return File(); | return File(); | ||||
@@ -1006,7 +1006,7 @@ namespace WindowsFileHelpers | |||||
GetModuleFileNameW (moduleHandle, wdest, (DWORD) numElementsInArray (wdest)); | GetModuleFileNameW (moduleHandle, wdest, (DWORD) numElementsInArray (wdest)); | ||||
if (WideCharToMultiByte (CP_UTF8, 0, wdest, -1, adest, numElementsInArray (adest), nullptr, nullptr)) | if (WideCharToMultiByte (CP_UTF8, 0, wdest, -1, adest, numElementsInArray (adest), nullptr, nullptr)) | ||||
return File (String (adest)); | |||||
return File (adest); | |||||
return File(); | return File(); | ||||
} | } | ||||
@@ -1120,7 +1120,7 @@ File File::getCurrentWorkingDirectory() | |||||
GetCurrentDirectoryW ((DWORD) numElementsInArray (wdest), wdest); | GetCurrentDirectoryW ((DWORD) numElementsInArray (wdest), wdest); | ||||
if (WideCharToMultiByte (CP_UTF8, 0, wdest, -1, adest, numElementsInArray (adest), nullptr, nullptr)) | if (WideCharToMultiByte (CP_UTF8, 0, wdest, -1, adest, numElementsInArray (adest), nullptr, nullptr)) | ||||
return File (String (adest)); | |||||
return File (adest); | |||||
return File(); | return File(); | ||||
} | } | ||||
@@ -1153,7 +1153,7 @@ File File::getSpecialLocation (const SpecialLocationType type) | |||||
GetTempPathW ((DWORD) numElementsInArray (wdest), wdest); | GetTempPathW ((DWORD) numElementsInArray (wdest), wdest); | ||||
if (WideCharToMultiByte (CP_UTF8, 0, wdest, -1, adest, numElementsInArray (adest), nullptr, nullptr)) | if (WideCharToMultiByte (CP_UTF8, 0, wdest, -1, adest, numElementsInArray (adest), nullptr, nullptr)) | ||||
return File (String (adest)); | |||||
return File (adest); | |||||
return File(); | return File(); | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* Carla JSFX utils | * Carla JSFX utils | ||||
* Copyright (C) 2021 Jean Pierre Cimalando | * Copyright (C) 2021 Jean Pierre Cimalando | ||||
* Copyright (C) 2021-2022 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 | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -19,21 +19,16 @@ | |||||
#ifndef CARLA_JSFX_UTILS_HPP_INCLUDED | #ifndef CARLA_JSFX_UTILS_HPP_INCLUDED | ||||
#define CARLA_JSFX_UTILS_HPP_INCLUDED | #define CARLA_JSFX_UTILS_HPP_INCLUDED | ||||
#include "CarlaDefines.h" | |||||
#include "CarlaBackend.h" | #include "CarlaBackend.h" | ||||
#include "CarlaUtils.hpp" | |||||
#include "CarlaJuceUtils.hpp" | |||||
#include "CarlaString.hpp" | |||||
#include "water/files/File.h" | #include "water/files/File.h" | ||||
#include "water/text/String.h" | |||||
#ifdef YSFX_API | #ifdef YSFX_API | ||||
# error YSFX_API is not private | # error YSFX_API is not private | ||||
#endif | #endif | ||||
#include "ysfx/include/ysfx.h" | #include "ysfx/include/ysfx.h" | ||||
#include <memory> | |||||
CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -76,7 +71,7 @@ struct CarlaJsfxLogging | |||||
struct CarlaJsfxCategories | struct CarlaJsfxCategories | ||||
{ | { | ||||
static PluginCategory getFromEffect(ysfx_t* effect) | |||||
static PluginCategory getFromEffect(ysfx_t* const effect) | |||||
{ | { | ||||
PluginCategory category = PLUGIN_CATEGORY_OTHER; | PluginCategory category = PLUGIN_CATEGORY_OTHER; | ||||
@@ -88,8 +83,8 @@ struct CarlaJsfxCategories | |||||
for (uint32_t i=0; i<tagCount && category == PLUGIN_CATEGORY_OTHER; ++i) | for (uint32_t i=0; i<tagCount && category == PLUGIN_CATEGORY_OTHER; ++i) | ||||
{ | { | ||||
water::CharPointer_UTF8 tag(tags[i]); | |||||
PluginCategory current = getFromTag(tag); | |||||
PluginCategory current = getFromTag(tags[i]); | |||||
if (current != PLUGIN_CATEGORY_NONE) | if (current != PLUGIN_CATEGORY_NONE) | ||||
category = current; | category = current; | ||||
} | } | ||||
@@ -98,30 +93,30 @@ struct CarlaJsfxCategories | |||||
return category; | return category; | ||||
} | } | ||||
static PluginCategory getFromTag(const water::CharPointer_UTF8 tag) | |||||
static PluginCategory getFromTag(const char* const tag) | |||||
{ | { | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("synthesis")) == 0) | |||||
if (carla_strcasecmp(tag, "synthesis") == 0) | |||||
return PLUGIN_CATEGORY_SYNTH; | return PLUGIN_CATEGORY_SYNTH; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("delay")) == 0) | |||||
if (carla_strcasecmp(tag, "delay") == 0) | |||||
return PLUGIN_CATEGORY_DELAY; | return PLUGIN_CATEGORY_DELAY; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("equalizer")) == 0) | |||||
if (carla_strcasecmp(tag, "equalizer") == 0) | |||||
return PLUGIN_CATEGORY_EQ; | return PLUGIN_CATEGORY_EQ; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("filter")) == 0) | |||||
if (carla_strcasecmp(tag, "filter") == 0) | |||||
return PLUGIN_CATEGORY_FILTER; | return PLUGIN_CATEGORY_FILTER; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("distortion")) == 0) | |||||
if (carla_strcasecmp(tag, "distortion") == 0) | |||||
return PLUGIN_CATEGORY_DISTORTION; | return PLUGIN_CATEGORY_DISTORTION; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("dynamics")) == 0) | |||||
if (carla_strcasecmp(tag, "dynamics") == 0) | |||||
return PLUGIN_CATEGORY_DYNAMICS; | return PLUGIN_CATEGORY_DYNAMICS; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("modulation")) == 0) | |||||
if (carla_strcasecmp(tag, "modulation") == 0) | |||||
return PLUGIN_CATEGORY_MODULATOR; | return PLUGIN_CATEGORY_MODULATOR; | ||||
if (tag.compareIgnoreCase(water::CharPointer_UTF8("utility")) == 0) | |||||
if (carla_strcasecmp(tag, "utility") == 0) | |||||
return PLUGIN_CATEGORY_UTILITY; | return PLUGIN_CATEGORY_UTILITY; | ||||
return PLUGIN_CATEGORY_NONE; | return PLUGIN_CATEGORY_NONE; | ||||
@@ -132,12 +127,12 @@ struct CarlaJsfxCategories | |||||
class CarlaJsfxUnit | class CarlaJsfxUnit | ||||
{ | { | ||||
static water::String createFileId(const water::File& rootPath, const water::File& filePath) | |||||
static CarlaString createFileId(const water::File& rootPath, const water::File& filePath) | |||||
{ | { | ||||
water::String fileId(filePath.getRelativePathFrom(rootPath)); | |||||
#ifdef CARLA_OS_WIN | |||||
fileId.replaceCharacter('\\', '/'); | |||||
#endif | |||||
CarlaString fileId(filePath.getRelativePathFrom(rootPath).toRawUTF8()); | |||||
#ifdef CARLA_OS_WIN | |||||
fileId.replace('\\', '/'); | |||||
#endif | |||||
return fileId; | return fileId; | ||||
} | } | ||||
@@ -149,33 +144,33 @@ public: | |||||
CarlaJsfxUnit(const water::File& rootPath, const water::File& filePath) | CarlaJsfxUnit(const water::File& rootPath, const water::File& filePath) | ||||
: fFileId(createFileId(rootPath, filePath)), | : fFileId(createFileId(rootPath, filePath)), | ||||
fFilePath(rootPath.getChildFile(fFileId.toRawUTF8()).getFullPathName()), | |||||
fRootPath(rootPath.getFullPathName()) {} | |||||
fFilePath(rootPath.getChildFile(fFileId).getFullPathName().toRawUTF8()), | |||||
fRootPath(rootPath.getFullPathName().toRawUTF8()) {} | |||||
explicit operator bool() const noexcept | explicit operator bool() const noexcept | ||||
{ | { | ||||
return fFileId.isNotEmpty(); | return fFileId.isNotEmpty(); | ||||
} | } | ||||
const water::String& getFileId() const noexcept | |||||
const CarlaString& getFileId() const noexcept | |||||
{ | { | ||||
return fFileId; | return fFileId; | ||||
} | } | ||||
const water::String& getFilePath() const noexcept | |||||
const CarlaString& getFilePath() const noexcept | |||||
{ | { | ||||
return fFilePath; | return fFilePath; | ||||
} | } | ||||
const water::String& getRootPath() const noexcept | |||||
const CarlaString& getRootPath() const noexcept | |||||
{ | { | ||||
return fRootPath; | return fRootPath; | ||||
} | } | ||||
private: | private: | ||||
water::String fFileId; | |||||
water::String fFilePath; | |||||
water::String fRootPath; | |||||
CarlaString fFileId; | |||||
CarlaString fFilePath; | |||||
CarlaString fRootPath; | |||||
}; | }; | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -1,19 +1,5 @@ | |||||
/* | |||||
* Carla String | |||||
* 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 | |||||
* 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 CARLA_STRING_HPP_INCLUDED | #ifndef CARLA_STRING_HPP_INCLUDED | ||||
#define CARLA_STRING_HPP_INCLUDED | #define CARLA_STRING_HPP_INCLUDED | ||||
@@ -297,23 +283,9 @@ public: | |||||
CARLA_SAFE_ASSERT_RETURN(strBuf != nullptr, false); | CARLA_SAFE_ASSERT_RETURN(strBuf != nullptr, false); | ||||
if (ignoreCase) | if (ignoreCase) | ||||
{ | |||||
#ifdef __USE_GNU | |||||
return (strcasestr(fBuffer, strBuf) != nullptr); | |||||
#else | |||||
CarlaString tmp1(fBuffer), tmp2(strBuf); | |||||
// memory allocation failed or empty string(s) | |||||
if (tmp1.fBuffer == _null() || tmp2.fBuffer == _null()) | |||||
return false; | |||||
tmp1.toLower(); | |||||
tmp2.toLower(); | |||||
return (std::strstr(tmp1, tmp2) != nullptr); | |||||
#endif | |||||
} | |||||
return carla_strcasestr(fBuffer, strBuf) != nullptr; | |||||
return (std::strstr(fBuffer, strBuf) != nullptr); | |||||
return std::strstr(fBuffer, strBuf) != nullptr; | |||||
} | } | ||||
/* | /* | ||||
@@ -1,19 +1,5 @@ | |||||
/* | |||||
* Carla common utils | |||||
* 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 CARLA_UTILS_HPP_INCLUDED | #ifndef CARLA_UTILS_HPP_INCLUDED | ||||
#define CARLA_UTILS_HPP_INCLUDED | #define CARLA_UTILS_HPP_INCLUDED | ||||
@@ -40,9 +26,11 @@ | |||||
# define NOMINMAX | # define NOMINMAX | ||||
# endif | # endif | ||||
# define WIN32_LEAN_AND_MEAN 1 | # define WIN32_LEAN_AND_MEAN 1 | ||||
# include <shlwapi.h> | |||||
# include <winsock2.h> | # include <winsock2.h> | ||||
# include <windows.h> | # include <windows.h> | ||||
#else | #else | ||||
# include <strings.h> | |||||
# include <unistd.h> | # include <unistd.h> | ||||
#endif | #endif | ||||
@@ -361,7 +349,7 @@ const char* carla_strdup(const char* const strBuf) | |||||
static inline | static inline | ||||
const char* carla_strdup_free(char* const strBuf) | const char* carla_strdup_free(char* const strBuf) | ||||
{ | { | ||||
const char* const buffer(carla_strdup(strBuf)); | |||||
const char* const buffer = carla_strdup(strBuf); | |||||
std::free(strBuf); | std::free(strBuf); | ||||
return buffer; | return buffer; | ||||
} | } | ||||
@@ -390,6 +378,35 @@ const char* carla_strdup_safe(const char* const strBuf) noexcept | |||||
return buffer; | return buffer; | ||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | |||||
// carla_strcase* | |||||
#ifdef CARLA_OS_WIN | |||||
static inline | |||||
int carla_strcasecmp(const char* const str1, const char* const str2) noexcept | |||||
{ | |||||
return ::StrCmpIA(str1, str2); | |||||
} | |||||
static inline | |||||
const char* carla_strcasestr(const char* const haystack, const char* const needle) noexcept | |||||
{ | |||||
return ::StrStrIA(haystack, needle); | |||||
} | |||||
#else | |||||
static inline | |||||
ssize_t carla_strcasecmp(const char* const str1, const char* const str2) noexcept | |||||
{ | |||||
return ::strcasecmp(str1, str2); | |||||
} | |||||
static inline | |||||
const char* carla_strcasestr(const char* const haystack, const char* const needle) noexcept | |||||
{ | |||||
return ::strcasestr(haystack, needle); | |||||
} | |||||
#endif | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
// memory functions | // memory functions | ||||