Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Cahute 0.6
Logo
Cahute 0.6
  • Installation guides
    • Installing Cahute on Linux distributions
    • Installing Cahute on macOS / OS X
    • Installing Cahute on Microsoft Windows
    • Installing Cahute on AmigaOS
  • Build from source guides
    • Building Cahute for Linux distributions
    • Building Cahute for macOS / OS X
    • Building Cahute for Microsoft Windows
    • Building Cahute for AmigaOS
  • Contribution guides
    • Contributing to Cahute
    • Reporting a bug or vulnerability
    • Requesting a feature
    • Packaging Cahute
    • Creating a merge request
  • Command line user guides
    • Getting information regarding a calculator
    • Sending a file to a calculator’s storage memory
    • Getting a file from the calculator’s storage memory
    • Displaying the screen from a calculator
  • Developer guides
    • Building with the Cahute library
    • Using device detection
      • Listing calculators connected by USB
      • Listing available serial ports
    • Using links
      • Opening a link to a calculator connected by USB
      • Opening a generic link to a calculator connected by serial
    • Reading and writing files
      • Guessing the type of a file
    • Using text conversion utilities
      • Converting text from an encoding to another
  • Miscellaneous guides
    • Getting started with Cahute in Visual Studio
    • Capturing USB communications on Windows using Wireshark
  • Data formats
    • Number formats
    • Picture formats
    • Text encodings
    • File formats
      • fx-CG add-ins
      • fx-9860G add-ins
      • Calculator Text Format (CTF)
      • CASIOLINK archives
      • casrc configuration file
      • Catalog files (CAT)
      • e-Activity files
      • fx-CG f-key files
      • fx-9860G f-key files
      • FX Program (FXP)
      • GraphCard file format
      • fx-CG language files
      • fx-9860G language files
      • Main memory archives
      • fx-CG picture
      • fx-CP picture
  • Communication protocols
    • Rationales behind the communication protocols
    • Transport medium and protocols
    • USB detection for CASIO calculators
    • CASIOLINK protocols – Serial protocols used by pre fx-9860G calculators
    • CAS40 protocol – Serial protocol used by pre-1996 calculators
      • CAS40 packet format
      • CAS40 data types
      • CAS40 flows
    • CAS50 protocol – Serial protocol used by calculators from 1996 to 2004
      • CAS50 packet format
      • CAS50 data types
      • CAS50 flows
    • CAS100 protocol – Serial protocol used by AFX / Graph 100
      • CAS100 packet format
      • CAS100 data types
      • CAS100 flows
    • CAS300 – Serial and USB protocol used by Classpad 300 / 330 (+)
      • CAS300 packet format
      • CAS300 commands
      • CAS300 flows
    • Protocol 7.00 – Serial and USB protocol used by post fx-9860G calculators
      • Specific formats for Protocol 7.00
      • Protocol 7.00 packet format
      • Protocol 7.00 communication flows
      • Known Protocol 7.00 commands by CASIO
      • Known Protocol 7.00 command extensions in fxRemote
      • Protocol 7.00 use cases
      • Known hardware identifiers for Protocol 7.00
    • Protocol 7.00 Screenstreaming – fx-9860G and fx-CG screenstreaming
      • Protocol 7.00 Screenstreaming packet format
      • Protocol 7.00 Screenstreaming communication flows
    • USB Mass Storage (UMS)
  • Cahute features
    • System compatibility
    • Contexts
    • Links and mediums
    • Files
    • Main memory data
    • Logging facilities
  • Cahute internals
    • Internal compatibility utilities
    • Links and medium internals
    • File internals
    • Characters, encodings and conversions
  • Command line reference
    • CaS command-line reference
    • p7 command line reference
    • p7os command line reference
    • p7screen command line reference
    • xfer9860 command line reference
  • Header reference
    • <cahute.h> – Main header for Cahute
      • <cahute/cdefs.h> – Basic definitions for Cahute
      • <cahute/config.h> – Cahute configuration details
      • <cahute/context.h> – Context management for Cahute
      • <cahute/data.h> – Calculator data resource and methods for Cahute
      • <cahute/detection.h> – Device detection for Cahute
      • <cahute/error.h> – Error definitions for Cahute
      • <cahute/file.h> – File related utilities for Cahute
      • <cahute/link.h> – Calculator link resource and methods for Cahute
      • <cahute/logging.h> – Logging control for Cahute
      • <cahute/path.h> – Path related utilities for Cahute
      • <cahute/picture.h> – Picture format related utilities for Cahute
      • <cahute/text.h> – Text encoding related utilities for Cahute
  • CMake setting reference
  • Project management
    • Project governance
    • Git and release versioning
    • Community feedback
    • Contribution style
    • Coding style
Back to top

<cahute/file.h> – File related utilities for Cahute¶

Macro definitions¶

CAHUTE_FILE_TYPE_* are constants representing the type of an opened file.

CAHUTE_FILE_TYPE_ADDIN_CG¶

fx-CG add-in; see fx-CG add-ins for more information.

CAHUTE_FILE_TYPE_ADDIN_FX¶

fx add-in; see fx-9860G add-ins for more information.

CAHUTE_FILE_TYPE_CASIOLINK¶

CASIOLINK archive, that can be used as a main memory archive; see CASIOLINK archives for more information.

CAHUTE_FILE_TYPE_EACT_FX¶

fx e-Activity; see e-Activity files for more information.

CAHUTE_FILE_TYPE_FKEY_FX¶

fx function keys file; see fx-9860G f-key files for more information.

CAHUTE_FILE_TYPE_FKEY_CG¶

fx-CG function keys file; see fx-CG f-key files for more information.

CAHUTE_FILE_TYPE_LANG_CG¶

fx-CG language file; see fx-CG language files for more information.

CAHUTE_FILE_TYPE_LANG_FX¶

fx language file; see fx-9860G language files for more information.

CAHUTE_FILE_TYPE_MAINMEM¶

fx main memory archive; see Main memory archives for more information.

CAHUTE_FILE_TYPE_PICTURE_CG¶

fx-CG picture; see fx-CG picture for more information.

CAHUTE_FILE_TYPE_PICTURE_CP¶

fx-CP picture; see fx-CP picture for more information.

Type definitions¶

struct cahute_file¶

Opened file for reading or writing.

This type is opaque, and such resources must be created using cahute_open_file().

Function declarations¶

int cahute_open_file(cahute_context *context, cahute_file **filep, void const *path, int path_type)¶

Open a file from a path, in order to read it.

Parameters:
  • context – Context in which to open the file.

  • filep – Pointer to the file object to create.

  • path – Path to the file to open, with the file type.

  • path_type – Type of the path to the file to open.

Returns:

Error, or 0 if the operation was successful.

int cahute_create_file(cahute_context *context, cahute_file **filep, size_t size, void const *path, int path_type)¶

Create a file at a path, in order to write its content.

Parameters:
  • context – Context in which to create and open the file.

  • filep – Pointer to the file object to create.

  • size – Size of the file to create or open.

  • path – Path to the file to open, with the file type.

  • path_type – Type of the path to the file to create or open.

Returns:

Error, or 0 if the operation was successful.

int cahute_open_stdout(cahute_context *context, cahute_file **filep)¶

Open standard output as a file, in order to write to it.

Warning

A file obtained through this method must be closed using cahute_close_file(), just like files opened using cahute_open_file(). It will always return a new file instance.

Parameters:
  • context – Context in which to open the standard output.

  • filep – Pointer to the file object to create.

Returns:

Error, or 0 if the operation was successful.

int cahute_get_file_size(cahute_file *file, unsigned long *sizep)¶

Get the total size of the file.

Parameters:
  • file – File object.

  • sizep – Pointer to the integer to set with the file size.

Returns:

Error, or 0 if the operation was successful.

int cahute_read_from_file(cahute_file *file, unsigned long off, void *buf, size_t size)¶

Read from the file starting at a given offset.

Parameters:
  • file – File object.

  • off – Offset at which to read.

  • buf – Buffer in which to write the resulting data.

  • size – Size of the data to read.

Returns:

Error, or 0 if the operation was successful.

int cahute_write_to_file(cahute_file *file, unsigned long off, void const *data, size_t size)¶

Write to the file starting at a given offset.

Parameters:
  • file – File object.

  • off – Offset at which to read.

  • buf – Buffer in which to write the resulting data.

  • size – Size of the data to read.

Returns:

Error, or 0 if the operation was successful.

int cahute_guess_file_type(cahute_file *file, int *typep)¶

Get the type of a file, in order to read it.

Parameters:
  • file – File object.

  • typep – Value to define with the determined type for the file.

Returns:

Error, or 0 if the operation was successful.

int cahute_get_data_from_file(cahute_file *file, cahute_data **datap);¶

Decode data from a file opened for reading.

Parameters:
  • file – File object.

  • datap – Pointer to the data to create.

Returns:

Error, or 0 if the operation was successful.

void cahute_close_file(cahute_file *file)¶

Close a file.

Parameters:
  • file – File object to close.

Next
<cahute/link.h> – Calculator link resource and methods for Cahute
Previous
<cahute/error.h> – Error definitions for Cahute
Copyright © 2024, Thomas Touhey
Made with Sphinx and @pradyunsg's Furo
On this page
  • <cahute/file.h> – File related utilities for Cahute
    • Macro definitions
    • Type definitions
    • Function declarations