REDIRECTOPEN

#include "l_bitmap.h"

L_HFILE pEXT_CALLBACK YourOpen(pFile, nMode, nShare, pUserData)

L_TCHAR* pFile;

file name

L_INT nMode;

access mode

L_INT nShare;

share mode

L_VOID* pUserData;

pointer to additional parameters

Replaces the normal LEADTOOLS function for opening a file.

Parameter Description
pFile Character string containing the name of the file to load.
nMode Access mode. LEADTOOLS uses the following definitions for the nMode parameter:
  Constant Meaning
  O_APPEND [0x0008] Repositions the file pointer to the end of the file before every write operation.
  O_BINARY [0x8000] Opens file in binary mode.
  O_CREAT [0x0100] Creates and opens a new file for writing; this has no effect if the file exists.
  O_EXCL [0x0400] Returns an error if the file name exists. Only applies when used with O_CREAT.
  O_RDONLY [0x0000] Opens file for reading only; if this flag is given, neither O_RDWR nor O_WRONLY can be given.
  O_RDWR [0x0002] Open file for both reading and writing; if this flag is given, neither O_RDONLY nor O_WRONLY can be given.
  O_TEXT [0x4000] Open file in text mode.
  O_TRUNC [0x0200] Opens and truncates an existing file to zero length. The contents of the file are destroyed. If this flag is given, you cannot specify O_RDONLY.
  O_WRONLY [0x0001] Opens file for writing only; if this flag is given, neither O_RDONLY nor O_RDWR can be given.
  LEADTOOLS assumes you will open the file as binary, unless the nMode value specifically indicates otherwise. If you use a function that does not open the file as binary by default (ex. _topen) then you should be sure to open the file as binary.
nShare Share mode. The following are valid constants:
  Value Meaning
  S_IREAD [0000400] Opens the file and denies other programs read access to the file. If the file has been opened for read access by any other program, the callback should return an error.
  S_IWRITE [0000200] Opens the file and denies other programs write access to the file. If the file has been opened for write access by any other program, the callback should return an error.
pUserData A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of the calling function.)
  Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

>0

File handle to be used with other I/O functions.

-1

An error occurred.

Comments

For information about using this type of callback, refer to L_RedirectIO.

Required DLLs and Libraries

LTKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

Example

To see how the following function is defined and called, refer to L_RedirectIO. This procedure is a replacement to the built in Open procedure. It returns the number 5 (which looks like a file handle) to indicate that the function was successful.

/************************** Global Declarations **********************************/ 
typedef struct tagUSERDATA 
{ 
   L_INT32 dwSize;              /* Size of the buffer. */ 
   L_INT32 dwUsed;              /* Number of bytes used. */ 
   L_CHAR pData;        /* Pointer to the buffer. */ 
   L_CHAR pCurData;     /* Current pointer location. */ 
} USERDATA, * LPUSERDATA; 
static USERDATA UserData;                      /* Pointer to DATA structure */ 
/***************************************************************************************/ 
L_INT WindowsOpen (const L_TCHAR * pFile, L_INT nMode, 
                                   L_INT nShare) 
{ 
   UNREFERENCED_PARAMETER (pFile); 
   UNREFERENCED_PARAMETER (nMode); 
   UNREFERENCED_PARAMETER (nShare); 
   UserData.pCurData = UserData.pData; 
   UserData.dwUsed = 0; 
   return (5); 
} 

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help