GXBF class¶
- class GXBF(handle=0)[source]¶
GXBF class.
The
GXBF
class is used to access (or create) Binary files and remove (or destroy) files from use. You can also perform a variety of additional tasks, such as positioning within files, reading from files and writing to files.- ch_size(size)[source]¶
Changes the size of a file
- Parameters:
size (int) – New length in bytes
New in version 5.0.
License: Geosoft Open License
- copy(b_fw)[source]¶
Copy entire contents of a source
GXBF
to a destinationGXBF
New in version 5.0.
License: Geosoft Open License
- crc(size, crc)[source]¶
Compute CRC of a file.
- Parameters:
size (int) – Number of bytes to CRC
crc (int) – CRC start (use
CRC_INIT_VALUE
for new)
- Returns:
CRC Value
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- classmethod create(file, status)[source]¶
Create
GXBF
object.- Parameters:
file (str) – File name to open (”” is a temporary file)
status (int) – BF_OPEN_MODE constants
- Returns:
GXBF
Object- Return type:
New in version 5.0.
License: Geosoft Open License
Note: Run-time specific directory paths may be added the the front of file names as follows:
<geosoft> the main Geosoft installation directory <geosoft2> the secondary Geosoft installation directory <geotemp> the Geosoft temporary file directory <windows> the operating system Windows directory <system> the operating system system directory <other> other environment variables
For example “<geosoft>/user/csv/datum.csv”
- classmethod create_sbf(sbf, file, status)[source]¶
Create
GXBF
object inside anGXSBF
.- Parameters:
sbf (GXSBF) – Storage
file (str) – File name to open (”” is a temporary file)
status (int) – BF_OPEN_MODE constants
- Returns:
GXBF
Object- Return type:
New in version 5.0.
License: Geosoft Open License
Note: see sbf.gxh
- eof()[source]¶
Returns 1 if at the end of the file
- Returns:
1 if at the end of the file, 0 if not at the end of the file
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- is_null()[source]¶
Check if this is a null (undefined) instance
- Returns:
True if this is a null (undefined) instance, False otherwise.
- Return type:
bool
- query_write()[source]¶
Check if you can write to the
GXBF
.- Returns:
0 - No 1 - Yes
- Return type:
int
New in version 5.1.1.
License: Geosoft Open License
- read_binary_string(bytes, encoding, data)[source]¶
Reads string data from current position in
GXBF
- Parameters:
bytes (int) – Number of bytes to read
encoding (int) – BF_ENCODE constants
data (str_ref) – Data
New in version 6.3.
License: Geosoft Open License
- read_double(type, data)[source]¶
Reads real data from current position in
GXBF
- Parameters:
type (int) – GS_TYPES constants and BF_BYTEORDER constants
data (float_ref) – Data
New in version 5.0.
License: Geosoft Open License
Note: If the data source may be in byte order different from that required by the reader, you can add the source byte-order to the
GXBF
elelment type. The byte order will be swapped if required. For example, to write out a real number 3.5 with Most-Significant_Byte first (Mortorola) convention:write_double
,3.5).If a byte order is not specified, the source is assumed to be in the native byte order of the reading/writing computer.
- read_int(type, data)[source]¶
Reads int data from current position in
GXBF
- Parameters:
type (int) – GS_TYPES constants and BF_BYTEORDER constants
data (int_ref) – Data
New in version 5.0.
License: Geosoft Open License
Note: If the data source may be in byte order different from that required by the reader, you can add the source byte-order to the
GXBF
elelment type. The byte order will be swapped if required. For example, to write out a real number 3.5 with Most-Significant_Byte first (Mortorola) convention:write_double
,3.5).If a byte order is not specified, the source is assumed to be in the native byte order of the reading/writing computer.
- read_vv(type, vv)[source]¶
Read data to a
GXVV
from current position inGXBF
- Parameters:
type (int) – GS_TYPES constants and BF_BYTEORDER constants
New in version 5.0.
License: Geosoft Open License
Note: If the data source may be in byte order different from that required by the reader, you can add the source byte-order to the
GXBF
elelment type. The byte order will be swapped if required. For example, to write out a real number 3.5 with Most-Significant_Byte first (Mortorola) convention:write_double
,3.5).If a byte order is not specified, the source is assumed to be in the native byte order of the reading/writing computer.
- seek(offset, ref)[source]¶
Moves file position
- Parameters:
offset (int) – Number of bytes from reference point
ref (int) – BF_SEEK constants
New in version 5.0.
License: Geosoft Open License
Note: Terminates if attempt to move past the end of a read-only file.
- set_destroy_status(status)[source]¶
Set the flag to delete the file on close
- Parameters:
status (int) – BF_CLOSE constants
New in version 6.0.
License: Geosoft Open License
- size()[source]¶
Returns the file length
- Returns:
File size in bytes.
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- tell()[source]¶
Returns current position of file pointer in bytes
- Returns:
Current file pointer location
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- write_binary_string(encoding, data)[source]¶
Write a binary string to a
GXBF
- Parameters:
encoding (int) – BF_ENCODE constants
data (str) – String to write out
New in version 6.3.
License: Geosoft Open License
- write_data_null()[source]¶
Writes a null byte (0) to
GXBF
New in version 5.0.
License: Geosoft Open License
- write_double(type, data)[source]¶
Writes real to the
GXBF
- Parameters:
type (int) – GS_TYPES constants and BF_BYTEORDER constants
data (float) – Data
New in version 5.0.
License: Geosoft Open License
Note: See comments on byte order for the Read.. functions if you want to enforce a certain byte order.
If a byte order is not specified, the data is written in the native byte order of the writing computer.
- write_int(type, data)[source]¶
Writes int to the
GXBF
- Parameters:
type (int) – GS_TYPES constants and BF_BYTEORDER constants
data (int) – Data
New in version 5.0.
License: Geosoft Open License
Note: See comments on byte order for the Read.. functions if you want to enforce a certain byte order.
If a byte order is not specified, the data is written in the native byte order of the writing computer.
- write_vv(type, vv)[source]¶
-
- Parameters:
type (int) – GS_TYPES constants and BF_BYTEORDER constants
vv (GXVV) – Data
New in version 5.0.
License: Geosoft Open License
Note: See comments on byte order for the Read.. functions if you want to enforce a certain byte order.
If a byte order is not specified, the data is written in the native byte order of the writing computer.
BF_BYTEORDER constants¶
Byte order for read/write
BF_CLOSE constants¶
Close Flags
BF_ENCODE constants¶
The way a string is encoded
- BF_ENCODE_UTF8¶
String is stored as UTF8 constants
- gxapi.BF_ENCODE_UTF8 = 1¶
BF_OPEN_MODE constants¶
Open Status
BF_SEEK constants¶
Seek Location