27 : fullPath (parseAbsolutePath (fullPathName))
39 : fullPath (other.fullPath)
45 fullPath = parseAbsolutePath (newPath);
51 fullPath = other.fullPath;
56 : fullPath (std::move (other.fullPath))
62 fullPath = std::move (other.fullPath);
66JUCE_DECLARE_DEPRECATED_STATIC (
const File File::nonexistent{};)
69static String removeEllipsis (
const String& path)
74 if (path.contains (
".\\"))
76 if (path.contains (
"./"))
81 bool anythingChanged =
false;
83 for (
int i = 1; i < toks.size(); ++i)
87 if (t ==
".." && toks[i - 1] !=
"..")
89 anythingChanged =
true;
90 toks.removeRange (i - 1, 2);
95 anythingChanged =
true;
107static String normaliseSeparators (
const String& path)
109 auto normalisedPath = path;
112 String doubleSeparator (separator + separator);
114 auto uncPath = normalisedPath.startsWith (doubleSeparator)
115 && ! normalisedPath.fromFirstOccurrenceOf (doubleSeparator,
false,
false).startsWith (separator);
118 normalisedPath = normalisedPath.fromFirstOccurrenceOf (doubleSeparator,
false,
false);
120 while (normalisedPath.contains (doubleSeparator))
121 normalisedPath = normalisedPath.replace (doubleSeparator, separator);
123 return uncPath ? doubleSeparator + normalisedPath
139 auto path = normaliseSeparators (removeEllipsis (p.
replaceCharacter (
'/',
'\\')));
157 else if (! path.containsChar (
':'))
178 auto path = normaliseSeparators (removeEllipsis (p));
180 if (path.startsWithChar (
'~'))
193 if (
auto* pw = getpwnam (userName.toUTF8()))
199 #if JUCE_DEBUG || JUCE_LOG_ASSERTIONS
200 if (! (path.startsWith (
"./") || path.startsWith (
"../")))
211 #if JUCE_LOG_ASSERTIONS
235 #define NAMES_ARE_CASE_SENSITIVE 1
240 #if NAMES_ARE_CASE_SENSITIVE
247static int compareFilenames (
const String& name1,
const String& name2)
noexcept
249 #if NAMES_ARE_CASE_SENSITIVE
250 return name1.compare (name2);
252 return name1.compareIgnoreCase (name2);
263 const bool applyRecursively)
const
269 worked = f.setReadOnly (shouldBeReadOnly,
true) && worked;
271 return setFileReadOnlyInternal (shouldBeReadOnly) && worked;
276 return setFileExecutableInternal (shouldBeExecutable);
285 worked = f.deleteRecursively (followSymlinks) && worked;
292 if (newFile.fullPath == fullPath)
298 #if ! NAMES_ARE_CASE_SENSITIVE
299 if (*
this != newFile)
304 return moveInternal (newFile);
309 return (*
this == newFile)
315 if (newFile.fullPath == fullPath)
321 if (! replaceInternal (newFile))
333 if (! f.copyFileTo (newDirectory.
getChildFile (f.getFileName())))
337 if (! f.copyDirectoryTo (newDirectory.
getChildFile (f.getFileName())))
347String File::getPathUpToLastSlash()
const
352 return fullPath.
substring (0, lastSlash);
376 if (lastDot > lastSlash)
377 return fullPath.
substring (lastSlash, lastDot);
384 if (potentialParent.fullPath.
isEmpty())
387 auto ourPath = getPathUpToLastSlash();
389 if (compareFilenames (potentialParent.fullPath, ourPath) == 0)
392 if (potentialParent.fullPath.
length() >= ourPath.length())
404 auto firstChar = *(path.
text);
408 || (firstChar != 0 && path.
text[1] ==
':');
416 auto r = relativePath.
text;
422 if (r.indexOf ((juce_wchar)
'/') >= 0)
426 auto path = fullPath;
432 auto secondChar = *++r;
434 if (secondChar ==
'.')
436 auto thirdChar = *++r;
438 if (thirdChar == separatorChar || thirdChar == 0)
440 auto lastSlash = path.lastIndexOfChar (separatorChar);
443 path = path.substring (0, lastSlash);
445 while (*r == separatorChar)
454 else if (secondChar == separatorChar || secondChar == 0)
456 while (*r == separatorChar)
467 path.appendCharPointer (r);
482 if (bytes == 1) { suffix =
" byte"; }
483 else if (bytes < 1024) { suffix =
" bytes"; }
484 else if (bytes < 1024 * 1024) { suffix =
" KB"; divisor = 1024.0; }
485 else if (bytes < 1024 * 1024 * 1024) { suffix =
" MB"; divisor = 1024.0 * 1024.0; }
486 else { suffix =
" GB"; divisor = 1024.0 * 1024.0 * 1024.0; }
488 return (divisor > 0 ?
String (bytes / divisor, 1) :
String (bytes)) + suffix;
499 if (parentDir == *
this)
502 auto r = parentDir.createDirectory();
520 if (parentDir == *
this)
523 auto r = parentDir.createDirectory();
569 findChildFiles (results, whatToLookFor, searchRecursively, wildcard);
579 results.
add (di.getFile());
608 bool putNumbersInBrackets)
const
615 auto prefix = suggestedPrefix;
618 if (prefix.trim().endsWithChar (
')'))
620 putNumbersInBrackets =
true;
623 auto closeBracks = prefix.lastIndexOfChar (
')');
626 && closeBracks > openBracks
627 && prefix.substring (openBracks + 1, closeBracks).containsOnly (
"0123456789"))
629 number = prefix.substring (openBracks + 1, closeBracks).getIntValue();
630 prefix = prefix.substring (0, openBracks);
636 auto newName = prefix;
638 if (putNumbersInBrackets)
640 newName <<
'(' << ++number <<
')';
652 }
while (f.exists());
665 putNumbersInBrackets);
684 auto semicolon = possibleSuffix.
text.
indexOf ((juce_wchar)
';');
692 if (possibleSuffix.
text[0] ==
'.')
695 auto dotPos = fullPath.
length() - possibleSuffix.
length() - 1;
698 return fullPath[dotPos] ==
'.';
711 auto lastDot = filePart.lastIndexOfChar (
'.');
714 filePart = filePart.substring (0, lastDot);
734 return fin.release();
741 std::unique_ptr<FileOutputStream> out (
new FileOutputStream (*
this, bufferSize));
743 return out->failedToOpen() ? nullptr
749 const size_t numberOfBytes)
const
751 jassert (((ssize_t) numberOfBytes) >= 0);
753 if (numberOfBytes == 0)
757 return out.
openedOk() && out.
write (dataToAppend, numberOfBytes);
761 const size_t numberOfBytes)
const
763 if (numberOfBytes == 0)
778 return out.
writeText (text, asUnicode, writeHeaderBytes, lineFeed);
784 tempFile.
getFile().
appendText (textToWrite, asUnicode, writeHeaderBytes, lineFeed);
797 if (in1.openedOk() && in2.
openedOk())
799 const int bufferSize = 4096;
804 auto num1 = in1.read (buffer1, bufferSize);
805 auto num2 = in2.
read (buffer2, bufferSize);
813 if (memcmp (buffer1, buffer2, (
size_t) num1) != 0)
828 if (s.isNotEmpty() && s[1] ==
':')
842 const int maxLength = 128;
847 auto lastDot = s.lastIndexOfChar (
'.');
849 if (lastDot > jmax (0, len - 12))
851 s = s.substring (0, maxLength - (len - lastDot))
852 + s.substring (lastDot);
856 s = s.substring (0, maxLength);
887 auto thisPath = fullPath;
895 int commonBitLength = 0;
896 auto thisPathAfterCommon = thisPath.getCharPointer();
897 auto dirPathAfterCommon = dirPath.getCharPointer();
900 auto thisPathIter = thisPath.getCharPointer();
901 auto dirPathIter = dirPath.getCharPointer();
905 auto c1 = thisPathIter.getAndAdvance();
906 auto c2 = dirPathIter.getAndAdvance();
908 #if NAMES_ARE_CASE_SENSITIVE
920 thisPathAfterCommon = thisPathIter;
921 dirPathAfterCommon = dirPathIter;
928 if (commonBitLength == 0 || (commonBitLength == 1 && thisPath[1] ==
getSeparatorChar()))
931 auto numUpDirectoriesNeeded = countNumberOfSeparators (dirPathAfterCommon);
933 if (numUpDirectoriesNeeded == 0)
934 return thisPathAfterCommon;
941 s.appendCharPointer (thisPathAfterCommon);
952 if (tempFile.exists())
959 const String& nativePathOfTarget,
960 bool overwriteExisting)
962 if (linkFileToCreate.
exists())
972 if (overwriteExisting)
976 #if JUCE_MAC || JUCE_LINUX
990 targetFile.
isDirectory() ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) != FALSE;
992 ignoreUnused (nativePathOfTarget);
1015 : range (0, file.getSize())
1017 openInternal (file, mode, exclusive);
1021 : range (fileRange.getIntersectionWith (
Range<int64> (0, file.getSize())))
1023 openInternal (file, mode, exclusive);
1035 :
UnitTest (
"Files", UnitTestCategories::files)
1038 void runTest()
override
1040 beginTest (
"Reading");
1045 expect (! File().exists());
1046 expect (! File().existsAsFile());
1047 expect (! File().isDirectory());
1049 expect (File(
"/").isDirectory());
1051 expect (home.isDirectory());
1052 expect (home.exists());
1053 expect (! home.existsAsFile());
1058 expect (home.getVolumeTotalSize() > 1024 * 1024);
1059 expect (home.getBytesFreeOnVolume() > 0);
1060 expect (! home.isHidden());
1061 expect (home.isOnHardDisk());
1062 expect (! home.isOnCDRomDrive());
1064 expect (home.setAsCurrentWorkingDirectory());
1070 expect (roots.size() > 0);
1072 int numRootsExisting = 0;
1073 for (
int i = 0; i < roots.size(); ++i)
1074 if (roots[i].exists())
1078 expect (numRootsExisting > 0);
1081 beginTest (
"Writing");
1083 File demoFolder (temp.getChildFile (
"JUCE UnitTests Temp Folder.folder"));
1084 expect (demoFolder.deleteRecursively());
1085 expect (demoFolder.createDirectory());
1086 expect (demoFolder.isDirectory());
1087 expect (demoFolder.getParentDirectory() == temp);
1088 expect (temp.isDirectory());
1092 File tempFile (demoFolder.getNonexistentChildFile (
"test",
".txt",
false));
1094 expect (tempFile.getFileExtension() ==
".txt");
1095 expect (tempFile.hasFileExtension (
".txt"));
1096 expect (tempFile.hasFileExtension (
"txt"));
1097 expect (tempFile.withFileExtension (
"xyz").hasFileExtension (
".xyz"));
1098 expect (tempFile.withFileExtension (
"xyz").hasFileExtension (
"abc;xyz;foo"));
1099 expect (tempFile.withFileExtension (
"xyz").hasFileExtension (
"xyz;foo"));
1100 expect (! tempFile.withFileExtension (
"h").hasFileExtension (
"bar;foo;xx"));
1101 expect (tempFile.getSiblingFile (
"foo").isAChildOf (temp));
1102 expect (tempFile.hasWriteAccess());
1104 expect (home.getChildFile (
".") == home);
1105 expect (home.getChildFile (
"..") == home.getParentDirectory());
1106 expect (home.getChildFile (
".xyz").getFileName() ==
".xyz");
1107 expect (home.getChildFile (
"..xyz").getFileName() ==
"..xyz");
1108 expect (home.getChildFile (
"...xyz").getFileName() ==
"...xyz");
1109 expect (home.getChildFile (
"./xyz") == home.getChildFile (
"xyz"));
1110 expect (home.getChildFile (
"././xyz") == home.getChildFile (
"xyz"));
1111 expect (home.getChildFile (
"../xyz") == home.getParentDirectory().getChildFile (
"xyz"));
1112 expect (home.getChildFile (
".././xyz") == home.getParentDirectory().getChildFile (
"xyz"));
1113 expect (home.getChildFile (
".././xyz/./abc") == home.getParentDirectory().getChildFile (
"xyz/abc"));
1114 expect (home.getChildFile (
"./../xyz") == home.getParentDirectory().getChildFile (
"xyz"));
1115 expect (home.getChildFile (
"a1/a2/a3/./../../a4") == home.getChildFile (
"a1/a4"));
1118 FileOutputStream fo (tempFile);
1119 fo.write (
"0123456789", 10);
1122 expect (tempFile.exists());
1123 expect (tempFile.getSize() == 10);
1125 expectEquals (tempFile.loadFileAsString(), String (
"0123456789"));
1126 expect (! demoFolder.containsSubDirectories());
1128 expectEquals (tempFile.getRelativePathFrom (demoFolder.getParentDirectory()), demoFolder.getFileName() +
File::getSeparatorString() + tempFile.getFileName());
1134 demoFolder.getNonexistentChildFile (
"tempFolder",
"",
false).createDirectory();
1137 expect (demoFolder.containsSubDirectories());
1139 expect (tempFile.hasWriteAccess());
1140 tempFile.setReadOnly (
true);
1141 expect (! tempFile.hasWriteAccess());
1142 tempFile.setReadOnly (
false);
1143 expect (tempFile.hasWriteAccess());
1146 tempFile.setLastModificationTime (t);
1147 Time t2 = tempFile.getLastModificationTime();
1148 expect (std::abs ((
int) (t2.toMilliseconds() - t.toMilliseconds())) <= 1000);
1152 tempFile.loadFileAsData (mb);
1153 expect (mb.getSize() == 10);
1154 expect (mb[0] ==
'0');
1158 expect (tempFile.getSize() == 10);
1159 FileOutputStream fo (tempFile);
1160 expect (fo.openedOk());
1162 expect (fo.setPosition (7));
1163 expect (fo.truncate().wasOk());
1164 expect (tempFile.getSize() == 7);
1165 fo.write (
"789", 3);
1167 expect (tempFile.getSize() == 10);
1170 beginTest (
"Memory-mapped files");
1174 expect (mmf.getSize() == 10);
1175 expect (mmf.getData() !=
nullptr);
1176 expect (memcmp (mmf.getData(),
"0123456789", 10) == 0);
1180 const File tempFile2 (tempFile.getNonexistentSibling (
false));
1181 expect (tempFile2.create());
1182 expect (tempFile2.appendData (
"xxxxxxxxxx", 10));
1186 expect (mmf.getSize() == 10);
1187 expect (mmf.getData() !=
nullptr);
1188 memcpy (mmf.getData(),
"abcdefghij", 10);
1193 expect (mmf.getSize() == 10);
1194 expect (mmf.getData() !=
nullptr);
1195 expect (memcmp (mmf.getData(),
"abcdefghij", 10) == 0);
1198 expect (tempFile2.deleteFile());
1201 beginTest (
"More writing");
1203 expect (tempFile.appendData (
"abcdefghij", 10));
1204 expect (tempFile.getSize() == 20);
1205 expect (tempFile.replaceWithData (
"abcdefghij", 10));
1206 expect (tempFile.getSize() == 10);
1208 File tempFile2 (tempFile.getNonexistentSibling (
false));
1209 expect (tempFile.copyFileTo (tempFile2));
1210 expect (tempFile2.exists());
1211 expect (tempFile2.hasIdenticalContentTo (tempFile));
1212 expect (tempFile.deleteFile());
1213 expect (! tempFile.exists());
1214 expect (tempFile2.moveFileTo (tempFile));
1215 expect (tempFile.exists());
1216 expect (! tempFile2.exists());
1218 expect (demoFolder.deleteRecursively());
1219 expect (! demoFolder.exists());
1222 URL url (
"https://audio.dev/foo/bar/");
1223 expectEquals (url.toString (
false), String (
"https://audio.dev/foo/bar/"));
1224 expectEquals (url.getChildURL (
"x").toString (
false), String (
"https://audio.dev/foo/bar/x"));
1225 expectEquals (url.getParentURL().toString (
false), String (
"https://audio.dev/foo"));
1226 expectEquals (url.getParentURL().getParentURL().toString (
false), String (
"https://audio.dev/"));
1227 expectEquals (url.getParentURL().getParentURL().getParentURL().toString (
false), String (
"https://audio.dev/"));
1228 expectEquals (url.getParentURL().getChildURL (
"x").toString (
false), String (
"https://audio.dev/foo/x"));
1229 expectEquals (url.getParentURL().getParentURL().getParentURL().getChildURL (
"x").toString (
false), String (
"https://audio.dev/x"));
1233 URL url (
"https://audio.dev/foo/bar");
1234 expectEquals (url.toString (
false), String (
"https://audio.dev/foo/bar"));
1235 expectEquals (url.getChildURL (
"x").toString (
false), String (
"https://audio.dev/foo/bar/x"));
1236 expectEquals (url.getParentURL().toString (
false), String (
"https://audio.dev/foo"));
1237 expectEquals (url.getParentURL().getParentURL().toString (
false), String (
"https://audio.dev/"));
1238 expectEquals (url.getParentURL().getParentURL().getParentURL().toString (
false), String (
"https://audio.dev/"));
1239 expectEquals (url.getParentURL().getChildURL (
"x").toString (
false), String (
"https://audio.dev/foo/x"));
1240 expectEquals (url.getParentURL().getParentURL().getParentURL().getChildURL (
"x").toString (
false), String (
"https://audio.dev/x"));
1245static FileTests fileUnitTests;
Holds a resizable array of primitive or copy-by-value objects.
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 ...
juce_wchar getAndAdvance() noexcept
Returns the character that this pointer is currently pointing to, and then advances the pointer to po...
int indexOf(const CharPointer stringToFind) const noexcept
Returns the character index of a substring, or -1 if it isn't found.
static juce_wchar toLowerCase(juce_wchar character) noexcept
Converts a character to lower-case.
static bool isDigit(char character) noexcept
Checks whether a character is a digit.
Searches through the files in a directory, returning each file that is found.
bool next()
Moves the iterator along to the next file.
An output stream that writes into a local file.
const Result & getStatus() const noexcept
Returns the status of the file stream.
bool write(const void *, size_t) override
Writes a block of data to the stream.
bool failedToOpen() const noexcept
Returns true if the stream couldn't be opened for some reason.
bool openedOk() const noexcept
Returns true if the stream opened without problems.
Represents a local file or directory.
bool replaceWithText(const String &textToWrite, bool asUnicode=false, bool writeUnicodeHeaderBytes=false, const char *lineEndings="\r\n") const
Replaces this file's contents with a given text string.
bool isSymbolicLink() const
Returns true if this file is a link or alias that can be followed using getLinkedTarget().
int getNumberOfChildFiles(int whatToLookFor, const String &wildCardPattern="*") const
Searches inside a directory and counts how many files match a wildcard pattern.
bool moveFileTo(const File &targetLocation) const
Moves or renames a file.
bool operator==(const File &) const
Compares the pathnames for two files.
int64 hashCode64() const
Returns a 64-bit hash-code that identifies this file.
bool containsSubDirectories() const
Returns true if this file is a directory that contains one or more subdirectories.
bool isDirectory() const
Checks whether the file is a directory that exists.
static void findFileSystemRoots(Array< File > &results)
Creates a set of files to represent each file root.
bool hasIdenticalContentTo(const File &other) const
Attempts to scan the contents of this file and compare it to another file, returning true if this is ...
FileOutputStream * createOutputStream(size_t bufferSize=0x8000) const
Creates a stream to write to this file.
static String createLegalPathName(const String &pathNameToFix)
Returns a version of a path with any illegal characters removed.
static String addTrailingSeparator(const String &path)
Adds a separator character to the end of a path if it doesn't already have one.
String getFileExtension() const
Returns the file's extension.
Time getLastModificationTime() const
Returns the last modification time of this file.
bool existsAsFile() const
Checks whether the file exists and is a file rather than a directory.
bool copyFileTo(const File &targetLocation) const
Copies a file.
int64 getSize() const
Returns the size of the file in bytes.
bool deleteRecursively(bool followSymlinks=false) const
Deletes a file or directory and all its subdirectories.
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.
const String & getFullPathName() const noexcept
Returns the complete, absolute path of this file.
String getFileName() const
Returns the last section of the pathname.
bool replaceWithData(const void *dataToWrite, size_t numberOfBytes) const
Replaces this file's contents with a given block of data.
bool setLastAccessTime(Time newTime) const
Changes the last-access time for 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 bool isAbsolutePath(StringRef path)
Returns true if the string seems to be a fully-specified absolute path.
File getSiblingFile(StringRef siblingFileName) const
Returns a file which is in the same directory as this one.
bool createSymbolicLink(const File &linkFileToCreate, bool overwriteExisting) const
Tries to create a symbolic link and returns a boolean to indicate success.
String getFileNameWithoutExtension() const
Returns the last part of the filename, without its file extension.
Array< File > findChildFiles(int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*") const
Searches this directory for files matching a wildcard pattern.
File getNonexistentSibling(bool putNumbersInBrackets=true) const
Chooses a filename for a sibling file to this one that doesn't already exist.
@ tempDirectory
The folder that should be used for temporary files.
@ currentApplicationFile
Returns this application's location.
@ invokedExecutableFile
Returns the file that was invoked to launch this executable.
@ userApplicationDataDirectory
The folder in which applications store their persistent user-specific settings.
@ currentExecutableFile
Returns this application's executable file.
@ userHomeDirectory
The user's home folder.
String getRelativePathFrom(const File &directoryToBeRelativeTo) const
Creates a relative path that refers to a file relatively to a given directory.
bool appendText(const String &textToAppend, bool asUnicode=false, bool writeUnicodeHeaderBytes=false, const char *lineEndings="\r\n") const
Appends a string to the end of the file.
int hashCode() const
Returns a 32-bit hash-code that identifies this file.
Result create() const
Creates an empty file if it doesn't already exist.
@ findDirectories
Use this flag to indicate that you want to find directories.
@ findFilesAndDirectories
Use this flag to indicate that you want to find both files and directories.
@ findFiles
Use this flag to indicate that you want to find files.
File getNonexistentChildFile(const String &prefix, const String &suffix, bool putNumbersInBrackets=true) const
Chooses a filename relative to this one that doesn't already exist.
bool operator!=(const File &) const
Compares the pathnames for two files.
bool setCreationTime(Time newTime) const
Changes the creation date for this file.
static String descriptionOfSizeInBytes(int64 bytes)
Utility function to convert a file size in bytes to a neat string description.
bool setReadOnly(bool shouldBeReadOnly, bool applyRecursively=false) const
Changes the write-permission of a file or directory.
static File createTempFile(StringRef fileNameEnding)
Returns a temporary file in the system's temp directory.
static juce_wchar getSeparatorChar()
The system-specific file separator character.
static bool areFileNamesCaseSensitive()
Indicates whether filenames are case-sensitive on the current operating system.
bool isRoot() const
Checks whether the path of this file represents the root of a file system, irrespective of its existe...
String loadFileAsString() const
Reads a file into memory as a string.
FileInputStream * createInputStream() const
Creates a stream to read from this file.
bool operator>(const File &) const
Compares the pathnames for two files.
File getLinkedTarget() const
If this file is a link or alias, this returns the file that it points to.
File getParentDirectory() const
Returns the directory that contains this file or directory.
bool appendData(const void *dataToAppend, size_t numberOfBytes) const
Appends a block of binary data to the end of the file.
bool operator<(const File &) const
Compares the pathnames for two files.
Time getCreationTime() const
Returns the time that this file was created.
bool setExecutePermission(bool shouldBeExecutable) const
Changes the execute-permissions of a file.
File withFileExtension(StringRef newExtension) const
Returns a version of this file with a different file extension.
static String createLegalFileName(const String &fileNameToFix)
Returns a version of a filename with any illegal characters removed.
File()=default
Creates an (invalid) file object.
bool deleteFile() const
Deletes a file.
bool replaceFileIn(const File &targetLocation) const
Replaces a file.
bool isAChildOf(const File &potentialParentDirectory) const
Checks whether a file is somewhere inside a directory.
static File createFileWithoutCheckingPath(const String &absolutePath) noexcept
Creates a file that simply contains this string, without doing the sanity-checking that the normal co...
bool startAsProcess(const String ¶meters=String()) const
Launches the file as a process.
String getNativeLinkedTarget() const
This returns the native path that the symbolic link points to.
bool hasFileExtension(StringRef extensionToTest) const
Checks whether the file has a given extension.
bool exists() const
Checks whether the file actually exists.
bool copyDirectoryTo(const File &newDirectory) const
Copies a directory.
bool loadFileAsData(MemoryBlock &result) const
Loads a file's contents into memory as a block of binary data.
bool setLastModificationTime(Time newTime) const
Changes the modification time for this file.
Time getLastAccessTime() const
Returns the last time this file was accessed.
Result createDirectory() const
Creates a new directory for this filename.
static File getCurrentWorkingDirectory()
Returns the current working directory.
static StringRef getSeparatorString()
The system-specific file separator character, as a string.
File & operator=(const String &newAbsolutePath)
Sets the file based on an absolute pathname.
static void JUCE_CALLTYPE writeToLog(const String &message)
Writes a string to the current logger.
A class to hold a resizable block of raw data.
MemoryMappedFile(const File &file, AccessMode mode, bool exclusive=false)
Opens a file and maps it to an area of virtual memory.
AccessMode
The read/write flags used when opening a memory mapped file.
@ 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.
virtual bool writeText(const String &text, bool asUTF16, bool writeUTF16ByteOrderMark, const char *lineEndings)
Writes a string of text to the stream.
static bool JUCE_CALLTYPE openDocument(const String &documentURL, const String ¶meters)
Tries to launch the OS's default reader application for a given file or URL.
static Random & getSystemRandom() noexcept
The overhead of creating a new Random object is fairly small, but if you want to avoid it,...
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.
static Result ok() noexcept
Creates and returns a 'successful' result.
A special array for holding a list of strings.
int addLines(StringRef stringToBreakUp)
Breaks up a string into lines and adds them to this array.
A simple class for holding temporary references to a string literal or String.
bool isNotEmpty() const noexcept
Returns true if the string is not empty.
int length() const noexcept
Returns the number of characters in the string.
String::CharPointerType text
The text that is referenced.
bool isEmpty() const noexcept
Returns true if the string is empty.
static String repeatedString(StringRef stringToRepeat, int numberOfTimesToRepeat)
Creates a string which is a version of a string repeated and joined together.
int indexOfChar(juce_wchar characterToLookFor) const noexcept
Searches for a character inside this string.
String upToFirstOccurrenceOf(StringRef substringToEndWith, bool includeSubStringInResult, bool ignoreCase) const
Returns the start of this string, up to the first occurrence of a substring.
int length() const noexcept
Returns the number of characters in the string.
bool endsWithChar(juce_wchar character) const noexcept
Tests whether the string ends with a particular character.
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.
int64 hashCode64() const noexcept
Generates a probably-unique 64-bit hashcode from this string.
bool containsChar(juce_wchar character) const noexcept
Tests whether the string contains a particular character.
String removeCharacters(StringRef charactersToRemove) const
Returns a version of this string with a set of characters removed.
bool endsWithIgnoreCase(StringRef text) const noexcept
Tests whether the string ends with another string.
String dropLastCharacters(int numberToDrop) const
Returns a version of this string with a number of characters removed from the end.
String trimEnd() const
Returns a copy of this string with any whitespace characters removed from the end.
static String toHexString(IntegerType number)
Returns a string representing this numeric value in hexadecimal.
int lastIndexOfChar(juce_wchar character) const noexcept
Searches for a character inside this string (working backwards from the end of the string).
const wchar_t * toWideCharPointer() const
Returns a pointer to a wchar_t version of this string.
String trimCharactersAtEnd(StringRef charactersToTrim) const
Returns a copy of this string, having removed a specified set of characters from its end.
String replaceCharacter(juce_wchar characterToReplace, juce_wchar characterToInsertInstead) const
Returns a string with all occurrences of a character replaced with a different one.
String substring(int startIndex, int endIndex) const
Returns a subsection of the string.
int hashCode() const noexcept
Generates a probably-unique 32-bit hashcode from this string.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
String fromFirstOccurrenceOf(StringRef substringToStartFrom, bool includeSubStringInResult, bool ignoreCase) const
Returns a section of the string starting from a given substring.
Manages a temporary file, which will be deleted when this object is deleted.
@ useHiddenFile
Indicates that the temporary file should be hidden - i.e.
bool overwriteTargetFileWithTemporary() const
Tries to move the temporary file to overwrite the target file that was specified in the constructor.
const File & getFile() const noexcept
Returns the temporary file.
Holds an absolute date and time.
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Returns a Time object that is set to the current system time.
int64 toMilliseconds() const noexcept
Returns the time as a number of milliseconds.
This is a base class for classes that perform a unit test.