Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / core / include / fxcrt / fx_stream.h
index 869797f..0a3d1c4 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #ifndef _FX_STREAM_H_
@@ -30,6 +30,7 @@ FX_DEFINEHANDLE(FX_HFILE)
 #endif
 #define FX_FILESIZE                    off_t
 #endif
+typedef base::CheckedNumeric<FX_FILESIZE>    FX_SAFE_FILESIZE;
 #define FX_GETBYTEOFFSET32(a)  0
 #define FX_GETBYTEOFFSET40(a)  0
 #define FX_GETBYTEOFFSET48(a)  0
@@ -41,9 +42,9 @@ FX_DEFINEHANDLE(FX_HFILE)
 #define FX_FILEMODE_Write              0
 #define FX_FILEMODE_ReadOnly   1
 #define FX_FILEMODE_Truncate   2
-FX_HFILE       FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
-FX_HFILE       FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
-void           FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL);
+FX_HFILE       FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode);
+FX_HFILE       FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode);
+void           FX_File_Close(FX_HFILE hFile);
 FX_FILESIZE    FX_File_GetSize(FX_HFILE hFile);
 FX_FILESIZE    FX_File_GetPosition(FX_HFILE hFile);
 FX_FILESIZE    FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
@@ -85,8 +86,8 @@ public:
         return WriteBlock(pData, GetSize(), size);
     }
 };
-IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
-IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
+IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename);
+IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename);
 class IFX_StreamRead
 {
 public:
@@ -131,8 +132,8 @@ public:
         return 0;
     }
 };
-IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
-IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
+IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename);
+IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename);
 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite
 {
 public:
@@ -159,8 +160,17 @@ public:
 
     virtual FX_BOOL                            Flush() = 0;
 };
-IFX_FileStream*                FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
-IFX_FileStream*                FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
+IFX_FileStream*                FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes);
+IFX_FileStream*                FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes);
+class IFX_FileAccess
+{
+public:
+       virtual void                            Release() = 0;  
+       virtual IFX_FileAccess*         Retain() = 0;
+       virtual void                            GetPath(CFX_WideString& wsPath) = 0;
+       virtual IFX_FileStream*         CreateFileStream(FX_DWORD dwModes) = 0;
+};
+IFX_FileAccess* FX_CreateDefaultFileAccess(FX_WSTR wsPath);
 class IFX_MemoryStream : public IFX_FileStream
 {
 public:
@@ -175,8 +185,8 @@ public:
 
     virtual void                       DetachBuffer() = 0;
 };
-IFX_MemoryStream*      FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE, IFX_Allocator* pAllocator = NULL);
-IFX_MemoryStream*      FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE, IFX_Allocator* pAllocator = NULL);
+IFX_MemoryStream*      FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE);
+IFX_MemoryStream*      FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
 class IFX_BufferRead : public IFX_StreamRead
 {
 public: