85 File& operator= (
const String& newAbsolutePath);
88 File& operator= (
const File& otherFile);
110 bool existsAsFile() const;
118 bool isDirectory() const;
132 int64 getSize() const;
139 static
String descriptionOfSizeInBytes (int64 bytes);
153 const
String& getFullPathName() const noexcept {
return fullPath; }
168 String getFileName()
const;
185 String getRelativePathFrom (
const File& directoryToBeRelativeTo)
const;
196 String getFileExtension()
const;
209 bool hasFileExtension (
StringRef extensionToTest)
const;
229 String getFileNameWithoutExtension()
const;
237 int hashCode()
const;
244 int64 hashCode64()
const;
279 File getParentDirectory()
const;
290 bool isAChildOf (
const File& potentialParentDirectory)
const;
310 File getNonexistentChildFile (
const String& prefix,
312 bool putNumbersInBrackets =
true)
const;
323 File getNonexistentSibling (
bool putNumbersInBrackets =
true)
const;
327 bool operator== (
const File&)
const;
329 bool operator!= (
const File&)
const;
331 bool operator< (
const File&)
const;
333 bool operator> (
const File&)
const;
354 bool setReadOnly (
bool shouldBeReadOnly,
355 bool applyRecursively =
false)
const;
362 bool setExecutePermission (
bool shouldBeExecutable)
const;
383 Time getLastModificationTime()
const;
390 Time getLastAccessTime()
const;
397 Time getCreationTime()
const;
405 bool setLastModificationTime (
Time newTime)
const;
413 bool setLastAccessTime (
Time newTime)
const;
421 bool setCreationTime (
Time newTime)
const;
457 Result createDirectory()
const;
485 bool deleteRecursively (
bool followSymlinks =
false)
const;
509 bool moveFileTo (
const File& targetLocation)
const;
519 bool copyFileTo (
const File& targetLocation)
const;
531 bool replaceFileIn (
const File& targetLocation)
const;
546 bool copyDirectoryTo (
const File& newDirectory)
const;
555 findFilesAndDirectories = 3,
556 ignoreHiddenFiles = 4
576 bool searchRecursively,
577 const String& wildCardPattern =
"*")
const;
584 int findChildFiles (
Array<File>& results,
int whatToLookFor,
585 bool searchRecursively,
const String& wildCardPattern =
"*")
const;
603 int getNumberOfChildFiles (
int whatToLookFor,
604 const String& wildCardPattern =
"*")
const;
609 bool containsSubDirectories()
const;
684 String loadFileAsString()
const;
698 bool appendData (
const void* dataToAppend,
699 size_t numberOfBytes)
const;
715 bool replaceWithData (
const void* dataToWrite,
716 size_t numberOfBytes)
const;
731 bool appendText (
const String& textToAppend,
732 bool asUnicode =
false,
733 bool writeUnicodeHeaderBytes =
false,
734 const char* lineEndings =
"\r\n")
const;
752 bool replaceWithText (
const String& textToWrite,
753 bool asUnicode =
false,
754 bool writeUnicodeHeaderBytes =
false,
755 const char* lineEndings =
"\r\n")
const;
760 bool hasIdenticalContentTo (
const File& other)
const;
823 bool startAsProcess (
const String& parameters =
String())
const;
921 #if JUCE_WINDOWS || DOXYGEN
932 #if JUCE_WINDOWS || DOXYGEN
940 globalApplicationsDirectoryX86
996 static String createLegalFileName (
const String& fileNameToFix);
1005 static String createLegalPathName (
const String& pathNameToFix);
1008 static bool areFileNamesCaseSensitive();
1011 static bool isAbsolutePath (
StringRef path);
1018 static File createFileWithoutCheckingPath (
const String& absolutePath) noexcept;
1021 static String addTrailingSeparator (
const String& path);
1025 bool createSymbolicLink (
const File& linkFileToCreate,
bool overwriteExisting)
const;
1033 File getLinkedTarget()
const;
1040 static bool createSymbolicLink (
const File& linkFileToCreate,
1041 const String& nativePathOfTarget,
1042 bool overwriteExisting);
1048 #if JUCE_WINDOWS || DOXYGEN
1059 #if JUCE_MAC || JUCE_IOS || DOXYGEN
1067 #if JUCE_MAC || DOXYGEN
1076 NaturalFileComparator (
bool shouldPutFoldersFirst) noexcept : foldersFirst (shouldPutFoldersFirst) {}
1078 int compareElements (
const File& firstFile,
const File& secondFile)
const
1083 #if NAMES_ARE_CASE_SENSITIVE
1098 JUCE_DEPRECATED_STATIC (
static const juce_wchar separator;)
1099 JUCE_DEPRECATED_STATIC (
static const StringRef separatorString;)
1100 JUCE_DEPRECATED_STATIC (
static const File nonexistent;)
1107 String getPathUpToLastSlash()
const;
1110 bool copyInternal (
const File&)
const;
1111 bool moveInternal (
const File&)
const;
1112 bool replaceInternal (
const File&)
const;
1113 bool setFileTimesInternal (int64 m, int64 a, int64 c)
const;
1114 void getFileTimesInternal (int64& m, int64& a, int64& c)
const;
1115 bool setFileReadOnlyInternal (
bool)
const;
1116 bool setFileExecutableInternal (
bool)
const;
Holds a resizable array of primitive or copy-by-value objects.
An output stream that writes into a local file.
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 isHidden() const
Returns true if this file is a hidden or system file.
bool isOnHardDisk() const
Returns true if this file is on a hard disk.
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 setAsCurrentWorkingDirectory() const
Sets the current working directory to be this file.
bool isOnCDRomDrive() const
Returns true if this file is on a CD or DVD drive.
bool isOnRemovableDrive() const
Returns true if this file is on a removable disk drive.
OSType getMacOSType() const
OSX ONLY - Finds the OSType of a file from the its resources.
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.
const String & getFullPathName() const noexcept
Returns the complete, absolute path of this file.
bool hasWriteAccess() const
Checks whether a file can be created or written to.
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.
~File()=default
Destructor.
void revealToUser() const
Opens Finder, Explorer, or whatever the OS uses, to show the user this file's location.
SpecialLocationType
A set of types of location that can be passed to the getSpecialLocation() method.
@ userMoviesDirectory
The most likely place where a user might store their movie files.
@ userMusicDirectory
The most likely place where a user might store their music files.
@ tempDirectory
The folder that should be used for temporary files.
@ globalApplicationsDirectory
The directory in which applications normally get installed.
@ userDocumentsDirectory
The user's default documents folder.
@ currentApplicationFile
Returns this application's location.
@ invokedExecutableFile
Returns the file that was invoked to launch this executable.
@ commonDocumentsDirectory
A place to put documents which are shared by all users of the machine.
@ userApplicationDataDirectory
The folder in which applications store their persistent user-specific settings.
@ userPicturesDirectory
The most likely place where a user might store their picture files.
@ commonApplicationDataDirectory
An equivalent of the userApplicationDataDirectory folder that is shared by all users of the computer,...
@ windowsSystemDirectory
On a Windows machine, returns the location of the Windows/System32 folder.
@ userDesktopDirectory
The folder that contains the user's desktop objects.
@ hostApplicationPath
In a plugin, this will return the path of the host executable.
@ currentExecutableFile
Returns this application's executable file.
@ userHomeDirectory
The user's home folder.
TypesOfFileToFind
Used in file searching, to specify whether to return files, directories, or both.
bool isShortcut() const
Windows ONLY - Returns true if this is a win32 .LNK file.
static juce_wchar getSeparatorChar()
The system-specific file separator character.
void addToDock() const
OSX ONLY - Adds this file to the OSX dock.
bool isBundle() const
OSX ONLY - Returns true if this file is actually a bundle.
bool moveToTrash() const
Moves this file or folder to the trash.
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.
File()=default
Creates an (invalid) file object.
bool deleteFile() const
Deletes a file.
String getVersion() const
If possible, this will try to create a version string for the given file.
String getNativeLinkedTarget() const
This returns the native path that the symbolic link points to.
bool createShortcut(const String &description, const File &linkFileToCreate) const
Windows ONLY - Creates a win32 .LNK shortcut file that links to this file.
static File getCurrentWorkingDirectory()
Returns the current working directory.
static StringRef getSeparatorString()
The system-specific file separator character, as a string.
A class to hold a resizable block of raw data.
Represents the 'success' or 'failure' of an operation, and holds an associated error message to descr...
A special array for holding a list of strings.
A simple class for holding temporary references to a string literal or String.
int compareNatural(StringRef other, bool isCaseSensitive=false) const noexcept
Compares two strings, taking into account textual characteristics like numbers and spaces.
Holds an absolute date and time.
#define JUCE_API
This macro is added to all JUCE public class declarations.