32 pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
47 time.tv_sec = millisecs / 1000;
48 time.tv_nsec = (millisecs % 1000) * 1000000;
62#if JUCE_MAC || JUCE_LINUX || JUCE_BSD
67 if (getrlimit (RLIMIT_NOFILE, &lim) == 0)
69 if (newMaxNumber <= 0 && lim.rlim_cur == RLIM_INFINITY && lim.rlim_max == RLIM_INFINITY)
72 if (newMaxNumber > 0 && lim.rlim_cur >= (rlim_t) newMaxNumber)
76 lim.rlim_cur = lim.rlim_max = newMaxNumber <= 0 ? RLIM_INFINITY : (rlim_t) newMaxNumber;
77 return setrlimit (RLIMIT_NOFILE, &lim) == 0;
80struct MaxNumFileHandlesInitialiser
82 MaxNumFileHandlesInitialiser() noexcept
84 #ifndef JUCE_PREFERRED_MAX_FILE_HANDLES
85 enum { JUCE_PREFERRED_MAX_FILE_HANDLES = 8192 };
89 if (! Process::setMaxNumberOfFileHandles (0))
91 for (
int num = JUCE_PREFERRED_MAX_FILE_HANDLES; num > 256; num -= 1024)
92 if (Process::setMaxNumberOfFileHandles (num))
98static MaxNumFileHandlesInitialiser maxNumFileHandlesInitialiser;
102#if JUCE_ALLOW_STATIC_NULL_VARIABLES
104JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Wdeprecated-declarations")
107const StringRef File::separatorString ("/");
109JUCE_END_IGNORE_WARNINGS_GCC_LIKE
122 char localBuffer[1024];
123 auto cwd =
getcwd (localBuffer,
sizeof (localBuffer) - 1);
124 size_t bufferSize = 4096;
128 heapBuffer.
malloc (bufferSize);
129 cwd =
getcwd (heapBuffer, bufferSize - 1);
143int juce_siginterrupt ([[maybe_unused]]
int sig, [[maybe_unused]]
int flag)
149 using juce_sigactionflags_type =
unsigned long;
151 using juce_sigactionflags_type =
int;
154 struct ::sigaction act;
155 (void) ::sigaction (sig,
nullptr, &act);
158 act.sa_flags &=
static_cast<juce_sigactionflags_type
> (~SA_RESTART);
160 act.sa_flags |=
static_cast<juce_sigactionflags_type
> (SA_RESTART);
162 return ::sigaction (sig, &act,
nullptr);
169 #if JUCE_LINUX || (JUCE_IOS && (! TARGET_OS_MACCATALYST) && (! __DARWIN_ONLY_64_BIT_INO_T))
170 using juce_statStruct =
struct stat64;
171 #define JUCE_STAT stat64
173 using juce_statStruct =
struct stat;
174 #define JUCE_STAT stat
177 bool juce_stat (
const String& fileName, juce_statStruct& info)
179 return fileName.isNotEmpty()
180 && JUCE_STAT (fileName.toUTF8(), &info) == 0;
185 bool juce_doStatFS (File f,
struct statfs& result)
187 for (
int i = 5; --i >= 0;)
192 f = f.getParentDirectory();
195 return statfs (f.getFullPathName().toUTF8(), &result) == 0;
198 #if JUCE_MAC || JUCE_IOS
199 static int64 getCreationTime (
const juce_statStruct& s)
noexcept {
return (
int64) s.st_birthtime; }
201 static int64 getCreationTime (
const juce_statStruct& s)
noexcept {
return (
int64) s.st_ctime; }
204 void updateStatInfoForFile (
const String& path,
bool* isDir,
int64* fileSize,
205 Time* modTime, Time* creationTime,
bool* isReadOnly)
207 if (isDir !=
nullptr || fileSize !=
nullptr || modTime !=
nullptr || creationTime !=
nullptr)
209 juce_statStruct info;
210 const bool statOk = juce_stat (path, info);
212 if (isDir !=
nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0);
213 if (fileSize !=
nullptr) *fileSize = statOk ? (
int64) info.st_size : 0;
214 if (modTime !=
nullptr) *modTime = Time (statOk ? (
int64) info.st_mtime * 1000 : 0);
215 if (creationTime !=
nullptr) *creationTime = Time (statOk ? getCreationTime (info) * 1000 : 0);
218 if (isReadOnly !=
nullptr)
219 *isReadOnly =
access (path.toUTF8(), W_OK) != 0;
223 Result getResultForErrno()
228 Result getResultForReturnValue (
int value)
230 return value == -1 ? getResultForErrno() : Result::ok();
234 void* fdToVoidPointer (
int fd)
noexcept {
return (
void*) (
pointer_sized_int) fd; }
239 juce_statStruct info;
242 && (juce_stat (fullPath, info) && ((info.st_mode & S_IFDIR) != 0));
258 juce_statStruct info;
259 return juce_stat (fullPath, info) ? info.st_size : 0;
264 juce_statStruct info;
265 return juce_stat (fullPath, info) ? (
uint64) info.st_ino : 0;
268static bool hasEffectiveRootFilePermissions()
270 #if JUCE_LINUX || JUCE_BSD
281 return (hasEffectiveRootFilePermissions()
296static bool setFileModeFlags (
const String& fullPath, mode_t flags,
bool shouldSet)
noexcept
298 juce_statStruct info;
300 if (! juce_stat (fullPath, info))
303 info.st_mode &= 0777;
306 info.st_mode |= flags;
308 info.st_mode &= ~flags;
310 return chmod (fullPath.toUTF8(), (mode_t) info.st_mode) == 0;
313bool File::setFileReadOnlyInternal (
bool shouldBeReadOnly)
const
316 return setFileModeFlags (fullPath, S_IWUSR | S_IWGRP | S_IWOTH, ! shouldBeReadOnly);
319bool File::setFileExecutableInternal (
bool shouldBeExecutable)
const
321 return setFileModeFlags (fullPath, S_IXUSR | S_IXGRP | S_IXOTH, shouldBeExecutable);
324void File::getFileTimesInternal (
int64& modificationTime,
int64& accessTime,
int64& creationTime)
const
326 modificationTime = 0;
330 juce_statStruct info;
332 if (juce_stat (fullPath, info))
334 #if JUCE_MAC || (JUCE_IOS && __DARWIN_ONLY_64_BIT_INO_T)
335 modificationTime = (
int64) info.st_mtimespec.tv_sec * 1000 + info.st_mtimespec.tv_nsec / 1000000;
336 accessTime = (
int64) info.st_atimespec.tv_sec * 1000 + info.st_atimespec.tv_nsec / 1000000;
337 creationTime = (
int64) info.st_birthtimespec.tv_sec * 1000 + info.st_birthtimespec.tv_nsec / 1000000;
339 modificationTime = (
int64) info.st_mtime * 1000;
340 accessTime = (
int64) info.st_atime * 1000;
342 creationTime = (
int64) info.st_birthtime * 1000;
344 creationTime = (
int64) info.st_ctime * 1000;
350bool File::setFileTimesInternal (
int64 modificationTime,
int64 accessTime,
int64 )
const
353 juce_statStruct info;
355 if ((modificationTime != 0 || accessTime != 0) && juce_stat (fullPath, info))
357 #if JUCE_MAC || (JUCE_IOS && __DARWIN_ONLY_64_BIT_INO_T)
358 struct timeval
times[2];
360 bool setModificationTime = (modificationTime != 0);
361 bool setAccessTime = (accessTime != 0);
363 times[0].tv_sec = setAccessTime ?
static_cast<__darwin_time_t
> (accessTime / 1000)
364 : info.st_atimespec.tv_sec;
366 times[0].tv_usec = setAccessTime ?
static_cast<__darwin_suseconds_t
> ((accessTime % 1000) * 1000)
367 : static_cast<__darwin_suseconds_t> (info.st_atimespec.tv_nsec / 1000);
369 times[1].tv_sec = setModificationTime ?
static_cast<__darwin_time_t
> (modificationTime / 1000)
370 : info.st_mtimespec.tv_sec;
372 times[1].tv_usec = setModificationTime ?
static_cast<__darwin_suseconds_t
> ((modificationTime % 1000) * 1000)
373 : static_cast<__darwin_suseconds_t> (info.st_mtimespec.tv_nsec / 1000);
377 struct utimbuf
times;
378 times.actime = accessTime != 0 ?
static_cast<time_t> (accessTime / 1000) : static_cast<
time_t> (info.st_atime);
379 times.modtime = modificationTime != 0 ?
static_cast<time_t> (modificationTime / 1000) : static_cast<
time_t> (info.st_mtime);
403bool File::moveInternal (
const File& dest)
const
408 if (isNonEmptyDirectory())
422bool File::replaceInternal (
const File& dest)
const
424 return moveInternal (dest);
427Result File::createDirectoryInternal (
const String& fileName)
const
429 return getResultForReturnValue (mkdir (fileName.toUTF8(), 0777));
433int64 juce_fileSetPosition (
void* handle,
int64 pos)
435 if (handle !=
nullptr && lseek (getFD (handle), (off_t) pos, SEEK_SET) == pos)
441void FileInputStream::openHandle()
446 fileHandle = fdToVoidPointer (f);
448 status = getResultForErrno();
453 if (fileHandle !=
nullptr)
454 close (getFD (fileHandle));
457size_t FileInputStream::readInternal (
void* buffer,
size_t numBytes)
461 if (fileHandle !=
nullptr)
463 result = ::read (getFD (fileHandle), buffer, numBytes);
467 status = getResultForErrno();
472 return (
size_t) result;
476void FileOutputStream::openHandle()
484 currentPosition =
lseek (f, 0, SEEK_END);
486 if (currentPosition >= 0)
488 fileHandle = fdToVoidPointer (f);
492 status = getResultForErrno();
498 status = getResultForErrno();
506 fileHandle = fdToVoidPointer (f);
508 status = getResultForErrno();
512void FileOutputStream::closeHandle()
514 if (fileHandle !=
nullptr)
516 close (getFD (fileHandle));
517 fileHandle =
nullptr;
521ssize_t FileOutputStream::writeInternal (
const void* data,
size_t numBytes)
523 if (fileHandle ==
nullptr)
526 auto result = ::write (getFD (fileHandle), data, numBytes);
529 status = getResultForErrno();
531 return (ssize_t) result;
535void FileOutputStream::flushInternal()
537 if (fileHandle !=
nullptr && fsync (getFD (fileHandle)) == -1)
538 status = getResultForErrno();
544 if (fileHandle ==
nullptr)
548 return getResultForReturnValue (
ftruncate (getFD (fileHandle), (
off_t) currentPosition));
554 if (
auto s = ::getenv (name.
toUTF8()))
562void MemoryMappedFile::openInternal (
const File& file, AccessMode mode,
bool exclusive)
568 auto pageSize =
sysconf (_SC_PAGE_SIZE);
575 fileHandle =
open (filename, O_CREAT | O_RDWR, 00644);
577 fileHandle =
open (filename, O_RDONLY);
579 if (fileHandle != -1)
582 mode ==
readWrite ? (PROT_READ | PROT_WRITE) : PROT_READ,
583 exclusive ? MAP_PRIVATE : MAP_SHARED, fileHandle,
584 (
off_t) range.getStart());
589 madvise (m, (
size_t) range.
getLength(), MADV_SEQUENTIAL);
593 range = Range<int64>();
603 if (address !=
nullptr)
611File juce_getExecutableFile();
612File juce_getExecutableFile()
616 static String getFilename()
620 auto localSymbol = (
void*) juce_getExecutableFile;
621 dladdr (localSymbol, &exeInfo);
626 static String filename = DLAddrReader::getFilename();
635 if (juce_doStatFS (*
this, buf))
636 return (
int64) buf.f_bsize * (
int64) buf.f_bavail;
645 if (juce_doStatFS (*
this, buf))
646 return (
int64) buf.f_bsize * (
int64) buf.f_blocks;
657 attrreference_t mountPointRef;
658 char mountPointSpace[MAXPATHLEN];
661 struct attrlist attrList;
663 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
664 attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_NAME;
671 return String::fromUTF8 (((
const char*) &attrBuf.mountPointRef) + attrBuf.mountPointRef.attr_dataoffset,
672 (
int) attrBuf.mountPointRef.attr_length);
695void juce_runSystemCommand (
const String&);
696void juce_runSystemCommand (
const String& command)
698 [[maybe_unused]]
int result =
system (command.
toUTF8());
701String juce_getOutputFromCommand (
const String&);
702String juce_getOutputFromCommand (
const String& command)
708 juce_runSystemCommand (command +
" > " + tempFile.getFullPathName());
710 auto result = tempFile.loadFileAsString();
711 tempFile.deleteFile();
718class InterProcessLock::Pimpl
721 Pimpl (
const String&,
int) {}
723 int handle = 1, refCount = 1;
731 Pimpl (
const String& lockName,
int timeOutMillisecs)
734 if (! createLockFile (
File (
"~/Library/Caches/com.juce.locks").getChildFile (lockName), timeOutMillisecs))
736 createLockFile (
File (
"/tmp/com.juce.locks").getChildFile (lockName), timeOutMillisecs);
739 File tempFolder (
"/var/tmp");
744 createLockFile (tempFolder.
getChildFile (lockName), timeOutMillisecs);
753 bool createLockFile (
const File& file,
int timeOutMillisecs)
763 fl.l_whence = SEEK_SET;
770 auto result =
fcntl (handle, F_SETLK, &fl);
782 if (timeOutMillisecs == 0
802 fl.l_whence = SEEK_SET;
813 int handle = 0, refCount = 1;
829 if (pimpl ==
nullptr)
831 pimpl.
reset (
new Pimpl (name, timeOutMillisecs));
833 if (pimpl->handle == 0)
841 return pimpl !=
nullptr;
851 if (pimpl !=
nullptr && --(pimpl->refCount) == 0)
860 if (valid && stackSize != 0)
870 auto* get() {
return valid ? &attr :
nullptr; }
884 pthread_getschedparam (
pthread_self(), &scheduler, ¶m);
885 return { scheduler, param.sched_priority };
891 const auto isRealtime = rt.hasValue();
893 const auto priority = [&]
900 return jmap (rt->getPriority(), 0, 10, min, max);
905 #if JUCE_MAC || JUCE_IOS
909 const auto p = [prio]
923 if (min != 0 && max != 0)
924 return jmap (p, 0, 4, min, max);
930 #if JUCE_MAC || JUCE_IOS || JUCE_BSD
931 const auto scheduler = SCHED_OTHER;
935 const auto scheduler = isRealtime ? SCHED_RR : backgroundSched;
937 const auto scheduler = 0;
940 return { scheduler, priority };
945 #if JUCE_LINUX || JUCE_BSD
946 const struct sched_param param { getPriority() };
948 pthread_attr_setinheritsched (attr.get(), PTHREAD_EXPLICIT_SCHED);
949 pthread_attr_setschedpolicy (attr.get(), getScheduler());
954 constexpr int getScheduler()
const {
return scheduler; }
955 constexpr int getPriority()
const {
return priority; }
959 : scheduler (schedulerIn), priority (priorityIn) {}
965static void* makeThreadHandle (
PosixThreadAttribute& attr,
void* userData,
void* (*threadEntryProc) (
void*))
969 const auto status =
pthread_create (&handle, attr.get(), threadEntryProc, userData);
975 return (
void*) handle;
978void Thread::closeThreadHandle()
981 threadHandle =
nullptr;
986 #if JUCE_IOS || JUCE_MAC
989 [[NSThread currentThread] setName: juceStringToNS (name)];
991 #elif JUCE_LINUX || JUCE_BSD || JUCE_ANDROID
993 || (JUCE_LINUX && (__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2012) \
994 || (JUCE_ANDROID && __ANDROID_API__ >= 9))
997 prctl (PR_SET_NAME, name.
toRawUTF8(), 0, 0, 0);
1017#if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES)
1018 #define SUPPORT_AFFINITIES 1
1023 #if SUPPORT_AFFINITIES
1025 CPU_ZERO (&affinity);
1027 for (
int i = 0; i < 32; ++i)
1029 if ((affinityMask & (
uint32) (1 << i)) != 0)
1033 JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Wsign-conversion")
1034 CPU_SET ((
size_t) i, &affinity);
1035 JUCE_END_IGNORE_WARNINGS_GCC_LIKE
1039 #if (! JUCE_ANDROID) && ((! (JUCE_LINUX || JUCE_BSD)) || ((__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2004))
1040 pthread_setaffinity_np (
pthread_self(),
sizeof (cpu_set_t), &affinity);
1042 sched_setaffinity (gettid(),
sizeof (cpu_set_t), &affinity);
1047 sched_setaffinity (
getpid(),
sizeof (cpu_set_t), &affinity);
1065 return handle !=
nullptr;
1070 if (handle !=
nullptr)
1079 return handle !=
nullptr ?
dlsym (handle, functionName.toUTF8()) :
nullptr;
1083#if JUCE_LINUX || JUCE_ANDROID
1084static String readPosixConfigFileValue (
const char* file,
const char* key)
1089 for (
int i = lines.
size(); --i >= 0;)
1090 if (lines[i].upToFirstOccurrenceOf (
":",
false,
false).trim().equalsIgnoreCase (key))
1091 return lines[i].fromFirstOccurrenceOf (
":",
false,
false).trim();
1104 auto exe = arguments[0].unquoted();
1111 int pipeHandles[2] = {};
1113 if (
pipe (pipeHandles) == 0)
1115 auto result =
fork();
1119 close (pipeHandles[0]);
1120 close (pipeHandles[1]);
1122 else if (result == 0)
1125 close (pipeHandles[0]);
1127 if ((streamFlags & wantStdOut) != 0)
1128 dup2 (pipeHandles[1], STDOUT_FILENO);
1130 dup2 (
open (
"/dev/null", O_WRONLY), STDOUT_FILENO);
1132 if ((streamFlags & wantStdErr) != 0)
1133 dup2 (pipeHandles[1], STDERR_FILENO);
1135 dup2 (
open (
"/dev/null", O_WRONLY), STDERR_FILENO);
1137 close (pipeHandles[1]);
1141 for (
auto& arg : arguments)
1142 if (arg.isNotEmpty())
1143 argv.
add (
const_cast<char*
> (arg.toRawUTF8()));
1154 pipeHandle = pipeHandles[0];
1155 close (pipeHandles[1]);
1162 if (readHandle !=
nullptr)
1165 if (pipeHandle != 0)
1169 bool isRunning()
noexcept
1175 auto pid =
waitpid (childPID, &childState, WNOHANG);
1180 if (WIFEXITED (childState))
1182 exitCode = WEXITSTATUS (childState);
1186 return ! WIFSIGNALED (childState);
1189 int read (
void* dest,
int numBytes)
noexcept
1191 jassert (dest !=
nullptr && numBytes > 0);
1197 if (readHandle ==
nullptr && childPID != 0)
1198 readHandle =
fdopen (pipeHandle,
"r");
1200 if (readHandle !=
nullptr)
1204 auto numBytesRead = (
int)
fread (dest, 1, (
size_t) numBytes, readHandle);
1206 if (numBytesRead > 0 ||
feof (readHandle))
1207 return numBytesRead;
1220 bool killProcess()
const noexcept
1222 return ::kill (childPID, SIGKILL) == 0;
1225 uint32 getExitCode()
noexcept
1228 return (
uint32) exitCode;
1233 auto pid =
waitpid (childPID, &childState, WNOHANG);
1235 if (pid >= 0 && WIFEXITED (childState))
1237 exitCode = WEXITSTATUS (childState);
1238 return (
uint32) exitCode;
1248 FILE* readHandle = {};
1260 if (args.
size() == 0)
1263 activeProcess.reset (
new ActiveProcess (args, streamFlags));
1265 if (activeProcess->childPID == 0)
1266 activeProcess.reset();
1268 return activeProcess !=
nullptr;
Holds a resizable array of primitive or copy-by-value objects.
ElementType * getRawDataPointer() noexcept
Returns a pointer to the actual array data.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
CharType * getAddress() const noexcept
Returns the address that this pointer is pointing to.
bool start(const String &command, int streamFlags=wantStdOut|wantStdErr)
Attempts to launch a child process command.
bool tryEnter() const noexcept
Attempts to lock this critical section without blocking.
~CriticalSection() noexcept
Destructor.
CriticalSection() noexcept
Creates a CriticalSection object.
void enter() const noexcept
Acquires the lock.
void exit() const noexcept
Releases the lock.
void * getFunction(const String &functionName) noexcept
Tries to find a named function in the currently-open DLL, and returns a pointer to it.
bool open(const String &name)
Opens a DLL.
void close()
Releases the currently-open DLL, or has no effect if none was open.
Result truncate()
Attempts to truncate the file to the current write position.
void flush() override
If the stream is using a buffer, this will ensure it gets written out to the destination.
Represents a local file or directory.
int getVolumeSerialNumber() const
Returns the serial number of the volume on which this file lives.
bool isSymbolicLink() const
Returns true if this file is a link or alias that can be followed using getLinkedTarget().
bool isDirectory() const
Checks whether the file is a directory that exists.
bool setAsCurrentWorkingDirectory() const
Sets the current working directory to be this file.
static StringRef getSeparatorString()
The system-specific file separator character, as a string.
int64 getVolumeTotalSize() const
Returns the total size of the drive that contains this file.
int64 getBytesFreeOnVolume() const
Returns the number of bytes free on the drive that this file lives on.
bool hasWriteAccess() const
Checks whether a file can be created or written to.
bool existsAsFile() const
Checks whether the file exists and is a file rather than a directory.
int64 getSize() const
Returns the size of the file in bytes.
const String & getFullPathName() const noexcept
Returns the complete, absolute path of this file.
File getChildFile(StringRef relativeOrAbsolutePath) const
Returns a file that represents a relative (or absolute) sub-path of the current one.
void readLines(StringArray &destLines) const
Reads the contents of this file as text and splits it into lines, which are appended to the given Str...
static File getCurrentWorkingDirectory()
Returns the current working directory.
@ tempDirectory
The folder that should be used for temporary files.
Result create() const
Creates an empty file if it doesn't already exist.
File getNonexistentChildFile(const String &prefix, const String &suffix, bool putNumbersInBrackets=true) const
Chooses a filename relative to this one that doesn't already exist.
static File JUCE_CALLTYPE getSpecialLocation(const SpecialLocationType type)
Finds the location of a special type of file or directory, such as a home folder or documents folder.
bool hasReadAccess() const
Checks whether a file can be read.
File getParentDirectory() const
Returns the directory that contains this file or directory.
String getVolumeLabel() const
Finds the name of the drive on which this file lives.
uint64 getFileIdentifier() const
Returns a unique identifier for the file, if one is available.
static juce_wchar getSeparatorChar()
The system-specific file separator character.
File()=default
Creates an (invalid) file object.
bool deleteFile() const
Deletes a file.
bool exists() const
Checks whether the file actually exists.
Automatically locks and unlocks a mutex object.
Very simple container class to hold a pointer to some data on the heap.
void malloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Allocates a specified amount of memory.
~InterProcessLock()
Destructor.
void exit()
Releases the lock if it's currently held by this process.
bool enter(int timeOutMillisecs=-1)
Attempts to lock the critical section.
InterProcessLock(const String &name)
Creates a lock object.
~MemoryMappedFile()
Destructor.
@ readWrite
Indicates that the memory can be read and written to - changes that are made will be flushed back to ...
@ readOnly
Indicates that the memory can only be read.
static void JUCE_CALLTYPE terminate()
Kills the current process immediately.
static bool setMaxNumberOfFileHandles(int maxNumberOfFiles) noexcept
UNIX ONLY - Attempts to use setrlimit to change the maximum number of file handles that the app can o...
static Random & getSystemRandom() noexcept
The overhead of creating a new Random object is fairly small, but if you want to avoid it,...
constexpr ValueType getStart() const noexcept
Returns the start of the range.
void setStart(const ValueType newStart) noexcept
Changes the start position of the range, leaving the end position unchanged.
constexpr ValueType getLength() const noexcept
Returns the length of the range.
Represents the 'success' or 'failure' of an operation, and holds an associated error message to descr...
static Result fail(const String &errorMessage) noexcept
Creates a 'failure' result.
A special array for holding a list of strings.
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Returns an array containing the tokens in a given string.
int size() const noexcept
Returns the number of strings in the array.
A simple class for holding temporary references to a string literal or String.
bool isEmpty() const noexcept
Returns true if the string contains no characters.
const char * toRawUTF8() const
Returns a pointer to a UTF-8 version of this string.
bool containsChar(juce_wchar character) const noexcept
Tests whether the string contains a particular character.
static String toHexString(IntegerType number)
Returns a string representing this numeric value in hexadecimal.
static String fromUTF8(const char *utf8buffer, int bufferSizeBytes=-1)
Creates a String from a UTF-8 encoded buffer.
CharPointer_UTF8 toUTF8() const
Returns a pointer to a UTF-8 version of this string.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
static String getEnvironmentVariable(const String &name, const String &defaultValue)
Returns an environment variable.
static void JUCE_CALLTYPE setCurrentThreadAffinityMask(uint32 affinityMask)
Changes the affinity mask for the caller thread.
void * ThreadID
A value type used for thread IDs.
static void JUCE_CALLTYPE yield()
Yields the current thread's CPU time-slot and allows a new thread to run.
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Returns an id that identifies the caller thread.
static void JUCE_CALLTYPE setCurrentThreadName(const String &newThreadName)
Changes the name of the caller thread.
Priority
The different runtime priorities of non-realtime threads.
@ low
Uses efficiency cores when possible.
@ high
Makes use of performance cores and higher clocks.
@ background
Restricted to efficiency cores on platforms that have them.
@ highest
The highest possible priority that isn't a dedicated realtime thread.
static void JUCE_CALLTYPE sleep(int milliseconds)
Suspends the execution of the current thread until the specified timeout period has elapsed (note tha...
static int64 currentTimeMillis() noexcept
Returns the current system time.
#define JUCE_AUTORELEASEPOOL
A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C ...
void zerostruct(Type &structure) noexcept
Overwrites a structure or object with zeros.
int pointer_sized_int
A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Remaps a normalised value (between 0 and 1) to a target range.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
unsigned long long uint64
A platform-independent 64-bit unsigned integer type.
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.
pthread_attr_setschedparam
pthread_attr_setstacksize
pthread_mutexattr_settype
typedef pthread_mutexattr_t