summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_extension.cpp36
-rw-r--r--core/fxcrt/fx_stream.h25
2 files changed, 34 insertions, 27 deletions
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 39bf028205..6bf61f1fb5 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -40,7 +40,7 @@ void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) {
}
IFX_SeekableStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) {
- return FX_CreateFileStream(m_path.c_str(), dwModes);
+ return IFX_SeekableStream::CreateFromFilename(m_path.c_str(), dwModes);
}
bool CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) {
@@ -338,33 +338,41 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) {
}
#endif // PDF_ENABLE_XFA
-IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename,
- uint32_t dwModes) {
+// static
+IFX_SeekableStream* IFX_SeekableStream::CreateFromFilename(
+ const FX_CHAR* filename,
+ uint32_t dwModes) {
std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create());
if (!pFA->Open(filename, dwModes))
return nullptr;
return new CFX_CRTFileStream(std::move(pFA));
}
-IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename,
- uint32_t dwModes) {
+// static
+IFX_SeekableStream* IFX_SeekableStream::CreateFromFilename(
+ const FX_WCHAR* filename,
+ uint32_t dwModes) {
std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create());
if (!pFA->Open(filename, dwModes))
return nullptr;
return new CFX_CRTFileStream(std::move(pFA));
}
-IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename) {
- return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
-}
-IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename) {
- return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
+
+// static
+IFX_SeekableReadStream* IFX_SeekableReadStream::CreateFromFilename(
+ const FX_CHAR* filename) {
+ return IFX_SeekableStream::CreateFromFilename(filename, FX_FILEMODE_ReadOnly);
}
-IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
- size_t dwSize,
- bool bTakeOver) {
+
+// static
+IFX_MemoryStream* IFX_MemoryStream::Create(uint8_t* pBuffer,
+ size_t dwSize,
+ bool bTakeOver) {
return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
}
-IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive) {
+
+// static
+IFX_MemoryStream* IFX_MemoryStream::Create(bool bConsecutive) {
return new CFX_MemoryStream(bConsecutive);
}
diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h
index dc687cf653..fe92c939d9 100644
--- a/core/fxcrt/fx_stream.h
+++ b/core/fxcrt/fx_stream.h
@@ -85,6 +85,8 @@ class IFX_SeekableWriteStream : public IFX_WriteStream {
class IFX_SeekableReadStream : public IFX_ReadStream {
public:
+ static IFX_SeekableReadStream* CreateFromFilename(const FX_CHAR* filename);
+
// IFX_ReadStream:
void Release() override = 0;
bool IsEOF() override;
@@ -95,12 +97,14 @@ class IFX_SeekableReadStream : public IFX_ReadStream {
virtual FX_FILESIZE GetSize() = 0;
};
-IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename);
-IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename);
-
class IFX_SeekableStream : public IFX_SeekableReadStream,
public IFX_SeekableWriteStream {
public:
+ static IFX_SeekableStream* CreateFromFilename(const FX_CHAR* filename,
+ uint32_t dwModes);
+ static IFX_SeekableStream* CreateFromFilename(const FX_WCHAR* filename,
+ uint32_t dwModes);
+
virtual IFX_SeekableStream* Retain() = 0;
// IFX_SeekableReadStream:
@@ -119,11 +123,6 @@ class IFX_SeekableStream : public IFX_SeekableReadStream,
bool Flush() override = 0;
};
-IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename,
- uint32_t dwModes);
-IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename,
- uint32_t dwModes);
-
#ifdef PDF_ENABLE_XFA
class IFX_FileAccess {
public:
@@ -138,6 +137,11 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath);
class IFX_MemoryStream : public IFX_SeekableStream {
public:
+ static IFX_MemoryStream* Create(uint8_t* pBuffer,
+ size_t nSize,
+ bool bTakeOver = false);
+ static IFX_MemoryStream* Create(bool bConsecutive = false);
+
virtual bool IsConsecutive() const = 0;
virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
virtual uint8_t* GetBuffer() const = 0;
@@ -147,11 +151,6 @@ class IFX_MemoryStream : public IFX_SeekableStream {
virtual void DetachBuffer() = 0;
};
-IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
- size_t nSize,
- bool bTakeOver = false);
-IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive = false);
-
class IFX_BufferRead : public IFX_ReadStream {
public:
// IFX_ReadStream: