Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
emutools_files.h
Go to the documentation of this file.
1 /* Xemu - Emulation (running on Linux/Unix/Windows/OSX, utilizing SDL2) of some
2  * 8 bit machines, including the Commodore LCD and Commodore 65 and MEGA65 as well.
3  Copyright (C)2016-2022 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
4 
5  The goal of emutools.c is to provide a relative simple solution
6  for relative simple emulators using SDL2.
7 
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21 
22 #ifndef XEMU_COMMON_EMUTOOLS_FILES_H_INCLUDED
23 #define XEMU_COMMON_EMUTOOLS_FILES_H_INCLUDED
24 
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 
30 #ifdef XEMU_ARCH_WIN
31 # define FILE_BROWSER "explorer"
32  /* Fow windows, we use 'cmd /c start' as web browser, but it needs special care because of
33  * being not a single string as executable. Thus WEB_BROWSER for Windows is handled in
34  * code, in emutools_files.c */
35 #elif defined(XEMU_ARCH_MAC)
36 # define FILE_BROWSER "open"
37 # define WEB_BROWSER "open"
38 #else
39 # define FILE_BROWSER "xdg-open"
40 # define WEB_BROWSER "xdg-open"
41 #endif
42 
43 #define OFF_T_ERROR ((off_t)-1)
44 
45 #define XEMU_OPEN_FILE_FIRST_MODE_USED -1
46 
47 extern void *xemu_load_buffer_p;
48 extern char xemu_load_filepath[PATH_MAX];
49 
50 extern int xemu_load_file ( const char *filename, void *store_to, int min_size, int max_size, const char *cry );
51 extern int xemu_save_file ( const char *filename, void *data, int size, const char *cry );
52 extern int xemu_open_file ( const char *filename, int mode, int *mode2, char *filepath_back );
53 extern ssize_t xemu_safe_read ( int fd, void *buffer, size_t length );
54 extern ssize_t xemu_safe_write ( int fd, const void *buffer, size_t length );
55 extern int xemu_safe_close ( int fd );
56 extern off_t xemu_safe_file_size_by_fd ( int fd );
57 extern off_t xemu_safe_file_size_by_name ( const char *name );
58 extern int xemu_create_large_empty_file ( const char *os_path, Uint64 size, int is_sparse );
59 
60 #if defined(HAVE_XEMU_INSTALLER) && !defined(HAVE_XEMU_EXEC_API)
61 #define HAVE_XEMU_EXEC_API
62 #endif
63 
64 #ifdef HAVE_XEMU_EXEC_API
65 #define XEMUEXEC_STILL_RUNNING 259
66 #ifdef XEMU_ARCH_WIN
67 typedef void* xemuexec_process_t;
68 #define XEMUEXEC_NULL_PROCESS_ID NULL
69 #else
70 typedef int xemuexec_process_t;
71 #define XEMUEXEC_NULL_PROCESS_ID 0
72 #endif
73 extern xemuexec_process_t xemuexec_run ( char *const args[] );
74 extern int xemuexec_check_status ( xemuexec_process_t pid, int wait );
75 #endif
76 
77 extern void xemuexec_open_native_file_browser ( char *dir );
78 
79 #ifdef HAVE_XEMU_INSTALLER
80 extern void xemu_set_installer ( const char *filename );
81 #endif
82 
83 #if defined(XEMU_USE_LODEPNG) && defined(XEMU_FILES_SCREENSHOT_SUPPORT)
84 // NOTE: you must call this function before the final rendering of course, thus source_pixels has a full rendered frame already ;)
85 extern int xemu_screenshot_png ( const char *path, const char *fn, unsigned int zoom_width, unsigned int zoom_height, Uint32 *source_pixels, unsigned int source_width, unsigned int source_height, unsigned int source_texture_width );
86 extern char xemu_screenshot_full_path[];
87 #endif
88 
89 #ifndef XEMU_ARCH_WIN
90 # define UNIX_DATADIR_0 "/usr/local/share/xemu"
91 # define UNIX_DATADIR_1 "/usr/local/lib/xemu"
92 # define UNIX_DATADIR_2 "/usr/share/xemu"
93 # define UNIX_DATADIR_3 "/usr/lib/xemu"
94 #endif
95 
96 #endif
xemu_open_file
int xemu_open_file(const char *filename, int mode, int *mode2, char *filepath_back)
Definition: emutools_files.c:469
xemu_load_buffer_p
void * xemu_load_buffer_p
Definition: emutools_files.c:34
xemuexec_open_native_file_browser
void xemuexec_open_native_file_browser(char *dir)
Definition: emutools_files.c:431
fn
const char * fn
Definition: roms.c:42
m65-memcontent-generator.data
data
Definition: m65-memcontent-generator.py:119
Uint32
uint32_t Uint32
Definition: fat32.c:49
xemu_load_file
int xemu_load_file(const char *filename, void *store_to, int min_size, int max_size, const char *cry)
Definition: emutools_files.c:674
xemu_safe_file_size_by_fd
off_t xemu_safe_file_size_by_fd(int fd)
Definition: emutools_files.c:583
xemu_save_file
int xemu_save_file(const char *filename, void *data, int size, const char *cry)
Definition: emutools_files.c:622
dir
DIR * dir
Definition: cpmfs.c:46
xemu_safe_write
ssize_t xemu_safe_write(int fd, const void *buffer, size_t length)
Definition: emutools_files.c:563
size
int size
Definition: inject.c:37
xemu_load_filepath
char xemu_load_filepath[PATH_MAX]
Definition: emutools_files.c:35
xemu_create_large_empty_file
int xemu_create_large_empty_file(const char *os_path, Uint64 size, int is_sparse)
Definition: emutools_files.c:727
name
const char * name
Definition: joystick.c:46
xemu_safe_read
ssize_t xemu_safe_read(int fd, void *buffer, size_t length)
Definition: emutools_files.c:543
xemu_safe_close
int xemu_safe_close(int fd)
Definition: emutools_files.c:600
xemu_safe_file_size_by_name
off_t xemu_safe_file_size_by_name(const char *name)
Definition: emutools_files.c:592