![]() |
![]() |
![]() |
libInstPatch Reference Manual | ![]() |
---|---|---|---|---|
IpatchFileIOFuncs; IpatchFileBuf; IpatchFile; IpatchFileClass; #define IPATCH_FILE_UNUSED_FLAG_SHIFT #define IPATCH_FILE_IS_OPEN (file) #define IPATCH_FILE_NEED_SWAP (file) #define IPATCH_FILE_BIG_ENDIAN (file) #define IPATCH_FILE_SWAP16 (file, p16) #define IPATCH_FILE_SWAP32 (file, p32) #define IPATCH_FILE_SWAP64 (file, p64) IpatchFile* ipatch_file_new (void); void ipatch_file_set_name (IpatchFile *file, const char *file_name); char* ipatch_file_get_name (IpatchFile *file); gboolean ipatch_file_open (IpatchFile *file, const char *file_name, const char *mode, GError **err); gboolean ipatch_file_open_with_fd (IpatchFile *file, int fd, GError **err); gboolean ipatch_file_open_with_io_channel (IpatchFile *file, GIOChannel *iochan, GError **err); GIOChannel* ipatch_file_ref_io_channel (IpatchFile *file); int ipatch_file_get_fd (IpatchFile *file); gboolean ipatch_file_is_open (IpatchFile *file); void ipatch_file_close (IpatchFile *file); int ipatch_file_get_position (IpatchFile *file); void ipatch_file_update_position (IpatchFile *file, int offset); gboolean ipatch_file_read (IpatchFile *file, gpointer buf, guint size, GError **err); GIOStatus ipatch_file_read_eof (IpatchFile *file, gpointer buf, guint size, guint *bytes_read, GError **err); gboolean ipatch_file_write (IpatchFile *file, gconstpointer buf, guint size, GError **err); #define ipatch_file_skip (file, offset, err) gboolean ipatch_file_seek (IpatchFile *file, int offset, GSeekType type, GError **err); GIOStatus ipatch_file_seek_eof (IpatchFile *file, int offset, GSeekType type, GError **err); GType ipatch_file_identify (IpatchFile *file, GError **err); IpatchFile* ipatch_file_identify_open (const char *file_name, const char *mode, GError **err); IpatchFile* ipatch_file_convert_type (IpatchFile *file, GType new_type); void ipatch_file_set_little_endian (IpatchFile *file); void ipatch_file_set_big_endian (IpatchFile *file); gboolean ipatch_file_read_u8 (IpatchFile *file, guint8 *val, GError **err); gboolean ipatch_file_read_u16 (IpatchFile *file, guint16 *val, GError **err); gboolean ipatch_file_read_u32 (IpatchFile *file, guint32 *val, GError **err); gboolean ipatch_file_read_u64 (IpatchFile *file, guint64 *val, GError **err); gboolean ipatch_file_read_s8 (IpatchFile *file, gint8 *val, GError **err); gboolean ipatch_file_read_s16 (IpatchFile *file, gint16 *val, GError **err); gboolean ipatch_file_read_s32 (IpatchFile *file, gint32 *val, GError **err); gboolean ipatch_file_read_s64 (IpatchFile *file, gint64 *val, GError **err); gboolean ipatch_file_write_u8 (IpatchFile *file, guint8 val, GError **err); gboolean ipatch_file_write_u16 (IpatchFile *file, guint16 val, GError **err); gboolean ipatch_file_write_u32 (IpatchFile *file, guint32 val, GError **err); gboolean ipatch_file_write_u64 (IpatchFile *file, guint64 val, GError **err); gboolean ipatch_file_write_s8 (IpatchFile *file, gint8 val, GError **err); gboolean ipatch_file_write_s16 (IpatchFile *file, gint16 val, GError **err); gboolean ipatch_file_write_s32 (IpatchFile *file, gint32 val, GError **err); gboolean ipatch_file_write_s64 (IpatchFile *file, gint64 val, GError **err); void ipatch_file_buf_init (IpatchFile *file, IpatchFileBuf *filebuf, gpointer buf, guint size); void ipatch_file_buf_free (IpatchFileBuf *filebuf); gboolean ipatch_file_buf_load (IpatchFileBuf *filebuf, guint size, GError **err); void ipatch_file_buf_read (IpatchFileBuf *filebuf, gpointer buf, guint size); void ipatch_file_buf_write (IpatchFileBuf *filebuf, gconstpointer buf, guint size); #define ipatch_file_buf_zero (filebuf, size) gboolean ipatch_file_buf_commit (IpatchFileBuf *filebuf, GError **err); #define ipatch_file_buf_skip (filebuf, offset) void ipatch_file_buf_seek (IpatchFileBuf *filebuf, int offset, GSeekType type); guint8 ipatch_file_buf_read_u8 (IpatchFileBuf *filebuf); guint16 ipatch_file_buf_read_u16 (IpatchFileBuf *filebuf); guint32 ipatch_file_buf_read_u32 (IpatchFileBuf *filebuf); guint64 ipatch_file_buf_read_u64 (IpatchFileBuf *filebuf); gint8 ipatch_file_buf_read_s8 (IpatchFileBuf *filebuf); gint16 ipatch_file_buf_read_s16 (IpatchFileBuf *filebuf); gint32 ipatch_file_buf_read_s32 (IpatchFileBuf *filebuf); gint64 ipatch_file_buf_read_s64 (IpatchFileBuf *filebuf); void ipatch_file_buf_write_u8 (IpatchFileBuf *filebuf, guint8 val); void ipatch_file_buf_write_u16 (IpatchFileBuf *filebuf, guint16 val); void ipatch_file_buf_write_u32 (IpatchFileBuf *filebuf, guint32 val); void ipatch_file_buf_write_u64 (IpatchFileBuf *filebuf, guint64 val); void ipatch_file_buf_write_s8 (IpatchFileBuf *filebuf, gint8 val); void ipatch_file_buf_write_s16 (IpatchFileBuf *filebuf, gint16 val); void ipatch_file_buf_write_s32 (IpatchFileBuf *filebuf, gint32 val); void ipatch_file_buf_write_s64 (IpatchFileBuf *filebuf, gint64 val); void ipatch_file_set_iofuncs_static (IpatchFile *file, IpatchFileIOFuncs *funcs); void ipatch_file_set_iofuncs (IpatchFile *file, const IpatchFileIOFuncs *funcs); void ipatch_file_get_iofuncs (IpatchFile *file, IpatchFileIOFuncs *out_funcs); void ipatch_file_set_iofuncs_null (IpatchFile *file); gboolean ipatch_file_default_open_method (IpatchFile *file, const char *mode, GError **err); void ipatch_file_default_close_method (IpatchFile *file); GIOStatus ipatch_file_default_read_method (IpatchFile *file, gpointer buf, guint size, guint *bytes_read, GError **err); GIOStatus ipatch_file_default_write_method (IpatchFile *file, gconstpointer buf, guint size, GError **err); GIOStatus ipatch_file_default_seek_method (IpatchFile *file, int offset, GSeekType type, GError **err); int ipatch_file_default_getfd_method (IpatchFile *file);
GObject +----IpatchItem +----IpatchFile +----IpatchSampleFile +----IpatchDLSFile +----IpatchSF2File +----IpatchCramFile
"close-on-finalize" gboolean : Read / Write "file-name" gchararray : Read / Write "open" gboolean : Read
An object for sharing open files and also a base class for specific file types. This object provides file reference counting, multi-thread friendly IO functions, endian byte swapping, and file identification using actual file data and file extensions.
typedef struct { gboolean (*open)(IpatchFile *file, const char *mode, GError **err); void (*close)(IpatchFile *file); GIOStatus (*read)(IpatchFile *file, gpointer buf, guint size, guint *bytes_read, GError **err); GIOStatus (*write)(IpatchFile *file, gconstpointer buf, guint size, GError **err); GIOStatus (*seek)(IpatchFile *file, int offset, GSeekType type, GError **err); int (*getfd)(IpatchFile *file); /* optional get file descriptor method */ int (*get_size)(IpatchFile *file, GError **err); /* optional get size method */ } IpatchFileIOFuncs;
typedef struct { IpatchFile *file; /* the file loading/saving from/to */ gpointer buf; /* the data buffer */ int pos; /* current position in buffer */ int buf_size; /* total buffer size */ int data_size; /* data size */ gboolean allocated; /* set if buffer was allocated */ } IpatchFileBuf;
typedef struct { IpatchItemClass parent_class; /* signals */ void (*pos_change)(IpatchFile *file, gint32 offset); /* methods */ gboolean (*identify)(IpatchFile *file); } IpatchFileClass;
#define IPATCH_FILE_UNUSED_FLAG_SHIFT (IPATCH_ITEM_UNUSED_FLAG_SHIFT + 8)
IpatchFile* ipatch_file_new (void);
Create a new file object
Returns : | The new file object |
void ipatch_file_set_name (IpatchFile *file, const char *file_name);
Sets the file name of a file object. The file name of a file object
should not be relied apon as referencing the same file as the file object
itself. It is used for information purposes only and with the
ipatch_file_open()
and ipatch_file_identify()
functions.
file : |
File object to assign file name to |
file_name : |
File name or NULL to unset the file name
|
char* ipatch_file_get_name (IpatchFile *file);
Gets the assigned file name from a file object.
file : |
File object to get file name from |
Returns : | The file name of the file object or NULL if not set. String
should be freed when finished with it.
|
gboolean ipatch_file_open (IpatchFile *file, const char *file_name, const char *mode, GError **err);
Opens a file and assigns it to a file object. The file will be closed when the IpatchFile object is destroyed, unless the "close-on-finalize" flag is cleared.
file : |
File object to open from a file name. |
file_name : |
Name of file to open or NULL to use the file object's assigned
file name (in which case should not be NULL ).
|
mode : |
File open mode ("r", "w", etc) see g_io_channel_new_file() or
fopen() for more info
|
err : |
Error information |
Returns : | TRUE on success, FALSE otherwise in which case error information
should be found in err provided its not NULL.
|
gboolean ipatch_file_open_with_fd (IpatchFile *file, int fd, GError **err);
An alternative to ipatch_file_open()
to use an existing open file
descriptor. The "close-on-finalize" flag is not set, so the file will
remain open after the IpatchFile object is destroyed.
gboolean ipatch_file_open_with_io_channel (IpatchFile *file, GIOChannel *iochan, GError **err);
Sets a file object's io channel directly and increments its
reference count. An alternative to ipatch_file_open()
and
ipatch_file_open_with_fd()
when using a custom or existing io channel.
The "close-on-finalize" flag is not set, so the io channel will remain
open even after the IpatchFile is destroyed.
GIOChannel* ipatch_file_ref_io_channel (IpatchFile *file);
Get the glib IO channel object from a file object. The caller owns a
reference to the returned io channel, and should be unreferenced with
g_io_channel_unref()
when finished with it.
MT-NOTE: Use of the io channel directly subverts multi-thread locking.
Caller is responsible for locking the file
item during any operations
using the io channel, if necessary.
file : |
File object to get io channel object from |
Returns : | GIOChannel assigned to the file object or NULL if none (some
derived IpatchFile types might not use io channels). Remember to unref it
with g_io_channel_unref() when finished.
|
int ipatch_file_get_fd (IpatchFile *file);
Get the unix file descriptor associated with a file object. Not all file objects have a file descriptor.
file : |
File object |
Returns : | File descriptor or -1 if not open or failed to get descriptor. |
gboolean ipatch_file_is_open (IpatchFile *file);
Checks if a file object is open.
void ipatch_file_close (IpatchFile *file);
Close a file object.
file : |
File to close |
int ipatch_file_get_position (IpatchFile *file);
Gets the value of the position counter in a file object. Note that this
might not be the actual position in the file if the file object was
attached to an already open file or if ipatch_file_update_position()
is
used to set virtual positions.
file : |
File object |
Returns : | Value of position counter in file object. |
void ipatch_file_update_position (IpatchFile *file, int offset);
Adds an offset value to the position counter in a file object. This can be used if one is operating directly on the underlying file object (i.e., not using the IpatchFile functions) or to add virtual space to the counter. Adding virtual space is useful when a system uses the position counter to write data (such as the RIFF parser) to act as a place holder for data that isn't actually written (sample data for example).
file : |
File object |
offset : |
Offset to add to the position counter (can be negative) |
gboolean ipatch_file_read (IpatchFile *file, gpointer buf, guint size, GError **err);
Reads data from a file object. An end of file encountered while
trying to read the specified size
of data is treated as an error.
If this is undesirable use ipatch_file_read_eof()
instead.
GIOStatus ipatch_file_read_eof (IpatchFile *file, gpointer buf, guint size, guint *bytes_read, GError **err);
Reads data from a file object. This function does not treat end of file
as an error and will return G_IO_STATUS_EOF with the number of bytes
actually read in bytes_read
. Use ipatch_file_read()
for convenience to
ensure actual number of requested bytes is read.
gboolean ipatch_file_write (IpatchFile *file, gconstpointer buf, guint size, GError **err);
Writes data to a file object.
file : |
File object |
buf : |
Buffer of data to write |
size : |
Amount of data to write, in bytes. |
err : |
A location to return an error of type GIOChannelError or NULL .
|
Returns : | The status of the operation |
gboolean ipatch_file_seek (IpatchFile *file, int offset, GSeekType type, GError **err);
Seek in a file object. An end of file condition is treated as an error, use
ipatch_file_seek_eof()
if this is undesirable.
file : |
File object to seek in |
offset : |
Offset in bytes to seek from the position specified by type
|
type : |
Position in file to seek from (see g_io_channel_seek_position for more details, only G_SEEK_CUR and G_SEEK_SET allowed). |
err : |
A location to return error info or NULL .
|
Returns : | TRUE on success, FALSE otherwise
|
GIOStatus ipatch_file_seek_eof (IpatchFile *file, int offset, GSeekType type, GError **err);
Seek in a file object. Does not treat end of file as an error, use
ipatch_file_seek()
for convenience if this is desirable.
file : |
File object to seek in |
offset : |
Offset in bytes to seek from the position specified by type
|
type : |
Position in file to seek from (see g_io_channel_seek_position for more details, only G_SEEK_CUR and G_SEEK_SET allowed). |
err : |
A location to return error info or NULL .
|
Returns : | The status of the operation |
GType ipatch_file_identify (IpatchFile *file, GError **err);
Attempts to identify the type of a file using the "identify" method of
registered types derived from IpatchFile. If the file object is open then
the "identify" methods may check the content of the file itself, otherwise
the extension of the file object's assigned file name is used. In the latter
case the assigned file name should not be NULL
.
file : |
File object to identify type of |
err : |
Location to store error information |
Returns : | The first IpatchFile derived type that had an "identify" method
which returned TRUE , or 0 if unknown file type or error, in which
case error information will be stored in err provided its not NULL .
|
IpatchFile* ipatch_file_identify_open (const char *file_name, const char *mode, GError **err);
Calls ipatch_file_identify()
to determine the file type of
file_name
. If the type is identified a new file object, of the
identified type, is created and the file is opened with
ipatch_file_open()
using mode
. A convenience function really.
file_name : |
File name to identify and open |
mode : |
Mode to open file with (if it is identified) |
err : |
Location to store error of type GIOChannelError |
Returns : | The new file object of the identified type or NULL if unable to
identify.
|
IpatchFile* ipatch_file_convert_type (IpatchFile *file, GType new_type);
Converts an open file to another IpatchFile type. After a successful
call to this function the original file
will be unset (won't reference
the actual file descriptor anymore) and the returned file will have taken
it over.
file : |
File to convert to a new file type |
new_type : |
New IpatchFile derived type |
Returns : | a new file with a refcount of 1. |
void ipatch_file_set_little_endian (IpatchFile *file);
Sets the file object to little endian mode (the default mode). If the system is big endian, byte swapping will be enabled (see IPATCH_FILE_SWAPxx macros). The endian mode affects buffered read and write functions that operate on multi-byte integers.
file : |
File object |
void ipatch_file_set_big_endian (IpatchFile *file);
Sets the file object to big endian mode (the default is little endian). If the system is little endian, byte swapping will be enabled (see IPATCH_FILE_SWAPxx macros). The endian mode affects buffered read and write functions that operate on multi-byte integers.
file : |
File object |
gboolean ipatch_file_read_u8 (IpatchFile *file, guint8 *val, GError **err);
Read an unsigned 8 bit integer from a file.
gboolean ipatch_file_read_u16 (IpatchFile *file, guint16 *val, GError **err);
Read an unsigned 16 bit integer from a file and performs endian byte swapping if necessary.
gboolean ipatch_file_read_u32 (IpatchFile *file, guint32 *val, GError **err);
Read an unsigned 32 bit integer from a file and performs endian byte swapping if necessary.
gboolean ipatch_file_read_u64 (IpatchFile *file, guint64 *val, GError **err);
Read an unsigned 64 bit integer from a file and performs endian byte swapping if necessary.
gboolean ipatch_file_read_s8 (IpatchFile *file, gint8 *val, GError **err);
Read a signed 8 bit integer from a file.
gboolean ipatch_file_read_s16 (IpatchFile *file, gint16 *val, GError **err);
Read a signed 16 bit integer from a file and performs endian byte swapping if necessary.
gboolean ipatch_file_read_s32 (IpatchFile *file, gint32 *val, GError **err);
Read a signed 32 bit integer from a file and performs endian byte swapping if necessary.
gboolean ipatch_file_read_s64 (IpatchFile *file, gint64 *val, GError **err);
Read a signed 64 bit integer from a file and performs endian byte swapping if necessary.
gboolean ipatch_file_write_u8 (IpatchFile *file, guint8 val, GError **err);
Write an unsigned 8 bit integer to a file.
gboolean ipatch_file_write_u16 (IpatchFile *file, guint16 val, GError **err);
Write an unsigned 16 bit integer to a file and performs endian byte swapping if necessary.
gboolean ipatch_file_write_u32 (IpatchFile *file, guint32 val, GError **err);
Write an unsigned 32 bit integer to a file and performs endian byte swapping if necessary.
gboolean ipatch_file_write_u64 (IpatchFile *file, guint64 val, GError **err);
Write an unsigned 64 bit integer to a file and performs endian byte swapping if necessary.
gboolean ipatch_file_write_s8 (IpatchFile *file, gint8 val, GError **err);
Write a signed 8 bit integer to a file.
gboolean ipatch_file_write_s16 (IpatchFile *file, gint16 val, GError **err);
Write a signed 16 bit integer to a file and performs endian byte swapping if necessary.
gboolean ipatch_file_write_s32 (IpatchFile *file, gint32 val, GError **err);
Write a signed 32 bit integer to a file and performs endian byte swapping if necessary.
gboolean ipatch_file_write_s64 (IpatchFile *file, gint64 val, GError **err);
Write a signed 64 bit integer to a file and performs endian byte swapping if necessary.
void ipatch_file_buf_init (IpatchFile *file, IpatchFileBuf *filebuf, gpointer buf, guint size);
Initializes a file buffer structure for use in buffered read and write
operations. If this function is called with filebuf
set to NULL
the
buffer will be allocated and should be freed at a later time with
ipatch_file_buf_free()
.
void ipatch_file_buf_free (IpatchFileBuf *filebuf);
Frees the data buffer of a file buffer structure. Not necessary to call this function if the file buffer was initialized with a user supplied data buffer, but won't break if you do.
filebuf : |
File buffer structure |
gboolean ipatch_file_buf_load (IpatchFileBuf *filebuf, guint size, GError **err);
Load data from a file file into a buffer for convenient parsing.
void ipatch_file_buf_read (IpatchFileBuf *filebuf, gpointer buf, guint size);
Read data from a file buffer and advance the buffer's current position.
filebuf : |
Initialized file buffer structure with loaded data |
buf : |
Buffer to copy data to |
size : |
Amount of data to copy in bytes |
void ipatch_file_buf_write (IpatchFileBuf *filebuf, gconstpointer buf, guint size);
Write data to a file buffer and advance the buffer's current position. Caller is responsible for ensuring there is enough space in the file buffer.
filebuf : |
Initialized file buffer structure to write data to |
buf : |
Buffer to copy data from |
size : |
Amount of data to copy in bytes |
gboolean ipatch_file_buf_commit (IpatchFileBuf *filebuf, GError **err);
Writes all data in a file buffer to its file object and resets the position back to the beginning of the buffer.
void ipatch_file_buf_seek (IpatchFileBuf *filebuf, int offset, GSeekType type);
Seeks the current position in a file buffer specified by an offset
and seek type
.
filebuf : |
Initialized file buffer structure with loaded data |
offset : |
Offset to seek |
type : |
Seek type |
guint8 ipatch_file_buf_read_u8 (IpatchFileBuf *filebuf);
Reads an unsigned byte from a file buffer and advances the buffer's current position.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
guint16 ipatch_file_buf_read_u16 (IpatchFileBuf *filebuf);
Reads an unsigned 16 bit word from a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
guint32 ipatch_file_buf_read_u32 (IpatchFileBuf *filebuf);
Reads an unsigned 32 bit word from a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
guint64 ipatch_file_buf_read_u64 (IpatchFileBuf *filebuf);
Reads an unsigned 64 bit word from a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
gint8 ipatch_file_buf_read_s8 (IpatchFileBuf *filebuf);
Reads a signed byte from a file buffer and advances the buffer's current position.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
gint16 ipatch_file_buf_read_s16 (IpatchFileBuf *filebuf);
Reads a signed 16 bit word from a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
gint32 ipatch_file_buf_read_s32 (IpatchFileBuf *filebuf);
Reads a signed 32 bit word from a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
gint64 ipatch_file_buf_read_s64 (IpatchFileBuf *filebuf);
Reads a signed 64 bit word from a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary.
filebuf : |
Initialized file buffer structure with loaded data |
Returns : | The value. |
void ipatch_file_buf_write_u8 (IpatchFileBuf *filebuf, guint8 val);
Writes an unsigned byte to a file buffer and advances the buffer's current position. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_u16 (IpatchFileBuf *filebuf, guint16 val);
Writes an unsigned 16 bit word to a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_u32 (IpatchFileBuf *filebuf, guint32 val);
Writes an unsigned 32 bit word to a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_u64 (IpatchFileBuf *filebuf, guint64 val);
Writes an unsigned 64 bit word to a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_s8 (IpatchFileBuf *filebuf, gint8 val);
Writes a signed byte to a file buffer and advances the buffer's current position. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_s16 (IpatchFileBuf *filebuf, gint16 val);
Writes a signed 16 bit word to a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_s32 (IpatchFileBuf *filebuf, gint32 val);
Writes a signed 32 bit word to a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_buf_write_s64 (IpatchFileBuf *filebuf, gint64 val);
Writes a signed 64 bit word to a file buffer and advances the buffer's current position. Performs endian byte swapping if necessary. The file buffer's size should not be exceeded.
filebuf : |
Initialized file buffer structure |
val : |
Value to write into file buffer |
void ipatch_file_set_iofuncs_static (IpatchFile *file, IpatchFileIOFuncs *funcs);
Sets the input/output functions of a file object using a statically allocated (or guaranteed exist for lifetime of file) functions structure. Setting these functions allows one to write custom data sources or hook into other file functions.
file : |
File object |
funcs : |
Static IO functions structure or NULL to set to defaults
|
void ipatch_file_set_iofuncs (IpatchFile *file, const IpatchFileIOFuncs *funcs);
Sets the input/output functions of a file object. The funcs
structure is duplicated so as not to use the original, see
ipatch_file_set_iofuncs_static()
for using a static structure.
Setting these functions allows one to write custom data sources or
hook into other file functions.
file : |
File object |
funcs : |
IO functions structure or NULL to set to defaults
|
void ipatch_file_get_iofuncs (IpatchFile *file, IpatchFileIOFuncs *out_funcs);
Get the current IO functions from a file object. The function pointers
are stored in a user supplied structure pointed to by out_funcs
.
file : |
File object |
out_funcs : |
Location to store current IO functions to |
void ipatch_file_set_iofuncs_null (IpatchFile *file);
Sets the I/O functions of a file object to /dev/null like methods. Reading from the file will return 0s, writing/seeking will do nothing.
file : |
File object |
gboolean ipatch_file_default_open_method (IpatchFile *file, const char *mode, GError **err);
Default "open" method for IpatchFileIOFuncs. Useful when overriding only some I/O functions.
void ipatch_file_default_close_method (IpatchFile *file);
Default "close" method for IpatchFileIOFuncs. Useful when overriding only some I/O functions.
file : |
File object |
GIOStatus ipatch_file_default_read_method (IpatchFile *file, gpointer buf, guint size, guint *bytes_read, GError **err);
Default "read" method for IpatchFileIOFuncs. Useful when overriding only some I/O functions.
file : |
File object |
buf : |
Buffer to store data to |
size : |
Size of data |
bytes_read : |
Number of bytes actually read |
err : |
Error info |
Returns : | The status of the operation. |
GIOStatus ipatch_file_default_write_method (IpatchFile *file, gconstpointer buf, guint size, GError **err);
Default "write" method for IpatchFileIOFuncs. Useful when overriding only some I/O functions.
file : |
File object |
buf : |
Buffer to read data from |
size : |
Size of data |
err : |
Error info |
Returns : | The status of the operation. |
GIOStatus ipatch_file_default_seek_method (IpatchFile *file, int offset, GSeekType type, GError **err);
Default "seek" method for IpatchFileIOFuncs. Useful when overriding only some I/O functions.
file : |
File object |
offset : |
Offset (depends on seek type )
|
type : |
Seek type |
err : |
Error info |
Returns : | The status of the operation. |
int ipatch_file_default_getfd_method (IpatchFile *file);
Default "getfd" method for IpatchFileIOFuncs. Useful when overriding only some I/O functions. This method gets a unix file descriptor for the given file object, it is an optional method.
file : |
File object |
Returns : | Unix file descriptor or -1 if no file descriptor or error. |
close-on-finalize
" property"close-on-finalize" gboolean : Read / Write
Close on finalize.
Default value: FALSE
file-name
" property"file-name" gchararray : Read / Write
Name and path of file.
Default value: NULL
void user_function (IpatchFile *ipatchfile, gint arg1, gpointer user_data) : Run First
ipatchfile : |
the object which received the signal. |
arg1 : |
|
user_data : |
user data set when the signal handler was connected. |