REDIRECTWRITE

Summary

Replaces the normal LEADTOOLS function for writing a file.

Syntax

#include "l_bitmap.h"

L_UINT pEXT_CALLBACK YourWrite (nFd, pBuf, uCount, pUserData)

Parameters

L_HFILE nFd

Identifies the file to be written. The file handle is returned by the REDIRECTOPEN callback function.

L_UCHAR* pBuf

Points to a buffer that contains data to be written to the file.

L_UINT uCount

Specifies the number of bytes to be written to the file.

L_VOID* 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

Value Meaning
>0 The number of bytes that the function wrote to the file.
-1 The function failed.

Comments

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

When uCount is 0, the file should be truncated. That is, mark the current write position as the last position in the file. Please note that previous operating system write functions automatically truncated a file when 0 bytes were written. However, the WIN32 WriteFile function does not truncate the file.

Required DLLs and Libraries

Example

For how the following function is defined and called, refer to L_RedirectIO.
This procedure is a replacement to the built in Write procedure.
In this example no I/O operation will be done, so we do nothing.

L_UINT  WindowsWrite (L_INT FD, L_CHAR  * pBuf, L_UINT uCount) 
{ 
   UNREFERENCED_PARAMETER (FD); 
   UNREFERENCED_PARAMETER (pBuf); 
   return (uCount); 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.