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.

87 lines
3.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 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_FILEUTILITIES_H_EEE25EE3__
  19. #define __JUCER_FILEUTILITIES_H_EEE25EE3__
  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. const String unixStylePath (const String& path);
  30. const String windowsStylePath (const String& path);
  31. bool shouldPathsBeRelative (String path1, String path2);
  32. //==============================================================================
  33. bool isJuceFolder (const File& folder);
  34. const File findParentJuceFolder (const File& file);
  35. const File findDefaultJuceFolder();
  36. }
  37. //==============================================================================
  38. class FileModificationDetector
  39. {
  40. public:
  41. FileModificationDetector (const File& file_)
  42. : file (file_)
  43. {
  44. }
  45. const File& getFile() const { return file; }
  46. void fileHasBeenRenamed (const File& newFile) { file = newFile; }
  47. bool hasBeenModified() const
  48. {
  49. return fileModificationTime != file.getLastModificationTime()
  50. && (fileSize != file.getSize()
  51. || FileHelpers::calculateFileHashCode (file) != fileHashCode);
  52. }
  53. void updateHash()
  54. {
  55. fileModificationTime = file.getLastModificationTime();
  56. fileSize = file.getSize();
  57. fileHashCode = FileHelpers::calculateFileHashCode (file);
  58. }
  59. private:
  60. File file;
  61. Time fileModificationTime;
  62. int64 fileHashCode, fileSize;
  63. };
  64. #endif // __JUCER_FILEUTILITIES_H_EEE25EE3__