fwrite_bytesT_fwrite_bytesFwriteBytesFwriteBytesfwrite_bytes (Operator)
Name
fwrite_bytesT_fwrite_bytesFwriteBytesFwriteBytesfwrite_bytes
— Write bytes to a binary file.
Signature
Description
The operator fwrite_bytesfwrite_bytesFwriteBytesFwriteBytesfwrite_bytes
writes bytes to the output
file defined by FileHandleFileHandleFileHandlefileHandlefile_handle
.
The output file must have been opened with open_fileopen_fileOpenFileOpenFileopen_file
in
binary format.
The data to be written to the file is specified as DataToWriteDataToWriteDataToWritedataToWritedata_to_write
.
The number of bytes that are written to the file is returned in
NumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittennumberOfBytesWrittennumber_of_bytes_written
.
Execution Information
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
FileHandleFileHandleFileHandlefileHandlefile_handle
(input_control) file →
HFile, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
File handle.
DataToWriteDataToWriteDataToWritedataToWritedata_to_write
(input_control) integer-array →
HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Data to be written to the file.
NumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittennumberOfBytesWrittennumber_of_bytes_written
(output_control) integer →
HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Number of bytes written to the output
binary file.
Example (HDevelop)
* Write a binary file byte by byte.
open_file (Filename, 'append_binary', FileHandle)
fwrite_bytes(FileHandle, [0x97, 99, 102], BytesWritten)
close_file (FileHandle)
Result
If an output file is open in binary mode and no file write error occurs,
the operator fwrite_bytesfwrite_bytesFwriteBytesFwriteBytesfwrite_bytes
returns 2 (
H_MSG_TRUE)
. Otherwise, an exception is
raised.
Possible Predecessors
open_fileopen_fileOpenFileOpenFileopen_file
Possible Successors
close_fileclose_fileCloseFileCloseFileclose_file
Alternatives
fwrite_stringfwrite_stringFwriteStringFwriteStringfwrite_string
See also
open_fileopen_fileOpenFileOpenFileopen_file
,
close_fileclose_fileCloseFileCloseFileclose_file
,
fread_bytesfread_bytesFreadBytesFreadBytesfread_bytes
Module
Foundation