102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
browse.c File Reference
#include <dttr_config.h>
#include <dttr_iso.h>
#include <dttr_loader.h>
#include <dttr_loader_paths.h>
#include <dttr_loader_ui.h>
#include <dttr_log.h>
#include <dttr_path.h>
#include <dttr_sdl.h>
#include <SDL3/SDL.h>
#include <string.h>
#include <windows.h>

Go to the source code of this file.

Functions

static bool utf8_to_wide_path (WCHAR *out, const char *path)
static bool get_full_path (char *out, size_t out_size, const char *path)
static bool get_os_cache_base_dir (char *buf, size_t buf_size)
static bool try_path (WCHAR *out, const WCHAR *dir, const WCHAR *subpath)
static bool try_dir (WCHAR *out, const WCHAR *dir)
static void copy_path (char *out, size_t out_size, const char *path)
static bool extract_iso_file (DTTR_IsoImage *iso, const char *cache_root, const char *iso_path, char *out_path, size_t out_path_size)
static bool extract_iso_game_cache (DTTR_IsoImage *iso, const char *cache_root, char *exe_path, size_t exe_path_size)
static bool resolve_iso_direct (WCHAR *out, const char *iso_path, DTTR_LoaderIsoContext *iso_context)
static bool resolve_iso (WCHAR *out, const char *iso_path, DTTR_LoaderIsoContext *iso_context)
static bool try_configured_path (WCHAR *out, const char *configured_path, DTTR_LoaderIsoContext *iso_context)
static void fill_disc_candidate (DTTR_LoaderUIDiscCandidate *candidate, char drive)
static void SDLCALL browse_callback (void *, const char *const *filelist, int)
static bool wait_for_browse_result ()
static void save_selected_path (const char *path)
static void scan_disc_candidates (DTTR_LoaderUIDiscCandidate *candidates, size_t *candidate_count)
static bool try_disc_candidate (WCHAR *out, const DTTR_LoaderUIDiscCandidate *candidate)
static bool run_browse_dialog (DTTR_LoaderUIChoice choice)
static bool try_browsed_path (WCHAR *out, DTTR_LoaderUIChoice choice, DTTR_LoaderIsoContext *iso_context)
static bool try_browse_choice (WCHAR *out, DTTR_LoaderUIChoice choice, DTTR_LoaderIsoContext *iso_context)
static bool prompt_browse_for_path (WCHAR *out, DTTR_LoaderIsoContext *iso_context)
bool DTTR_Loader_ResolveEXEPath (WCHAR *out, const char *configured_path, DTTR_LoaderIsoContext *iso_context)

Variables

static char browse_result [MAX_PATH]
static HANDLE browse_event

Function Documentation

◆ browse_callback()

void SDLCALL browse_callback ( void * ,
const char *const * filelist,
int  )
static

Definition at line 264 of file browse.c.

References browse_event, browse_result, copy_path(), and NULL.

Referenced by run_browse_dialog().

◆ copy_path()

void copy_path ( char * out,
size_t out_size,
const char * path )
static

Definition at line 70 of file browse.c.

References DTTR_Path_CopyString().

Referenced by browse_callback(), resolve_iso_direct(), and save_selected_path().

◆ DTTR_Loader_ResolveEXEPath()

bool DTTR_Loader_ResolveEXEPath ( WCHAR * out,
const char * configured_path,
DTTR_LoaderIsoContext * iso_context )

Definition at line 459 of file browse.c.

References prompt_browse_for_path(), and try_configured_path().

Referenced by dttr_launcher_main().

◆ extract_iso_file()

bool extract_iso_file ( DTTR_IsoImage * iso,
const char * cache_root,
const char * iso_path,
char * out_path,
size_t out_path_size )
static

Definition at line 81 of file browse.c.

References DTTR_ISO_ExtractFile(), DTTR_ISO_LastError(), and DTTR_LOG_ERROR.

Referenced by extract_iso_game_cache().

◆ extract_iso_game_cache()

bool extract_iso_game_cache ( DTTR_IsoImage * iso,
const char * cache_root,
char * exe_path,
size_t exe_path_size )
static

◆ fill_disc_candidate()

void fill_disc_candidate ( DTTR_LoaderUIDiscCandidate * candidate,
char drive )
static

Definition at line 258 of file browse.c.

References DTTR_LoaderUIDiscCandidate::label, and DTTR_LoaderUIDiscCandidate::path.

Referenced by scan_disc_candidates().

◆ get_full_path()

bool get_full_path ( char * out,
size_t out_size,
const char * path )
static

Definition at line 25 of file browse.c.

References DWORD, and NULL.

Referenced by resolve_iso_direct().

◆ get_os_cache_base_dir()

bool get_os_cache_base_dir ( char * buf,
size_t buf_size )
static

Definition at line 31 of file browse.c.

References DWORD.

Referenced by resolve_iso_direct().

◆ prompt_browse_for_path()

◆ resolve_iso()

bool resolve_iso ( WCHAR * out,
const char * iso_path,
DTTR_LoaderIsoContext * iso_context )
static

Definition at line 205 of file browse.c.

References DTTR_LoaderUI_ShowError(), DTTR_LOG_ERROR, and resolve_iso_direct().

Referenced by try_browsed_path(), and try_configured_path().

◆ resolve_iso_direct()

◆ run_browse_dialog()

◆ save_selected_path()

void save_selected_path ( const char * path)
static

◆ scan_disc_candidates()

void scan_disc_candidates ( DTTR_LoaderUIDiscCandidate * candidates,
size_t * candidate_count )
static

Definition at line 298 of file browse.c.

References DTTR_LOADER_UI_MAX_DISC_CANDIDATES, DWORD, fill_disc_candidate(), and try_dir().

Referenced by prompt_browse_for_path().

◆ try_browse_choice()

bool try_browse_choice ( WCHAR * out,
DTTR_LoaderUIChoice choice,
DTTR_LoaderIsoContext * iso_context )
static

Definition at line 382 of file browse.c.

References run_browse_dialog(), and try_browsed_path().

Referenced by prompt_browse_for_path().

◆ try_browsed_path()

bool try_browsed_path ( WCHAR * out,
DTTR_LoaderUIChoice choice,
DTTR_LoaderIsoContext * iso_context )
static

◆ try_configured_path()

bool try_configured_path ( WCHAR * out,
const char * configured_path,
DTTR_LoaderIsoContext * iso_context )
static

◆ try_dir()

bool try_dir ( WCHAR * out,
const WCHAR * dir )
static

◆ try_disc_candidate()

bool try_disc_candidate ( WCHAR * out,
const DTTR_LoaderUIDiscCandidate * candidate )
static

◆ try_path()

bool try_path ( WCHAR * out,
const WCHAR * dir,
const WCHAR * subpath )
static

Definition at line 43 of file browse.c.

Referenced by try_dir().

◆ utf8_to_wide_path()

bool utf8_to_wide_path ( WCHAR * out,
const char * path )
static

◆ wait_for_browse_result()

bool wait_for_browse_result ( )
static

Definition at line 277 of file browse.c.

References browse_event, browse_result, DTTR_SDL_Delay(), and DTTR_SDL_PumpEvents().

Referenced by run_browse_dialog().

Variable Documentation

◆ browse_event

HANDLE browse_event
static

Definition at line 255 of file browse.c.

Referenced by browse_callback(), run_browse_dialog(), and wait_for_browse_result().

◆ browse_result

char browse_result[MAX_PATH]
static