Click or drag to resize

FCommit Function

X#
Flush file buffers.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION FCommit(
	ptrHandle AS IntPtr
) AS LOGIC
Request Example View Source

Parameters

ptrHandle
Type: IntPtr
The handle of the open file you want to flush.

Return Value

Type: Logic
Remarks
FCommit() writes to a file the contents of its buffers.
If files are being shared in a multi-user or multi-tasking environment, FCommit() is helpful in allowing each user to see the latest contents of the file.
The disk-write also protects you against possible data loss due to a system crash.
Remarks
Tip Tip
The low level File IO functions in the X# runtime are using .Net filestreams in the background.
That means that the file handles returned by FOpen() and FCreate() are not 'normal' file handles, but unique identifiers that are used to find the underlying stream object in a collection of streams in the runtime.
That also means that you can't use file handles for functions such as FRead() and FWrite() that were not created in the X# runtime.
If you want to access the underlying FileStream, then you should call the function FGetStream(IntPtr)
Examples
This example uses FCommit() to ensure that buffers are written to the disk:
X#
1LOCAL ptrFile AS PTR
2ptrFile := FOpen2("myfile.txt", F0_READWRITE + FO_SHARED)
3FWrite3(ptrFile, Space(550), 550)
4// Keep other users/tasks updated
5FCommit(ptrFile)
See Also