openshot-audio  0.1.2
juce_File.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_FILE_H_INCLUDED
30 #define JUCE_FILE_H_INCLUDED
31 
32 
33 //==============================================================================
46 {
47 public:
48  //==============================================================================
58 
69  File (const String& absolutePath);
70 
72  File (const File&);
73 
76 
87  File& operator= (const String& newAbsolutePath);
88 
90  File& operator= (const File& otherFile);
91 
92  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
93  File (File&&) noexcept;
94  File& operator= (File&&) noexcept;
95  #endif
96 
97  //==============================================================================
99  static const File nonexistent;
100 
101  //==============================================================================
107  bool exists() const;
108 
115  bool existsAsFile() const;
116 
123  bool isDirectory() const;
124 
129  int64 getSize() const;
130 
136  static String descriptionOfSizeInBytes (int64 bytes);
137 
138  //==============================================================================
150  const String& getFullPathName() const noexcept { return fullPath; }
151 
165  String getFileName() const;
166 
182  String getRelativePathFrom (const File& directoryToBeRelativeTo) const;
183 
184  //==============================================================================
193  String getFileExtension() const;
194 
206  bool hasFileExtension (StringRef extensionToTest) const;
207 
218  File withFileExtension (StringRef newExtension) const;
219 
226  String getFileNameWithoutExtension() const;
227 
228  //==============================================================================
234  int hashCode() const;
235 
241  int64 hashCode64() const;
242 
243  //==============================================================================
258  File getChildFile (StringRef relativeOrAbsolutePath) const;
259 
266  File getSiblingFile (StringRef siblingFileName) const;
267 
268  //==============================================================================
273  File getParentDirectory() const;
274 
284  bool isAChildOf (const File& potentialParentDirectory) const;
285 
286  //==============================================================================
304  File getNonexistentChildFile (const String& prefix,
305  const String& suffix,
306  bool putNumbersInBrackets = true) const;
307 
317  File getNonexistentSibling (bool putNumbersInBrackets = true) const;
318 
319  //==============================================================================
321  bool operator== (const File&) const;
323  bool operator!= (const File&) const;
325  bool operator< (const File&) const;
327  bool operator> (const File&) const;
328 
329  //==============================================================================
337  bool hasWriteAccess() const;
338 
348  bool setReadOnly (bool shouldBeReadOnly,
349  bool applyRecursively = false) const;
350 
356  bool setExecutePermission (bool shouldBeExecutable) const;
357 
361  bool isHidden() const;
362 
364  bool isLink() const;
365 
369  File getLinkedTarget() const;
370 
377  uint64 getFileIdentifier() const;
378 
379  //==============================================================================
385  Time getLastModificationTime() const;
386 
392  Time getLastAccessTime() const;
393 
399  Time getCreationTime() const;
400 
407  bool setLastModificationTime (Time newTime) const;
408 
415  bool setLastAccessTime (Time newTime) const;
416 
423  bool setCreationTime (Time newTime) const;
424 
431  String getVersion() const;
432 
433  //==============================================================================
444  Result create() const;
445 
455  Result createDirectory() const;
456 
466  bool deleteFile() const;
467 
477  bool deleteRecursively() const;
478 
485  bool moveToTrash() const;
486 
501  bool moveFileTo (const File& targetLocation) const;
502 
511  bool copyFileTo (const File& targetLocation) const;
512 
526  bool copyDirectoryTo (const File& newDirectory) const;
527 
528  //==============================================================================
532  {
533  findDirectories = 1,
534  findFiles = 2,
535  findFilesAndDirectories = 3,
536  ignoreHiddenFiles = 4
537  };
538 
556  int findChildFiles (Array<File>& results,
557  int whatToLookFor,
558  bool searchRecursively,
559  const String& wildCardPattern = "*") const;
560 
577  int getNumberOfChildFiles (int whatToLookFor,
578  const String& wildCardPattern = "*") const;
579 
583  bool containsSubDirectories() const;
584 
585  //==============================================================================
592  FileInputStream* createInputStream() const;
593 
604  FileOutputStream* createOutputStream (size_t bufferSize = 0x8000) const;
605 
606  //==============================================================================
617  bool loadFileAsData (MemoryBlock& result) const;
618 
626  String loadFileAsString() const;
627 
631  void readLines (StringArray& destLines) const;
632 
633  //==============================================================================
640  bool appendData (const void* dataToAppend,
641  size_t numberOfBytes) const;
642 
657  bool replaceWithData (const void* dataToWrite,
658  size_t numberOfBytes) const;
659 
672  bool appendText (const String& textToAppend,
673  bool asUnicode = false,
674  bool writeUnicodeHeaderBytes = false) const;
675 
692  bool replaceWithText (const String& textToWrite,
693  bool asUnicode = false,
694  bool writeUnicodeHeaderBytes = false) const;
695 
699  bool hasIdenticalContentTo (const File& other) const;
700 
701  //==============================================================================
708  static void findFileSystemRoots (Array<File>& results);
709 
713  String getVolumeLabel() const;
714 
718  int getVolumeSerialNumber() const;
719 
725  int64 getBytesFreeOnVolume() const;
726 
732  int64 getVolumeTotalSize() const;
733 
735  bool isOnCDRomDrive() const;
736 
742  bool isOnHardDisk() const;
743 
748  bool isOnRemovableDrive() const;
749 
750  //==============================================================================
762  bool startAsProcess (const String& parameters = String()) const;
763 
767  void revealToUser() const;
768 
769  //==============================================================================
773  {
776 
782 
785 
788 
791 
794 
801 
811 
818 
823 
836 
846 
853 
856 
857  #if JUCE_WINDOWS
858 
859  windowsSystemDirectory,
860  #endif
861 
866  globalApplicationsDirectory
867  };
868 
874  static File JUCE_CALLTYPE getSpecialLocation (const SpecialLocationType type);
875 
876  //==============================================================================
881  static File createTempFile (StringRef fileNameEnding);
882 
883 
884  //==============================================================================
888  static File getCurrentWorkingDirectory();
889 
897  bool setAsCurrentWorkingDirectory() const;
898 
899  //==============================================================================
903  static const juce_wchar separator;
904 
908  static const String separatorString;
909 
910  //==============================================================================
922  static String createLegalFileName (const String& fileNameToFix);
923 
931  static String createLegalPathName (const String& pathNameToFix);
932 
934  static bool areFileNamesCaseSensitive();
935 
937  static bool isAbsolutePath (StringRef path);
938 
944  static File createFileWithoutCheckingPath (const String& absolutePath) noexcept;
945 
947  static String addTrailingSeparator (const String& path);
948 
949  #if JUCE_MAC || JUCE_IOS || DOXYGEN
950  //==============================================================================
952  OSType getMacOSType() const;
953 
955  bool isBundle() const;
956  #endif
957 
958  #if JUCE_MAC || DOXYGEN
959 
960  void addToDock() const;
961  #endif
962 
963  #if JUCE_WINDOWS
964 
965  bool createLink (const String& description, const File& linkFileToCreate) const;
966  #endif
967 
968 private:
969  //==============================================================================
970  String fullPath;
971 
972  static String parseAbsolutePath (const String&);
973  String getPathUpToLastSlash() const;
974 
975  Result createDirectoryInternal (const String&) const;
976  bool copyInternal (const File&) const;
977  bool moveInternal (const File&) const;
978  bool setFileTimesInternal (int64 m, int64 a, int64 c) const;
979  void getFileTimesInternal (int64& m, int64& a, int64& c) const;
980  bool setFileReadOnlyInternal (bool) const;
981  bool setFileExecutableInternal (bool) const;
982 };
983 
984 #endif // JUCE_FILE_H_INCLUDED
Definition: juce_File.h:852
SpecialLocationType
Definition: juce_File.h:772
File() noexcept
Definition: juce_File.h:57
#define noexcept
Definition: juce_CompilerSupport.h:141
JUCE_API bool JUCE_CALLTYPE operator>(const String &s1, const String &s2) noexcept
Definition: juce_core.cpp:589
Definition: juce_File.h:793
Definition: juce_Time.h:41
Definition: juce_File.h:784
Definition: juce_MemoryBlock.h:38
#define JUCE_CALLTYPE
Definition: juce_PlatformDefs.h:50
Definition: juce_File.h:817
Definition: juce_String.h:43
Definition: juce_Result.h:61
static const String separatorString
Definition: juce_File.h:908
Definition: juce_FileOutputStream.h:39
Definition: juce_File.h:781
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
Definition: juce_File.h:775
Definition: juce_File.h:787
unsigned long long uint64
Definition: juce_MathsFunctions.h:62
static const File nonexistent
Definition: juce_File.h:99
Definition: juce_File.h:810
static const juce_wchar separator
Definition: juce_File.h:903
Definition: juce_File.h:855
Definition: juce_File.h:800
long long int64
Definition: juce_MathsFunctions.h:60
Definition: juce_FileInputStream.h:39
JUCE_API bool JUCE_CALLTYPE operator<(const String &s1, const String &s2) noexcept
Definition: juce_core.cpp:590
Definition: juce_StringArray.h:39
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
~File() noexcept
Definition: juce_File.h:75
Definition: juce_File.h:790
Definition: juce_File.h:822
Definition: juce_File.h:835
TypesOfFileToFind
Definition: juce_File.h:531
const String & getFullPathName() const noexcept
Definition: juce_File.h:150
Definition: juce_File.h:845
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
Definition: juce_File.h:45
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49
Definition: juce_StringRef.h:65