102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
hook_crt_open_file.c File Reference
#include "hooks_private.h"
#include "sidecar_private.h"
#include <dttr_config.h>
#include <dttr_log.h>
#include <dttr_path.h>
#include <dttr_pcdogs.h>
#include <dttr_sdl.h>
#include <SDL3/SDL.h>
#include <sds.h>
#include <sys/stat.h>
#include <windows.h>

Go to the source code of this file.

Macros

#define IS_READ_ONLY_MODE(m)

Functions

static DTTR_PCDOGS_T_File_Handlefile_open_with_mode (const char *path, const char *mode, uint8_t sharing_flag)
static bool is_relative_path (const char *path)
static bool mode_wants_write (const char *mode)
static void create_dir_if_set (const char *path)
static void build_saves_dir (char *buf, size_t buf_size)
static void build_save_slot_dir (char *buf, size_t buf_size)
static void ensure_save_dir ()
static const char * redirect_path (const char *path, char *buf, size_t buf_size, const char *mode)
static DTTR_PCDOGS_T_File_Handlereport_file_open_failure (const char *path, const char *mode)
static DTTR_PCDOGS_T_File_Handletry_fix_permissions (const char *path, const char *mode)
static DTTR_PCDOGS_T_File_Handletry_open_read_path (const char *path, const char *mode)
DTTR_PCDOGS_T_File_Handledttr_crt_hook_open_file_callback (const char *path, const char *mode)

Variables

static bool redirect_saves_initialized = false

Macro Definition Documentation

◆ IS_READ_ONLY_MODE

#define IS_READ_ONLY_MODE ( m)
Value:
((m) && (m)[0] == 'r' && !strchr((m), '+'))

Definition at line 14 of file hook_crt_open_file.c.

Referenced by dttr_crt_hook_open_file_callback(), and redirect_path().

Function Documentation

◆ build_save_slot_dir()

void build_save_slot_dir ( char * buf,
size_t buf_size )
static

◆ build_saves_dir()

void build_saves_dir ( char * buf,
size_t buf_size )
static

◆ create_dir_if_set()

void create_dir_if_set ( const char * path)
static

Definition at line 56 of file hook_crt_open_file.c.

References NULL.

Referenced by ensure_save_dir().

◆ dttr_crt_hook_open_file_callback()

DTTR_PCDOGS_T_File_Handle * dttr_crt_hook_open_file_callback ( const char * path,
const char * mode )

◆ ensure_save_dir()

void ensure_save_dir ( )
static

◆ file_open_with_mode()

DTTR_PCDOGS_T_File_Handle * file_open_with_mode ( const char * path,
const char * mode,
uint8_t sharing_flag )
static

◆ is_relative_path()

bool is_relative_path ( const char * path)
static

Definition at line 44 of file hook_crt_open_file.c.

References DTTR_Path_IsSafeRelative().

Referenced by build_saves_dir(), and redirect_path().

◆ mode_wants_write()

bool mode_wants_write ( const char * mode)
static

Definition at line 49 of file hook_crt_open_file.c.

Referenced by dttr_crt_hook_open_file_callback(), and try_fix_permissions().

◆ redirect_path()

const char * redirect_path ( const char * path,
char * buf,
size_t buf_size,
const char * mode )
static

◆ report_file_open_failure()

DTTR_PCDOGS_T_File_Handle * report_file_open_failure ( const char * path,
const char * mode )
static

Definition at line 148 of file hook_crt_open_file.c.

References DTTR_SDL_ShowSimpleMessageBox(), and NULL.

Referenced by dttr_crt_hook_open_file_callback().

◆ try_fix_permissions()

DTTR_PCDOGS_T_File_Handle * try_fix_permissions ( const char * path,
const char * mode )
static

◆ try_open_read_path()

DTTR_PCDOGS_T_File_Handle * try_open_read_path ( const char * path,
const char * mode )
static

Variable Documentation

◆ redirect_saves_initialized

bool redirect_saves_initialized = false
static

Definition at line 53 of file hook_crt_open_file.c.

Referenced by ensure_save_dir().