Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
FileSystem.h
Go to the documentation of this file.
1 #pragma once
15 #include <Ultralight/Defines.h>
16 #include <Ultralight/String16.h>
17 #include <time.h>
18 
19 namespace ultralight {
20 
24 #if defined(__WIN32__) || defined(_WIN32)
25 typedef size_t FileHandle;
26 #else
27 typedef int FileHandle;
28 #endif
29 
34 
39  kFileSeekOrigin_Beginning = 0,
40  kFileSeekOrigin_Current,
41  kFileSeekOrigin_End
42 };
43 
48  kMetadataType_Unknown = 0,
49  kMetadataType_File,
50  kMetadataType_Directory,
51 };
52 
73 class UExport FileSystem {
74 public:
75  virtual ~FileSystem();
76 
80  virtual bool FileExists(const String16& path) = 0;
81 
85  virtual bool DeleteFile_(const String16& path) = 0;
86 
90  virtual bool DeleteEmptyDirectory(const String16& path) = 0;
91 
95  virtual bool MoveFile_(const String16& old_path, const String16& new_path) = 0;
96 
100  virtual bool GetFileSize(const String16& path, int64_t& result) = 0;
101 
105  virtual bool GetFileSize(FileHandle handle, int64_t& result) = 0;
106 
110  virtual bool GetFileMimeType(const String16& path, String16& result) = 0;
111 
115  virtual bool GetFileModificationTime(const String16& path, time_t& result) = 0;
116 
120  virtual bool GetFileCreationTime(const String16& path, time_t& result) = 0;
121 
125  virtual MetadataType GetMetadataType(const String16& path) = 0;
126 
130  virtual String16 GetPathByAppendingComponent(const String16& path, const String16& component) = 0;
131 
135  virtual bool CreateDirectory_(const String16& path) = 0;
136 
140  virtual String16 GetHomeDirectory() = 0;
141 
145  virtual String16 GetFilenameFromPath(const String16& path) = 0;
146 
150  virtual String16 GetDirectoryNameFromPath(const String16& path) = 0;
151 
155  virtual bool GetVolumeFreeSpace(const String16& path, uint64_t& result) = 0;
156 
160  virtual int32_t GetVolumeId(const String16& path) = 0;
161 
165  virtual Ref<String16Vector> ListDirectory(const String16& path, const String16& filter) = 0;
166 
170  virtual String16 OpenTemporaryFile(const String16& prefix, FileHandle& handle) = 0;
171 
175  virtual FileHandle OpenFile(const String16& path, bool open_for_writing) = 0;
176 
180  virtual void CloseFile(FileHandle& handle) = 0;
181 
185  virtual int64_t SeekFile(FileHandle handle, int64_t offset, FileSeekOrigin origin) = 0;
186 
190  virtual bool TruncateFile(FileHandle handle, int64_t offset) = 0;
191 
195  virtual int64_t WriteToFile(FileHandle handle, const char* data, int64_t length) = 0;
196 
200  virtual int64_t ReadFromFile(FileHandle handle, char* data, int64_t length) = 0;
201 
205  virtual bool CopyFile_(const String16& source_path, const String16& destination_path) = 0;
206 };
207 
208 } // namespace ultralight
FileSeekOrigin
The position to seek from in a file,.
Definition: FileSystem.h:38
MetadataType
The type of path,.
Definition: FileSystem.h:47
A non-nullable smart pointer.
Definition: RefPtr.h:64
This is a set of common JavaScriptCore Helper functions to simplify sample code.
Definition: App.h:19
FileSystem interface, used for all file system operations.
Definition: FileSystem.h:73
A UTF-16 string container.
Definition: String16.h:38
const FileHandle invalidFileHandle
Handle used to denote an invalid file.
Definition: FileSystem.h:33
The header for the String16 class.
int FileHandle
File Handle type used as unique ID for opened files.
Definition: FileSystem.h:27