The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. //==============================================================================
  19. namespace FileHelpers
  20. {
  21. int64 calculateStreamHashCode (InputStream& stream);
  22. int64 calculateFileHashCode (const File& file);
  23. bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, size_t numBytes);
  24. bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData);
  25. bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData);
  26. bool containsAnyNonHiddenFiles (const File& folder);
  27. String unixStylePath (const String& path);
  28. String windowsStylePath (const String& path);
  29. String currentOSStylePath (const String& path);
  30. bool shouldPathsBeRelative (String path1, String path2);
  31. bool isAbsolutePath (const String& path);
  32. // A windows-aware version of File::getRelativePath()
  33. String getRelativePathFrom (const File& file, const File& sourceFolder);
  34. // removes "/../" bits from the middle of the path
  35. String simplifyPath (String::CharPointerType path);
  36. String simplifyPath (const String& path);
  37. }
  38. //==============================================================================
  39. const char* const sourceFileExtensions = "cpp;mm;m;c;cc;cxx;swift;s;asm;r";
  40. const char* const headerFileExtensions = "h;hpp;hxx;hh;inl";
  41. const char* const cOrCppFileExtensions = "cpp;cc;cxx;c";
  42. const char* const cppFileExtensions = "cpp;cc;cxx";
  43. const char* const objCFileExtensions = "mm;m";
  44. const char* const asmFileExtensions = "s;S;asm";
  45. const char* const sourceOrHeaderFileExtensions = "cpp;mm;m;c;cc;cxx;swift;s;S;asm;h;hpp;hxx;hh;inl";
  46. const char* const browseableFileExtensions = "cpp;mm;m;c;cc;cxx;swift;s;S;asm;h;hpp;hxx;hh;inl;txt;md;rtf";
  47. const char* const fileTypesToCompileByDefault = "cpp;mm;c;m;cc;cxx;swift;s;S;asm;r";
  48. //==============================================================================
  49. struct FileModificationDetector
  50. {
  51. FileModificationDetector (const File& f) : file (f) {}
  52. const File& getFile() const { return file; }
  53. void fileHasBeenRenamed (const File& newFile) { file = newFile; }
  54. bool hasBeenModified() const
  55. {
  56. return fileModificationTime != file.getLastModificationTime()
  57. && (fileSize != file.getSize()
  58. || FileHelpers::calculateFileHashCode (file) != fileHashCode);
  59. }
  60. void updateHash()
  61. {
  62. fileModificationTime = file.getLastModificationTime();
  63. fileSize = file.getSize();
  64. fileHashCode = FileHelpers::calculateFileHashCode (file);
  65. }
  66. private:
  67. File file;
  68. Time fileModificationTime;
  69. int64 fileHashCode, fileSize;
  70. };