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.

88 lines
3.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_FILEHELPERS_JUCEHEADER__
  19. #define __JUCER_FILEHELPERS_JUCEHEADER__
  20. //==============================================================================
  21. namespace FileHelpers
  22. {
  23. int64 calculateStreamHashCode (InputStream& stream);
  24. int64 calculateFileHashCode (const File& file);
  25. bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes);
  26. bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData);
  27. bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData);
  28. bool containsAnyNonHiddenFiles (const File& folder);
  29. String unixStylePath (const String& path);
  30. String windowsStylePath (const String& path);
  31. bool shouldPathsBeRelative (String path1, String path2);
  32. //==============================================================================
  33. bool isJuceFolder (const File& folder);
  34. bool isModulesFolder (const File& folder);
  35. File findParentJuceFolder (const File& file);
  36. File lookInFolderForJuceFolder (const File& folder);
  37. }
  38. //==============================================================================
  39. class FileModificationDetector
  40. {
  41. public:
  42. FileModificationDetector (const File& file_)
  43. : file (file_)
  44. {
  45. }
  46. const File& getFile() const { return file; }
  47. void fileHasBeenRenamed (const File& newFile) { file = newFile; }
  48. bool hasBeenModified() const
  49. {
  50. return fileModificationTime != file.getLastModificationTime()
  51. && (fileSize != file.getSize()
  52. || FileHelpers::calculateFileHashCode (file) != fileHashCode);
  53. }
  54. void updateHash()
  55. {
  56. fileModificationTime = file.getLastModificationTime();
  57. fileSize = file.getSize();
  58. fileHashCode = FileHelpers::calculateFileHashCode (file);
  59. }
  60. private:
  61. File file;
  62. Time fileModificationTime;
  63. int64 fileHashCode, fileSize;
  64. };
  65. #endif // __JUCER_FILEHELPERS_JUCEHEADER__