Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
Functions | Variables
emutools_files.c File Reference
#include "xemu/emutools.h"
#include "xemu/emutools_files.h"
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
Include dependency graph for emutools_files.c:

Go to the source code of this file.


void xemuexec_open_native_file_browser (char *dir)
int xemu_open_file (const char *filename, int mode, int *mode2, char *filepath_back)
ssize_t xemu_safe_read (int fd, void *buffer, size_t length)
ssize_t xemu_safe_write (int fd, const void *buffer, size_t length)
off_t xemu_safe_file_size_by_fd (int fd)
off_t xemu_safe_file_size_by_name (const char *name)
int xemu_safe_close (int fd)
int xemu_safe_open (const char *fn, int flags)
int xemu_safe_open_with_mode (const char *fn, int flags, int mode)
int xemu_save_file (const char *filename_in, void *data, int size, const char *cry)
int xemu_load_file (const char *filename, void *store_to, int min_size, int max_size, const char *cry)
int xemu_create_large_empty_file (const char *os_path, Uint64 size, int is_sparse)


void * xemu_load_buffer_p
char xemu_load_filepath [PATH_MAX]

Function Documentation

◆ xemu_create_large_empty_file()

int xemu_create_large_empty_file ( const char *  os_path,
Uint64  size,
int  is_sparse 

Definition at line 727 of file emutools_files.c.

◆ xemu_load_file()

int xemu_load_file ( const char *  filename,
void *  store_to,
int  min_size,
int  max_size,
const char *  cry 

Definition at line 674 of file emutools_files.c.

Here is the caller graph for this function:

◆ xemu_open_file()

int xemu_open_file ( const char *  filename,
int  mode,
int *  mode2,
char *  filepath_back 

Open a file (probably with special search paths, see below), returning a file descriptor, or negative value in case of failure.

Central part of file handling in Xemu.

*filenamename of the file
  • if it begins with '@' the file is meant to relative to the SDL preferences directory (ie: @thisisit.rom, no need for dirsep!)
  • if it begins with '#' the file is meant for 'data directory' which is probed then multiple places, depends on the OS as well
    • Note: in this case, if installer is enabled and file not found, Xemu can try to download the file. For this, see above the "installer" part of this source
  • otherwise it's simply a file name, passed as-is
modeactually the flags parameter for open (O_RDONLY, etc)
  • O_BINARY is used automatically in case of Windows, no need to specify as input data
  • you can even use creating file effect with the right value here
*mode2pointer to an int, secondary open mode set
  • if it's NULL pointer, it won't be used ever
  • if it's not NULL, open() is also tried with the pointed flags for open() after trying (and failed!) open() with the 'mode' par
  • if mode2 pointer is not NULL, the pointed value will be set to XEMU_OPEN_FILE_FIRST_MODE_USED by this func, if NOT *mode2 is used with successfull open
  • the reason for this madness: opening a disk image which neads to be read/write access, but also works for read-only, however then the caller needs to know if the disk emulation is about r/w or ro only ...
*filepath_backif not null, actually tried path will be placed here (even in case of non-successfull call, ie retval is negative)
  • in case of multiple-path tries (# prefix) the first (so the most relevant, hopefully) is passed back
  • note: if no prefix (@ and #) the filename will be returned as is, even if didn't hold absolute path (only relative) or no path as all (both: relative to cwd)!

Definition at line 469 of file emutools_files.c.

Here is the caller graph for this function:

◆ xemu_safe_close()

int xemu_safe_close ( int  fd)

Definition at line 600 of file emutools_files.c.

◆ xemu_safe_file_size_by_fd()

off_t xemu_safe_file_size_by_fd ( int  fd)

Definition at line 583 of file emutools_files.c.

◆ xemu_safe_file_size_by_name()

off_t xemu_safe_file_size_by_name ( const char *  name)

Definition at line 592 of file emutools_files.c.

◆ xemu_safe_open()

int xemu_safe_open ( const char *  fn,
int  flags 

Definition at line 610 of file emutools_files.c.

◆ xemu_safe_open_with_mode()

int xemu_safe_open_with_mode ( const char *  fn,
int  flags,
int  mode 

Definition at line 616 of file emutools_files.c.

◆ xemu_safe_read()

ssize_t xemu_safe_read ( int  fd,
void *  buffer,
size_t  length 

Definition at line 543 of file emutools_files.c.

◆ xemu_safe_write()

ssize_t xemu_safe_write ( int  fd,
const void *  buffer,
size_t  length 

Definition at line 563 of file emutools_files.c.

Here is the caller graph for this function:

◆ xemu_save_file()

int xemu_save_file ( const char *  filename_in,
void *  data,
int  size,
const char *  cry 

Definition at line 622 of file emutools_files.c.

Here is the caller graph for this function:

◆ xemuexec_open_native_file_browser()

void xemuexec_open_native_file_browser ( char *  dir)

Definition at line 431 of file emutools_files.c.

Variable Documentation

◆ xemu_load_buffer_p

void* xemu_load_buffer_p

Definition at line 34 of file emutools_files.c.

◆ xemu_load_filepath

char xemu_load_filepath[PATH_MAX]

Definition at line 35 of file emutools_files.c.