extractToFileDirect

extractToFileDirect(fileName:     String;
                    allowReplace: Boolean);

The extractToFileDirect method of the JadeBytes class extracts the binary content of the receiver to the file specified by the value of the fileName parameter, which must be a valid file name for the machine running the server node.

The value of the allowReplace parameter determines whether an existing file with the same name can be replaced.

This method raises an exception if the receiver is not a singleFile instance.

If the logical length of the receiver is zero, the output file is not created.

The copy operation uses a fast operating system file copy method when the physical file length matches the logical length; otherwise a read/write loop is used, followed by a loop to write nulls to pad the new file to the logical length.

This non-updating method must be executed in transaction state so that the server can avoid blocking other users of singleFile instances while the copy operation is in progress.

The following example shows the use of the extractToFileDirect method.

vars
    bytes : MyJadeBytes;
begin
    beginTransaction;
    create bytes persistent;
    bytes.singleFile := true;
    bytes.setContent("JADE".Binary);
    bytes.extractToFileDirect("c:\example.txt", true);
epilog
    abortTransaction;
end;