Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: core/fxcrt/include/fx_stream.h

Issue 2382723003: Move core/fxcrt/include to core/fxcrt (Closed)
Patch Set: Rebase to master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcrt/include/fx_safe_types.h ('k') | core/fxcrt/include/fx_string.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef CORE_FXCRT_INCLUDE_FX_STREAM_H_
8 #define CORE_FXCRT_INCLUDE_FX_STREAM_H_
9
10 #include "core/fxcrt/include/fx_string.h"
11 #include "core/fxcrt/include/fx_system.h"
12
13 void* FX_OpenFolder(const FX_CHAR* path);
14 void* FX_OpenFolder(const FX_WCHAR* path);
15 FX_BOOL FX_GetNextFile(void* handle,
16 CFX_ByteString& filename,
17 FX_BOOL& bFolder);
18 FX_BOOL FX_GetNextFile(void* handle,
19 CFX_WideString& filename,
20 FX_BOOL& bFolder);
21 void FX_CloseFolder(void* handle);
22 FX_WCHAR FX_GetFolderSeparator();
23
24 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
25 #define FX_FILESIZE int32_t
26 #else
27 #include <fcntl.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
30
31 #ifndef O_BINARY
32 #define O_BINARY 0
33 #endif // O_BINARY
34
35 #ifndef O_LARGEFILE
36 #define O_LARGEFILE 0
37 #endif // O_LARGEFILE
38
39 #define FX_FILESIZE off_t
40 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
41
42 #define FX_GETBYTEOFFSET32(a) 0
43 #define FX_GETBYTEOFFSET40(a) 0
44 #define FX_GETBYTEOFFSET48(a) 0
45 #define FX_GETBYTEOFFSET56(a) 0
46 #define FX_GETBYTEOFFSET24(a) ((uint8_t)(a >> 24))
47 #define FX_GETBYTEOFFSET16(a) ((uint8_t)(a >> 16))
48 #define FX_GETBYTEOFFSET8(a) ((uint8_t)(a >> 8))
49 #define FX_GETBYTEOFFSET0(a) ((uint8_t)(a))
50 #define FX_FILEMODE_Write 0
51 #define FX_FILEMODE_ReadOnly 1
52 #define FX_FILEMODE_Truncate 2
53
54 class IFX_StreamWrite {
55 public:
56 virtual ~IFX_StreamWrite() {}
57 virtual void Release() = 0;
58 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
59 };
60
61 class IFX_FileWrite : public IFX_StreamWrite {
62 public:
63 // IFX_StreamWrite:
64 FX_BOOL WriteBlock(const void* pData, size_t size) override;
65 virtual FX_FILESIZE GetSize() = 0;
66 virtual FX_BOOL Flush() = 0;
67 virtual FX_BOOL WriteBlock(const void* pData,
68 FX_FILESIZE offset,
69 size_t size) = 0;
70 };
71
72 class IFX_StreamRead {
73 public:
74 virtual ~IFX_StreamRead() {}
75
76 virtual void Release() = 0;
77 virtual FX_BOOL IsEOF() = 0;
78 virtual FX_FILESIZE GetPosition() = 0;
79 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
80 };
81
82 class IFX_FileRead : public IFX_StreamRead {
83 public:
84 // IFX_StreamRead:
85 void Release() override = 0;
86 FX_BOOL IsEOF() override;
87 FX_FILESIZE GetPosition() override;
88 size_t ReadBlock(void* buffer, size_t size) override;
89
90 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
91 virtual FX_FILESIZE GetSize() = 0;
92 };
93
94 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename);
95 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename);
96
97 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite {
98 public:
99 virtual IFX_FileStream* Retain() = 0;
100
101 // IFX_FileRead:
102 void Release() override = 0;
103 FX_BOOL IsEOF() override = 0;
104 FX_FILESIZE GetPosition() override = 0;
105 size_t ReadBlock(void* buffer, size_t size) override = 0;
106 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0;
107 FX_FILESIZE GetSize() override = 0;
108
109 // IFX_FileWrite:
110 FX_BOOL WriteBlock(const void* buffer,
111 FX_FILESIZE offset,
112 size_t size) override = 0;
113 FX_BOOL WriteBlock(const void* buffer, size_t size) override;
114 FX_BOOL Flush() override = 0;
115 };
116
117 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes);
118 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, uint32_t dwModes);
119
120 #ifdef PDF_ENABLE_XFA
121 class IFX_FileAccess {
122 public:
123 virtual ~IFX_FileAccess() {}
124 virtual void Release() = 0;
125 virtual IFX_FileAccess* Retain() = 0;
126 virtual void GetPath(CFX_WideString& wsPath) = 0;
127 virtual IFX_FileStream* CreateFileStream(uint32_t dwModes) = 0;
128 };
129 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath);
130 #endif // PDF_ENABLE_XFA
131
132 class IFX_MemoryStream : public IFX_FileStream {
133 public:
134 virtual FX_BOOL IsConsecutive() const = 0;
135 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
136 virtual uint8_t* GetBuffer() const = 0;
137 virtual void AttachBuffer(uint8_t* pBuffer,
138 size_t nSize,
139 FX_BOOL bTakeOver = FALSE) = 0;
140 virtual void DetachBuffer() = 0;
141 };
142
143 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
144 size_t nSize,
145 FX_BOOL bTakeOver = FALSE);
146 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
147
148 class IFX_BufferRead : public IFX_StreamRead {
149 public:
150 // IFX_StreamRead:
151 void Release() override = 0;
152 FX_BOOL IsEOF() override = 0;
153 FX_FILESIZE GetPosition() override = 0;
154 size_t ReadBlock(void* buffer, size_t size) override = 0;
155
156 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
157 virtual const uint8_t* GetBlockBuffer() = 0;
158 virtual size_t GetBlockSize() = 0;
159 virtual FX_FILESIZE GetBlockOffset() = 0;
160 };
161
162 #endif // CORE_FXCRT_INCLUDE_FX_STREAM_H_
OLDNEW
« no previous file with comments | « core/fxcrt/include/fx_safe_types.h ('k') | core/fxcrt/include/fx_string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698