TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FileStream.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PART_FILE_HEADER
 
struct  _PART_FILE_MAP_ENTRY
 
struct  _FILE_BITMAP_FOOTER
 
union  TBaseProviderData
 
struct  TFileStream
 
struct  TBlockStream
 
struct  TEncryptedStream
 

Macros

#define ID_FILE_BITMAP_FOOTER   0x33767470
 
#define DEFAULT_BLOCK_SIZE   0x00004000
 
#define DEFAULT_BUILD_NUMBER   10958
 
#define ENCRYPTED_CHUNK_SIZE   0x40
 

Typedefs

typedef void(* STREAM_INIT )(struct TFileStream *pStream)
 
typedef bool(* STREAM_CREATE )(struct TFileStream *pStream)
 
typedef bool(* STREAM_OPEN )(struct TFileStream *pStream, const TCHAR *szFileName, DWORD dwStreamFlags)
 
typedef bool(* STREAM_READ )(struct TFileStream *pStream, ULONGLONG *pByteOffset, void *pvBuffer, DWORD dwBytesToRead)
 
typedef bool(* STREAM_WRITE )(struct TFileStream *pStream, ULONGLONG *pByteOffset, const void *pvBuffer, DWORD dwBytesToWrite)
 
typedef bool(* STREAM_RESIZE )(struct TFileStream *pStream, ULONGLONG FileSize)
 
typedef bool(* STREAM_GETSIZE )(struct TFileStream *pStream, ULONGLONG *pFileSize)
 
typedef bool(* STREAM_GETPOS )(struct TFileStream *pStream, ULONGLONG *pByteOffset)
 
typedef void(* STREAM_CLOSE )(struct TFileStream *pStream)
 
typedef bool(* BLOCK_READ )(struct TFileStream *pStream, ULONGLONG StartOffset, ULONGLONG EndOffset, LPBYTE BlockBuffer, DWORD BytesNeeded, bool bAvailable)
 
typedef bool(* BLOCK_CHECK )(struct TFileStream *pStream, ULONGLONG BlockOffset)
 
typedef void(* BLOCK_SAVEMAP )(struct TFileStream *pStream)
 
typedef struct _PART_FILE_HEADER PART_FILE_HEADER
 
typedef struct _PART_FILE_HEADERPPART_FILE_HEADER
 
typedef struct _PART_FILE_MAP_ENTRY PART_FILE_MAP_ENTRY
 
typedef struct
_PART_FILE_MAP_ENTRY
PPART_FILE_MAP_ENTRY
 
typedef struct _FILE_BITMAP_FOOTER FILE_BITMAP_FOOTER
 
typedef struct
_FILE_BITMAP_FOOTER
PFILE_BITMAP_FOOTER
 

Functions

TFileStreamFileStream_CreateFile (const TCHAR *szFileName, DWORD dwStreamFlags)
 
TFileStreamFileStream_OpenFile (const TCHAR *szFileName, DWORD dwStreamFlags)
 
const TCHARFileStream_GetFileName (TFileStream *pStream)
 
size_t FileStream_Prefix (const TCHAR *szFileName, DWORD *pdwProvider)
 
bool FileStream_SetCallback (TFileStream *pStream, STREAM_DOWNLOAD_CALLBACK pfnCallback, void *pvUserData)
 
bool FileStream_Read (TFileStream *pStream, ULONGLONG *pByteOffset, void *pvBuffer, DWORD dwBytesToRead)
 
bool FileStream_Write (TFileStream *pStream, ULONGLONG *pByteOffset, const void *pvBuffer, DWORD dwBytesToWrite)
 
bool FileStream_SetSize (TFileStream *pStream, ULONGLONG NewFileSize)
 
bool FileStream_GetSize (TFileStream *pStream, ULONGLONG *pFileSize)
 
bool FileStream_GetPos (TFileStream *pStream, ULONGLONG *pByteOffset)
 
bool FileStream_GetTime (TFileStream *pStream, ULONGLONG *pFT)
 
bool FileStream_GetFlags (TFileStream *pStream, PDWORD pdwStreamFlags)
 
bool FileStream_Replace (TFileStream *pStream, TFileStream *pNewStream)
 
void FileStream_Close (TFileStream *pStream)
 

Macro Definition Documentation

#define DEFAULT_BLOCK_SIZE   0x00004000
#define DEFAULT_BUILD_NUMBER   10958
#define ENCRYPTED_CHUNK_SIZE   0x40
#define ID_FILE_BITMAP_FOOTER   0x33767470

Typedef Documentation

typedef bool(* BLOCK_CHECK)(struct TFileStream *pStream,ULONGLONG BlockOffset)
typedef bool(* BLOCK_READ)(struct TFileStream *pStream,ULONGLONG StartOffset,ULONGLONG EndOffset,LPBYTE BlockBuffer,DWORD BytesNeeded,bool bAvailable)
typedef void(* BLOCK_SAVEMAP)(struct TFileStream *pStream)
typedef void(* STREAM_CLOSE)(struct TFileStream *pStream)
typedef bool(* STREAM_CREATE)(struct TFileStream *pStream)
typedef bool(* STREAM_GETPOS)(struct TFileStream *pStream,ULONGLONG *pByteOffset)
typedef bool(* STREAM_GETSIZE)(struct TFileStream *pStream,ULONGLONG *pFileSize)
typedef void(* STREAM_INIT)(struct TFileStream *pStream)
typedef bool(* STREAM_OPEN)(struct TFileStream *pStream,const TCHAR *szFileName,DWORD dwStreamFlags)
typedef bool(* STREAM_READ)(struct TFileStream *pStream,ULONGLONG *pByteOffset,void *pvBuffer,DWORD dwBytesToRead)
typedef bool(* STREAM_RESIZE)(struct TFileStream *pStream,ULONGLONG FileSize)
typedef bool(* STREAM_WRITE)(struct TFileStream *pStream,ULONGLONG *pByteOffset,const void *pvBuffer,DWORD dwBytesToWrite)

Function Documentation

void FileStream_Close ( TFileStream pStream)

This function closes an archive file and frees any data buffers that have been allocated for stream management. The function must also support partially allocated structure, i.e. one or more buffers can be NULL, if there was an allocation failure during the process

pStream Pointer to an open stream

2708 {
2709  // Check if the stream structure is allocated at all
2710  if(pStream != NULL)
2711  {
2712  // Free the master stream, if any
2713  if(pStream->pMaster != NULL)
2714  FileStream_Close(pStream->pMaster);
2715  pStream->pMaster = NULL;
2716 
2717  // Close the stream provider.
2718  if(pStream->StreamClose != NULL)
2719  pStream->StreamClose(pStream);
2720 
2721  // Also close base stream, if any
2722  else if(pStream->BaseClose != NULL)
2723  pStream->BaseClose(pStream);
2724 
2725  // Free the stream itself
2726  CASC_FREE(pStream);
2727  }
2728 }
STREAM_CLOSE StreamClose
Definition: FileStream.h:161
arena_t NULL
Definition: jemalloc_internal.h:624
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
STREAM_CLOSE BaseClose
Definition: FileStream.h:175
void FileStream_Close(TFileStream *pStream)
Definition: FileStream.cpp:2707
TFileStream * pMaster
Definition: FileStream.h:181

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TFileStream* FileStream_CreateFile ( const TCHAR szFileName,
DWORD  dwStreamFlags 
)

This function creates a new file for read-write access

  • If the current platform supports file sharing, the file must be created for read sharing (i.e. another application can open the file for read, but not for write)
  • If the file does not exist, the function must create new one
  • If the file exists, the function must rewrite it and set to zero size
  • The parameters of the function must be validate by the caller
  • The function must initialize all stream function pointers in TFileStream
  • If the function fails from any reason, it must close all handles and free all memory that has been allocated in the process of stream creation, including the TFileStream structure itself

szFileName Name of the file to create

2331 {
2332  TFileStream * pStream;
2333 
2334  // We only support creation of flat, local file
2335  if((dwStreamFlags & (STREAM_PROVIDERS_MASK)) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE))
2336  {
2338  return NULL;
2339  }
2340 
2341  // Allocate file stream structure for flat stream
2342  pStream = AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags);
2343  if(pStream != NULL)
2344  {
2345  // Attempt to create the disk file
2346  if(BaseFile_Create(pStream))
2347  {
2348  // Fill the stream provider functions
2349  pStream->StreamRead = pStream->BaseRead;
2350  pStream->StreamWrite = pStream->BaseWrite;
2351  pStream->StreamResize = pStream->BaseResize;
2352  pStream->StreamGetSize = pStream->BaseGetSize;
2353  pStream->StreamGetPos = pStream->BaseGetPos;
2354  pStream->StreamClose = pStream->BaseClose;
2355  return pStream;
2356  }
2357 
2358  // File create failed, delete the stream
2359  CASC_FREE(pStream);
2360  pStream = NULL;
2361  }
2362 
2363  // Return the stream
2364  return pStream;
2365 }
STREAM_GETPOS StreamGetPos
Definition: FileStream.h:160
STREAM_CLOSE StreamClose
Definition: FileStream.h:161
static TFileStream * AllocateFileStream(const TCHAR *szFileName, size_t StreamSize, DWORD dwStreamFlags)
Definition: FileStream.cpp:977
STREAM_READ BaseRead
Definition: FileStream.h:170
arena_t NULL
Definition: jemalloc_internal.h:624
STREAM_RESIZE BaseResize
Definition: FileStream.h:172
STREAM_WRITE BaseWrite
Definition: FileStream.h:171
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
void SetLastError(int nError)
Definition: Common.cpp:75
STREAM_CLOSE BaseClose
Definition: FileStream.h:175
STREAM_GETPOS BaseGetPos
Definition: FileStream.h:174
STREAM_WRITE StreamWrite
Definition: FileStream.h:157
#define STREAM_PROVIDER_FLAT
Definition: CascLib.h:50
STREAM_RESIZE StreamResize
Definition: FileStream.h:158
#define BASE_PROVIDER_FILE
Definition: CascLib.h:45
static bool BaseFile_Create(TFileStream *pStream)
Definition: FileStream.cpp:52
STREAM_GETSIZE StreamGetSize
Definition: FileStream.h:159
Definition: FileStream.h:153
#define ERROR_NOT_SUPPORTED
Definition: CascPort.h:209
#define STREAM_PROVIDERS_MASK
Definition: CascLib.h:61
Definition: FileStream.h:195
STREAM_GETSIZE BaseGetSize
Definition: FileStream.h:173
STREAM_READ StreamRead
Definition: FileStream.h:156

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const TCHAR* FileStream_GetFileName ( TFileStream pStream)

Returns the file name of the stream

pStream Pointer to an open stream

2422 {
2423  assert(pStream != NULL);
2424  return pStream->szFileName;
2425 }
arena_t NULL
Definition: jemalloc_internal.h:624
TCHAR * szFileName
Definition: FileStream.h:182
bool FileStream_GetFlags ( TFileStream pStream,
PDWORD  pdwStreamFlags 
)

Returns the stream flags

pStream Pointer to an open stream pdwStreamFlags Pointer where to store the stream flags

2650 {
2651  *pdwStreamFlags = pStream->dwFlags;
2652  return true;
2653 }
DWORD dwFlags
Definition: FileStream.h:187
bool FileStream_GetPos ( TFileStream pStream,
ULONGLONG pByteOffset 
)

This function returns the current file position pStream pByteOffset

2625 {
2626  assert(pStream->StreamGetPos != NULL);
2627  return pStream->StreamGetPos(pStream, pByteOffset);
2628 }
STREAM_GETPOS StreamGetPos
Definition: FileStream.h:160
arena_t NULL
Definition: jemalloc_internal.h:624
bool FileStream_GetSize ( TFileStream pStream,
ULONGLONG pFileSize 
)

Returns the size of a file

pStream Pointer to an open stream FileSize Pointer where to store the file size

2596 {
2597  assert(pStream->StreamGetSize != NULL);
2598  return pStream->StreamGetSize(pStream, pFileSize);
2599 }
arena_t NULL
Definition: jemalloc_internal.h:624
STREAM_GETSIZE StreamGetSize
Definition: FileStream.h:159

+ Here is the caller graph for this function:

bool FileStream_GetTime ( TFileStream pStream,
ULONGLONG pFileTime 
)

Returns the last write time of a file

pStream Pointer to an open stream pFileType Pointer where to store the file last write time

2637 {
2638  // Just use the saved filetime value
2639  *pFileTime = pStream->Base.File.FileTime;
2640  return true;
2641 }
ULONGLONG FileTime
Definition: FileStream.h:131
TBaseProviderData Base
Definition: FileStream.h:178
struct TBaseProviderData::@0 File
TFileStream* FileStream_OpenFile ( const TCHAR szFileName,
DWORD  dwStreamFlags 
)

This function opens an existing file for read or read-write access

  • If the current platform supports file sharing, the file must be open for read sharing (i.e. another application can open the file for read, but not for write)
  • If the file does not exist, the function must return NULL
  • If the file exists but cannot be open, then function must return NULL
  • The parameters of the function must be validate by the caller
  • The function must initialize all stream function pointers in TFileStream
  • If the function fails from any reason, it must close all handles and free all memory that has been allocated in the process of stream creation, including the TFileStream structure itself

szFileName Name of the file to open dwStreamFlags specifies the provider and base storage type

2387 {
2388  DWORD dwProvider = dwStreamFlags & STREAM_PROVIDERS_MASK;
2389  size_t nPrefixLength = FileStream_Prefix(szFileName, &dwProvider);
2390 
2391  // Re-assemble the stream flags
2392  dwStreamFlags = (dwStreamFlags & STREAM_OPTIONS_MASK) | dwProvider;
2393  szFileName += nPrefixLength;
2394 
2395  // Perform provider-specific open
2396  switch(dwStreamFlags & STREAM_PROVIDER_MASK)
2397  {
2398  case STREAM_PROVIDER_FLAT:
2399  return FlatStream_Open(szFileName, dwStreamFlags);
2400 
2402  return PartStream_Open(szFileName, dwStreamFlags);
2403 
2405  return EncrStream_Open(szFileName, dwStreamFlags);
2406 
2408  return Block4Stream_Open(szFileName, dwStreamFlags);
2409 
2410  default:
2412  return NULL;
2413  }
2414 }
#define STREAM_OPTIONS_MASK
Definition: CascLib.h:59
static TFileStream * Block4Stream_Open(const TCHAR *szFileName, DWORD dwStreamFlags)
Definition: FileStream.cpp:2194
arena_t NULL
Definition: jemalloc_internal.h:624
void SetLastError(int nError)
Definition: Common.cpp:75
size_t FileStream_Prefix(const TCHAR *szFileName, DWORD *pdwProvider)
Definition: FileStream.cpp:2434
#define STREAM_PROVIDER_ENCRYPTED
Definition: CascLib.h:52
static TFileStream * FlatStream_Open(const TCHAR *szFileName, DWORD dwStreamFlags)
Definition: FileStream.cpp:1328
#define STREAM_PROVIDER_FLAT
Definition: CascLib.h:50
#define STREAM_PROVIDER_MASK
Definition: CascLib.h:54
unsigned int DWORD
Definition: CascPort.h:139
#define STREAM_PROVIDER_PARTIAL
Definition: CascLib.h:51
static TFileStream * PartStream_Open(const TCHAR *szFileName, DWORD dwStreamFlags)
Definition: FileStream.cpp:1748
#define ERROR_INVALID_PARAMETER
Definition: CascPort.h:210
#define STREAM_PROVIDERS_MASK
Definition: CascLib.h:61
#define STREAM_PROVIDER_BLOCK4
Definition: CascLib.h:53
static TFileStream * EncrStream_Open(const TCHAR *szFileName, DWORD dwStreamFlags)
Definition: FileStream.cpp:2065

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t FileStream_Prefix ( const TCHAR szFileName,
DWORD pdwProvider 
)

Returns the length of the provider prefix. Returns zero if no prefix

szFileName Pointer to a stream name (file, mapped file, URL) pdwStreamProvider Pointer to a DWORD variable that receives stream provider (STREAM_PROVIDER_XXX)

2435 {
2436  size_t nPrefixLength1 = 0;
2437  size_t nPrefixLength2 = 0;
2438  DWORD dwProvider = 0;
2439 
2440  if(szFileName != NULL)
2441  {
2442  //
2443  // Determine the stream provider
2444  //
2445 
2446  if(!_tcsnicmp(szFileName, _T("flat-"), 5))
2447  {
2448  dwProvider |= STREAM_PROVIDER_FLAT;
2449  nPrefixLength1 = 5;
2450  }
2451 
2452  else if(!_tcsnicmp(szFileName, _T("part-"), 5))
2453  {
2454  dwProvider |= STREAM_PROVIDER_PARTIAL;
2455  nPrefixLength1 = 5;
2456  }
2457 
2458  else if(!_tcsnicmp(szFileName, _T("mpqe-"), 5))
2459  {
2460  dwProvider |= STREAM_PROVIDER_ENCRYPTED;
2461  nPrefixLength1 = 5;
2462  }
2463 
2464  else if(!_tcsnicmp(szFileName, _T("blk4-"), 5))
2465  {
2466  dwProvider |= STREAM_PROVIDER_BLOCK4;
2467  nPrefixLength1 = 5;
2468  }
2469 
2470  //
2471  // Determine the base provider
2472  //
2473 
2474  if(!_tcsnicmp(szFileName+nPrefixLength1, _T("file:"), 5))
2475  {
2476  dwProvider |= BASE_PROVIDER_FILE;
2477  nPrefixLength2 = 5;
2478  }
2479 
2480  else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("map:"), 4))
2481  {
2482  dwProvider |= BASE_PROVIDER_MAP;
2483  nPrefixLength2 = 4;
2484  }
2485 
2486  else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("http:"), 5))
2487  {
2488  dwProvider |= BASE_PROVIDER_HTTP;
2489  nPrefixLength2 = 5;
2490  }
2491 
2492  // Only accept stream provider if we recognized the base provider
2493  if(nPrefixLength2 != 0)
2494  {
2495  // It is also allowed to put "//" after the base provider, e.g. "file://", "http://"
2496  if(szFileName[nPrefixLength1+nPrefixLength2] == '/' && szFileName[nPrefixLength1+nPrefixLength2+1] == '/')
2497  nPrefixLength2 += 2;
2498 
2499  if(pdwProvider != NULL)
2500  *pdwProvider = dwProvider;
2501  return nPrefixLength1 + nPrefixLength2;
2502  }
2503  }
2504 
2505  return 0;
2506 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define BASE_PROVIDER_HTTP
Definition: CascLib.h:47
#define _T(x)
Definition: CascPort.h:171
#define BASE_PROVIDER_MAP
Definition: CascLib.h:46
#define STREAM_PROVIDER_ENCRYPTED
Definition: CascLib.h:52
#define STREAM_PROVIDER_FLAT
Definition: CascLib.h:50
unsigned int DWORD
Definition: CascPort.h:139
#define STREAM_PROVIDER_PARTIAL
Definition: CascLib.h:51
#define BASE_PROVIDER_FILE
Definition: CascLib.h:45
#define _tcsnicmp
Definition: CascPort.h:188
#define STREAM_PROVIDER_BLOCK4
Definition: CascLib.h:53

+ Here is the caller graph for this function:

bool FileStream_Read ( TFileStream pStream,
ULONGLONG pByteOffset,
void *  pvBuffer,
DWORD  dwBytesToRead 
)

Reads data from the stream

  • Returns true if the read operation succeeded and all bytes have been read
  • Returns false if either read failed or not all bytes have been read
  • If the pByteOffset is NULL, the function must read the data from the current file position
  • The function can be called with dwBytesToRead = 0. In that case, pvBuffer is ignored and the function just adjusts file pointer.

pStream Pointer to an open stream pByteOffset Pointer to file byte offset. If NULL, it reads from the current position pvBuffer Pointer to data to be read dwBytesToRead Number of bytes to read from the file

Returns
  • If the function reads the required amount of bytes, it returns true.
  • If the function reads less than required bytes, it returns false and GetLastError() returns ERROR_HANDLE_EOF
  • If the function fails, it reads false and GetLastError() returns an error code different from ERROR_HANDLE_EOF
2552 {
2553  //FILE * fp = fopen("E:\\Loading.txt", "at");
2554  //if(fp != NULL)
2555  //{
2556  // ULONGLONG ByteOffset = (pByteOffset != NULL) ? pByteOffset[0] : 0;
2557  // fprintf(fp, "%-32ws\t%08X\t%08X\n", GetPlainFileName(pStream->szFileName), (ULONG)ByteOffset, dwBytesToRead);
2558  // fclose(fp);
2559  //}
2560 
2561  assert(pStream->StreamRead != NULL);
2562  return pStream->StreamRead(pStream, pByteOffset, pvBuffer, dwBytesToRead);
2563 }
arena_t NULL
Definition: jemalloc_internal.h:624
STREAM_READ StreamRead
Definition: FileStream.h:156

+ Here is the caller graph for this function:

bool FileStream_Replace ( TFileStream pStream,
TFileStream pNewStream 
)

Switches a stream with another. Used for final phase of archive compacting. Performs these steps:

1) Closes the handle to the existing file 2) Renames the temporary file to the original file, overwrites existing one 3) Opens the file stores the handle and stream position to the new stream structure

pStream Pointer to an open stream pNewStream Temporary ("working") stream (created during archive compacting)

2667 {
2668  // Only supported on flat files
2670  {
2672  return false;
2673  }
2674 
2675  // Not supported on read-only streams
2676  if(pStream->dwFlags & STREAM_FLAG_READ_ONLY)
2677  {
2679  return false;
2680  }
2681 
2682  // Close both stream's base providers
2683  pNewStream->BaseClose(pNewStream);
2684  pStream->BaseClose(pStream);
2685 
2686  // Now we have to delete the (now closed) old file and rename the new file
2687  if(!BaseFile_Replace(pStream, pNewStream))
2688  return false;
2689 
2690  // Now open the base file again
2691  if(!BaseFile_Open(pStream, pStream->szFileName, pStream->dwFlags))
2692  return false;
2693 
2694  // Cleanup the new stream
2695  FileStream_Close(pNewStream);
2696  return true;
2697 }
void SetLastError(int nError)
Definition: Common.cpp:75
STREAM_CLOSE BaseClose
Definition: FileStream.h:175
TCHAR * szFileName
Definition: FileStream.h:182
#define ERROR_ACCESS_DENIED
Definition: CascPort.h:206
#define STREAM_PROVIDER_FLAT
Definition: CascLib.h:50
void FileStream_Close(TFileStream *pStream)
Definition: FileStream.cpp:2707
DWORD dwFlags
Definition: FileStream.h:187
#define BASE_PROVIDER_FILE
Definition: CascLib.h:45
#define ERROR_NOT_SUPPORTED
Definition: CascPort.h:209
#define STREAM_PROVIDERS_MASK
Definition: CascLib.h:61
static bool BaseFile_Replace(TFileStream *pStream, TFileStream *pNewStream)
Definition: FileStream.cpp:358
static bool BaseFile_Open(TFileStream *pStream, const TCHAR *szFileName, DWORD dwStreamFlags)
Definition: FileStream.cpp:91
#define STREAM_FLAG_READ_ONLY
Definition: CascLib.h:56

+ Here is the call graph for this function:

bool FileStream_SetCallback ( TFileStream pStream,
STREAM_DOWNLOAD_CALLBACK  pfnCallback,
void *  pvUserData 
)

Sets a download callback. Whenever the stream needs to download one or more blocks from the server, the callback is called

pStream Pointer to an open stream pfnCallback Pointer to callback function pvUserData Arbitrary user pointer passed to the download callback

2518 {
2519  TBlockStream * pBlockStream = (TBlockStream *)pStream;
2520 
2521  if(pStream->BlockRead == NULL)
2522  {
2524  return false;
2525  }
2526 
2527  pBlockStream->pfnCallback = pfnCallback;
2528  pBlockStream->UserData = pvUserData;
2529  return true;
2530 }
void * UserData
Definition: FileStream.h:199
arena_t NULL
Definition: jemalloc_internal.h:624
BLOCK_READ BlockRead
Definition: FileStream.h:164
void SetLastError(int nError)
Definition: Common.cpp:75
STREAM_DOWNLOAD_CALLBACK pfnCallback
Definition: FileStream.h:197
#define ERROR_NOT_SUPPORTED
Definition: CascPort.h:209
Definition: FileStream.h:195

+ Here is the call graph for this function:

bool FileStream_SetSize ( TFileStream pStream,
ULONGLONG  NewFileSize 
)

Sets the size of a file

pStream Pointer to an open stream NewFileSize File size to set

2608 {
2609  if(pStream->dwFlags & STREAM_FLAG_READ_ONLY)
2610  {
2612  return false;
2613  }
2614 
2615  assert(pStream->StreamResize != NULL);
2616  return pStream->StreamResize(pStream, NewFileSize);
2617 }
arena_t NULL
Definition: jemalloc_internal.h:624
void SetLastError(int nError)
Definition: Common.cpp:75
#define ERROR_ACCESS_DENIED
Definition: CascPort.h:206
STREAM_RESIZE StreamResize
Definition: FileStream.h:158
DWORD dwFlags
Definition: FileStream.h:187
#define STREAM_FLAG_READ_ONLY
Definition: CascLib.h:56

+ Here is the call graph for this function:

bool FileStream_Write ( TFileStream pStream,
ULONGLONG pByteOffset,
const void *  pvBuffer,
DWORD  dwBytesToWrite 
)

This function writes data to the stream

  • Returns true if the write operation succeeded and all bytes have been written
  • Returns false if either write failed or not all bytes have been written
  • If the pByteOffset is NULL, the function must write the data to the current file position

pStream Pointer to an open stream pByteOffset Pointer to file byte offset. If NULL, it reads from the current position pvBuffer Pointer to data to be written dwBytesToWrite Number of bytes to write to the file

2578 {
2579  if(pStream->dwFlags & STREAM_FLAG_READ_ONLY)
2580  {
2582  return false;
2583  }
2584 
2585  assert(pStream->StreamWrite != NULL);
2586  return pStream->StreamWrite(pStream, pByteOffset, pvBuffer, dwBytesToWrite);
2587 }
arena_t NULL
Definition: jemalloc_internal.h:624
void SetLastError(int nError)
Definition: Common.cpp:75
STREAM_WRITE StreamWrite
Definition: FileStream.h:157
#define ERROR_ACCESS_DENIED
Definition: CascPort.h:206
DWORD dwFlags
Definition: FileStream.h:187
#define STREAM_FLAG_READ_ONLY
Definition: CascLib.h:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function: