Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
Macros | Functions | Variables
emutools_files.h File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
Include dependency graph for emutools_files.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FILE_BROWSER   "xdg-open"
 
#define WEB_BROWSER   "xdg-open"
 
#define OFF_T_ERROR   ((off_t)-1)
 
#define XEMU_OPEN_FILE_FIRST_MODE_USED   -1
 
#define UNIX_DATADIR_0   "/usr/local/share/xemu"
 
#define UNIX_DATADIR_1   "/usr/local/lib/xemu"
 
#define UNIX_DATADIR_2   "/usr/share/xemu"
 
#define UNIX_DATADIR_3   "/usr/lib/xemu"
 

Functions

int xemu_load_file (const char *filename, void *store_to, int min_size, int max_size, const char *cry)
 
int xemu_save_file (const char *filename, void *data, int size, const char *cry)
 
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)
 
int xemu_safe_close (int fd)
 
off_t xemu_safe_file_size_by_fd (int fd)
 
off_t xemu_safe_file_size_by_name (const char *name)
 
int xemu_create_large_empty_file (const char *os_path, Uint64 size, int is_sparse)
 
void xemuexec_open_native_file_browser (char *dir)
 

Variables

void * xemu_load_buffer_p
 
char xemu_load_filepath [PATH_MAX]
 

Macro Definition Documentation

◆ FILE_BROWSER

#define FILE_BROWSER   "xdg-open"

Definition at line 39 of file emutools_files.h.

◆ OFF_T_ERROR

#define OFF_T_ERROR   ((off_t)-1)

Definition at line 43 of file emutools_files.h.

◆ UNIX_DATADIR_0

#define UNIX_DATADIR_0   "/usr/local/share/xemu"

Definition at line 90 of file emutools_files.h.

◆ UNIX_DATADIR_1

#define UNIX_DATADIR_1   "/usr/local/lib/xemu"

Definition at line 91 of file emutools_files.h.

◆ UNIX_DATADIR_2

#define UNIX_DATADIR_2   "/usr/share/xemu"

Definition at line 92 of file emutools_files.h.

◆ UNIX_DATADIR_3

#define UNIX_DATADIR_3   "/usr/lib/xemu"

Definition at line 93 of file emutools_files.h.

◆ WEB_BROWSER

#define WEB_BROWSER   "xdg-open"

Definition at line 40 of file emutools_files.h.

◆ XEMU_OPEN_FILE_FIRST_MODE_USED

#define XEMU_OPEN_FILE_FIRST_MODE_USED   -1

Definition at line 45 of file emutools_files.h.

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.

Parameters
*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_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,
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.