| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | |
| 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * | |
| 9 * 1. Redistributions of source code must retain the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer. | |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | |
| 12 * notice, this list of conditions and the following disclaimer in the | |
| 13 * documentation and/or other materials provided with the distribution. | |
| 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
| 15 * its contributors may be used to endorse or promote products derived | |
| 16 * from this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
| 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 */ | |
| 29 | |
| 30 #ifndef FileSystem_h | |
| 31 #define FileSystem_h | |
| 32 | |
| 33 #if PLATFORM(GTK) | |
| 34 #include <gmodule.h> | |
| 35 #endif | |
| 36 #if PLATFORM(QT) | |
| 37 #include <QFile> | |
| 38 #include <QLibrary> | |
| 39 #if defined(Q_OS_WIN32) | |
| 40 #include <windows.h> | |
| 41 #endif | |
| 42 #endif | |
| 43 | |
| 44 #include <time.h> | |
| 45 | |
| 46 #include <wtf/Platform.h> | |
| 47 #include <wtf/Vector.h> | |
| 48 | |
| 49 #include "PlatformString.h" | |
| 50 | |
| 51 typedef const struct __CFData* CFDataRef; | |
| 52 | |
| 53 #if PLATFORM(WIN) | |
| 54 // These are to avoid including <winbase.h> in a header for Chromium | |
| 55 typedef void *HANDLE; | |
| 56 // Assuming STRICT | |
| 57 typedef struct HINSTANCE__* HINSTANCE; | |
| 58 typedef HINSTANCE HMODULE; | |
| 59 #endif | |
| 60 | |
| 61 namespace WebCore { | |
| 62 | |
| 63 class CString; | |
| 64 | |
| 65 #if PLATFORM(WIN) | |
| 66 typedef HANDLE PlatformFileHandle; | |
| 67 typedef HMODULE PlatformModule; | |
| 68 // HACK: -1 is INVALID_HANDLE_VALUE, defined in <winbase.h>. Chromium tries to | |
| 69 // avoid using Windows headers in headers. We'd rather move this into the .cpp. | |
| 70 const PlatformFileHandle invalidPlatformFileHandle = (HANDLE)-1; | |
| 71 | |
| 72 struct PlatformModuleVersion { | |
| 73 unsigned leastSig; | |
| 74 unsigned mostSig; | |
| 75 | |
| 76 PlatformModuleVersion(unsigned) | |
| 77 : leastSig(0) | |
| 78 , mostSig(0) | |
| 79 { | |
| 80 } | |
| 81 | |
| 82 PlatformModuleVersion(unsigned lsb, unsigned msb) | |
| 83 : leastSig(lsb) | |
| 84 , mostSig(msb) | |
| 85 { | |
| 86 } | |
| 87 | |
| 88 }; | |
| 89 #elif PLATFORM(QT) | |
| 90 | |
| 91 typedef QFile* PlatformFileHandle; | |
| 92 const PlatformFileHandle invalidPlatformFileHandle = 0; | |
| 93 #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) | |
| 94 typedef QLibrary* PlatformModule; | |
| 95 typedef unsigned PlatformModuleVersion; | |
| 96 #elif defined(Q_OS_WIN32) | |
| 97 typedef HMODULE PlatformModule; | |
| 98 struct PlatformModuleVersion { | |
| 99 unsigned leastSig; | |
| 100 unsigned mostSig; | |
| 101 | |
| 102 PlatformModuleVersion(unsigned) | |
| 103 : leastSig(0) | |
| 104 , mostSig(0) | |
| 105 { | |
| 106 } | |
| 107 | |
| 108 PlatformModuleVersion(unsigned lsb, unsigned msb) | |
| 109 : leastSig(lsb) | |
| 110 , mostSig(msb) | |
| 111 { | |
| 112 } | |
| 113 | |
| 114 }; | |
| 115 #endif | |
| 116 | |
| 117 #else | |
| 118 typedef int PlatformFileHandle; | |
| 119 #if PLATFORM(GTK) | |
| 120 typedef GModule* PlatformModule; | |
| 121 #else | |
| 122 typedef void* PlatformModule; | |
| 123 #endif | |
| 124 const PlatformFileHandle invalidPlatformFileHandle = -1; | |
| 125 | |
| 126 typedef unsigned PlatformModuleVersion; | |
| 127 #endif | |
| 128 | |
| 129 bool fileExists(const String&); | |
| 130 bool deleteFile(const String&); | |
| 131 bool deleteEmptyDirectory(const String&); | |
| 132 bool getFileSize(const String&, long long& result); | |
| 133 bool getFileModificationTime(const String&, time_t& result); | |
| 134 String pathByAppendingComponent(const String& path, const String& component); | |
| 135 bool makeAllDirectories(const String& path); | |
| 136 String homeDirectoryPath(); | |
| 137 String pathGetFileName(const String&); | |
| 138 String directoryName(const String&); | |
| 139 | |
| 140 Vector<String> listDirectory(const String& path, const String& filter = String()
); | |
| 141 | |
| 142 CString fileSystemRepresentation(const String&); | |
| 143 | |
| 144 inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != i
nvalidPlatformFileHandle; } | |
| 145 | |
| 146 // Prefix is what the filename should be prefixed with, not the full path. | |
| 147 CString openTemporaryFile(const char* prefix, PlatformFileHandle&); | |
| 148 void closeFile(PlatformFileHandle&); | |
| 149 int writeToFile(PlatformFileHandle, const char* data, int length); | |
| 150 | |
| 151 // Methods for dealing with loadable modules | |
| 152 bool unloadModule(PlatformModule); | |
| 153 | |
| 154 #if PLATFORM(WIN) | |
| 155 String localUserSpecificStorageDirectory(); | |
| 156 String roamingUserSpecificStorageDirectory(); | |
| 157 | |
| 158 bool safeCreateFile(const String&, CFDataRef); | |
| 159 #endif | |
| 160 | |
| 161 } // namespace WebCore | |
| 162 | |
| 163 #endif // FileSystem_h | |
| OLD | NEW |