1 /* 2 ============================================================================== 3 4 This file is part of the JUCE library. 5 Copyright (c) 2020 - Raw Material Software Limited 6 7 JUCE is an open source library subject to commercial or open-source 8 licensing. 9 10 By using JUCE, you agree to the terms of both the JUCE 6 End-User License 11 Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). 12 13 End User License Agreement: www.juce.com/juce-6-licence 14 Privacy Policy: www.juce.com/juce-privacy-policy 15 16 Or: You may also use this code under the terms of the GPL v3 (see 17 www.gnu.org/licenses). 18 19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER 20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE 21 DISCLAIMED. 22 23 ============================================================================== 24 */ 25 26 #pragma once 27 28 29 //============================================================================== 30 namespace FileHelpers 31 { 32 bool containsAnyNonHiddenFiles (const File& folder); 33 34 bool shouldPathsBeRelative (String path1, String path2); 35 36 // removes "/../" bits from the middle of the path 37 String simplifyPath (String::CharPointerType path); 38 String simplifyPath (const String& path); 39 } 40 41 //============================================================================== 42 const char* const sourceFileExtensions = "cpp;mm;m;metal;c;cc;cxx;swift;s;asm;r"; 43 const char* const headerFileExtensions = "h;hpp;hxx;hh;inl"; 44 const char* const cOrCppFileExtensions = "cpp;cc;cxx;c"; 45 const char* const cppFileExtensions = "cpp;cc;cxx"; 46 const char* const objCFileExtensions = "mm;m"; 47 const char* const asmFileExtensions = "s;S;asm"; 48 const char* const sourceOrHeaderFileExtensions = "cpp;mm;m;metal;c;cc;cxx;swift;s;S;asm;h;hpp;hxx;hh;inl"; 49 const char* const browseableFileExtensions = "cpp;mm;m;metal;c;cc;cxx;swift;s;S;asm;h;hpp;hxx;hh;inl;txt;md;rtf"; 50 const char* const fileTypesToCompileByDefault = "cpp;mm;m;metal;c;cc;cxx;swift;s;S;asm;r"; 51 52 //============================================================================== 53 struct FileModificationDetector 54 { FileModificationDetectorFileModificationDetector55 FileModificationDetector (const File& f) : file (f) {} 56 getFileFileModificationDetector57 const File& getFile() const { return file; } fileHasBeenRenamedFileModificationDetector58 void fileHasBeenRenamed (const File& newFile) { file = newFile; } 59 hasBeenModifiedFileModificationDetector60 bool hasBeenModified() const 61 { 62 return fileModificationTime != file.getLastModificationTime() 63 && (fileSize != file.getSize() 64 || build_tools::calculateFileHashCode (file) != fileHashCode); 65 } 66 updateHashFileModificationDetector67 void updateHash() 68 { 69 fileModificationTime = file.getLastModificationTime(); 70 fileSize = file.getSize(); 71 fileHashCode = build_tools::calculateFileHashCode (file); 72 } 73 74 private: 75 File file; 76 Time fileModificationTime; 77 uint64 fileHashCode = 0; 78 int64 fileSize = -1; 79 }; 80