Add remaining files
[juce-lv2.git] / juce / source / extras / Introjucer / Source / Utility / jucer_FileHelpers.h
blob6baa12f3c1c50cddb13d5c3da07e52240e1cb0b3
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-10 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_FILEUTILITIES_H_EEE25EE3__
27 #define __JUCER_FILEUTILITIES_H_EEE25EE3__
30 //==============================================================================
31 namespace FileHelpers
33 int64 calculateStreamHashCode (InputStream& stream);
34 int64 calculateFileHashCode (const File& file);
36 bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes);
37 bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData);
38 bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData);
40 bool containsAnyNonHiddenFiles (const File& folder);
42 const String unixStylePath (const String& path);
43 const String windowsStylePath (const String& path);
45 bool shouldPathsBeRelative (String path1, String path2);
47 //==============================================================================
48 bool isJuceFolder (const File& folder);
49 const File findParentJuceFolder (const File& file);
50 const File findDefaultJuceFolder();
53 //==============================================================================
54 class FileModificationDetector
56 public:
57 FileModificationDetector (const File& file_)
58 : file (file_)
62 const File& getFile() const { return file; }
63 void fileHasBeenRenamed (const File& newFile) { file = newFile; }
65 bool hasBeenModified() const
67 return fileModificationTime != file.getLastModificationTime()
68 && (fileSize != file.getSize()
69 || FileHelpers::calculateFileHashCode (file) != fileHashCode);
72 void updateHash()
74 fileModificationTime = file.getLastModificationTime();
75 fileSize = file.getSize();
76 fileHashCode = FileHelpers::calculateFileHashCode (file);
79 private:
80 File file;
81 Time fileModificationTime;
82 int64 fileHashCode, fileSize;
86 #endif // __JUCER_FILEUTILITIES_H_EEE25EE3__