2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
39 #if defined(Q_OS_WIN32)
45 #include <CoreFoundation/CFBundle.h>
50 #include <wtf/Platform.h>
51 #include <wtf/Vector.h>
53 #include "PlatformString.h"
55 typedef const struct __CFData
* CFDataRef
;
58 // These are to avoid including <winbase.h> in a header for Chromium
61 typedef struct HINSTANCE__
* HINSTANCE
;
62 typedef HINSTANCE HMODULE
;
70 typedef HANDLE PlatformFileHandle
;
71 typedef HMODULE PlatformModule
;
72 // FIXME: -1 is INVALID_HANDLE_VALUE, defined in <winbase.h>. Chromium tries to
73 // avoid using Windows headers in headers. We'd rather move this into the .cpp.
74 const PlatformFileHandle invalidPlatformFileHandle
= reinterpret_cast<HANDLE
>(-1);
76 struct PlatformModuleVersion
{
80 PlatformModuleVersion(unsigned)
86 PlatformModuleVersion(unsigned lsb
, unsigned msb
)
95 typedef QFile
* PlatformFileHandle
;
96 const PlatformFileHandle invalidPlatformFileHandle
= 0;
98 typedef CFBundleRef PlatformModule
;
99 typedef unsigned PlatformModuleVersion
;
100 #elif defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_S60)
101 typedef QLibrary
* PlatformModule
;
102 typedef unsigned PlatformModuleVersion
;
103 #elif defined(Q_OS_WIN)
104 typedef HMODULE PlatformModule
;
105 struct PlatformModuleVersion
{
109 PlatformModuleVersion(unsigned)
115 PlatformModuleVersion(unsigned lsb
, unsigned msb
)
125 typedef int PlatformFileHandle
;
127 typedef GModule
* PlatformModule
;
129 typedef void* PlatformModule
;
131 const PlatformFileHandle invalidPlatformFileHandle
= -1;
133 typedef unsigned PlatformModuleVersion
;
136 bool fileExists(const String
&);
137 bool deleteFile(const String
&);
138 bool deleteEmptyDirectory(const String
&);
139 bool getFileSize(const String
&, long long& result
);
140 bool getFileModificationTime(const String
&, time_t& result
);
141 String
pathByAppendingComponent(const String
& path
, const String
& component
);
142 bool makeAllDirectories(const String
& path
);
143 String
homeDirectoryPath();
144 String
pathGetFileName(const String
&);
145 String
directoryName(const String
&);
147 Vector
<String
> listDirectory(const String
& path
, const String
& filter
= String());
149 CString
fileSystemRepresentation(const String
&);
151 inline bool isHandleValid(const PlatformFileHandle
& handle
) { return handle
!= invalidPlatformFileHandle
; }
153 // Prefix is what the filename should be prefixed with, not the full path.
154 CString
openTemporaryFile(const char* prefix
, PlatformFileHandle
&);
155 void closeFile(PlatformFileHandle
&);
156 int writeToFile(PlatformFileHandle
, const char* data
, int length
);
158 // Methods for dealing with loadable modules
159 bool unloadModule(PlatformModule
);
162 String
localUserSpecificStorageDirectory();
163 String
roamingUserSpecificStorageDirectory();
165 bool safeCreateFile(const String
&, CFDataRef
);
169 String
filenameToString(const char*);
170 char* filenameFromString(const String
&);
171 String
filenameForDisplay(const String
&);
174 } // namespace WebCore
176 #endif // FileSystem_h