102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
iso.c File Reference
#include <dttr_iso.h>
#include <dttr_path.h>
#include <physfs.h>
#include <sds.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <direct.h>
#include <windows.h>

Go to the source code of this file.

Macros

#define MKDIR(path)

Enumerations

enum  { ISO_SECTOR_SIZE = 2048 }

Functions

static void set_error (const char *message)
static void set_physfs_error (const char *context)
const char * DTTR_ISO_LastError ()
static bool is_iso_version_suffix (const char *suffix)
static size_t strip_iso_version_suffix_len (const char *segment, size_t segment_len)
static void trim_trailing_separators (sds path)
static bool sdscat_lower_segment (sds *out, const char *segment, size_t segment_len)
bool DTTR_ISO_CachePathForFile (const char *cache_root, const char *iso_relative_path, char *out_path, size_t out_path_size)
static bool physfs_init ()
static void physfs_deinit ()
bool DTTR_ISO_Open (DTTR_IsoImage *iso, const char *iso_path)
static bool name_matches_segment (const char *name, const char *segment, size_t segment_len)
static bool find_case_match (const char *parent, const char *segment, size_t segment_len, char *out_name, size_t out_name_size)
static bool resolve_iso_path_case (const char *requested, char *out_path, size_t out_path_size)
static bool create_parent_dirs (const char *path)
static bool file_matches_physfs_file (const char *path, PHYSFS_File *physfs_file, size_t size)
static sds child_iso_path (const char *parent, const char *entry)
bool DTTR_ISO_ExtractFile (DTTR_IsoImage *iso, const char *iso_relative_path, const char *cache_root, char *out_path, size_t out_path_size)
static bool extract_tree_path (DTTR_IsoImage *iso, const char *physfs_path, const char *cache_root)
bool DTTR_ISO_ExtractTree (DTTR_IsoImage *iso, const char *iso_relative_path, const char *cache_root)
void DTTR_ISO_Close (DTTR_IsoImage *iso)

Variables

static int physfs_refcount
static char last_error [256]

Macro Definition Documentation

◆ MKDIR

#define MKDIR ( path)
Value:
(CreateDirectoryA((path), NULL) || GetLastError() == ERROR_ALREADY_EXISTS)
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL

Definition at line 14 of file iso.c.

Referenced by create_parent_dirs().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ISO_SECTOR_SIZE 

Definition at line 17 of file iso.c.

Function Documentation

◆ child_iso_path()

sds child_iso_path ( const char * parent,
const char * entry )
static

Definition at line 395 of file iso.c.

References DTTR_Path_AppendSegment(), and NULL.

Referenced by extract_tree_path().

◆ create_parent_dirs()

bool create_parent_dirs ( const char * path)
static

Definition at line 308 of file iso.c.

References DTTR_ISO_MAX_PATH, DTTR_Path_IsSeparator(), and MKDIR.

Referenced by DTTR_ISO_ExtractFile().

◆ DTTR_ISO_CachePathForFile()

bool DTTR_ISO_CachePathForFile ( const char * cache_root,
const char * iso_relative_path,
char * out_path,
size_t out_path_size )

◆ DTTR_ISO_Close()

void DTTR_ISO_Close ( DTTR_IsoImage * iso)

Definition at line 593 of file iso.c.

References DTTR_IsoImage::iso_path, DTTR_IsoImage::open, and physfs_deinit().

Referenced by resolve_iso_direct().

◆ DTTR_ISO_ExtractFile()

bool DTTR_ISO_ExtractFile ( DTTR_IsoImage * iso,
const char * iso_relative_path,
const char * cache_root,
char * out_path,
size_t out_path_size )

◆ DTTR_ISO_ExtractTree()

bool DTTR_ISO_ExtractTree ( DTTR_IsoImage * iso,
const char * iso_relative_path,
const char * cache_root )

◆ DTTR_ISO_LastError()

const char * DTTR_ISO_LastError ( )

Definition at line 44 of file iso.c.

References last_error.

Referenced by extract_iso_file(), extract_iso_game_cache(), and resolve_iso_direct().

◆ DTTR_ISO_Open()

bool DTTR_ISO_Open ( DTTR_IsoImage * iso,
const char * iso_path )

◆ extract_tree_path()

bool extract_tree_path ( DTTR_IsoImage * iso,
const char * physfs_path,
const char * cache_root )
static

◆ file_matches_physfs_file()

bool file_matches_physfs_file ( const char * path,
PHYSFS_File * physfs_file,
size_t size )
static

Definition at line 342 of file iso.c.

References ISO_SECTOR_SIZE, set_physfs_error(), and size.

Referenced by DTTR_ISO_ExtractFile().

◆ find_case_match()

bool find_case_match ( const char * parent,
const char * segment,
size_t segment_len,
char * out_name,
size_t out_name_size )
static

Definition at line 222 of file iso.c.

References DTTR_Path_CopyString(), and name_matches_segment().

Referenced by resolve_iso_path_case().

◆ is_iso_version_suffix()

bool is_iso_version_suffix ( const char * suffix)
static

Definition at line 48 of file iso.c.

Referenced by name_matches_segment(), and strip_iso_version_suffix_len().

◆ name_matches_segment()

bool name_matches_segment ( const char * name,
const char * segment,
size_t segment_len )
static

Definition at line 210 of file iso.c.

References DTTR_Path_AsciiIeqN(), and is_iso_version_suffix().

Referenced by find_case_match().

◆ physfs_deinit()

void physfs_deinit ( )
static

Definition at line 172 of file iso.c.

References physfs_refcount.

Referenced by DTTR_ISO_Close(), and DTTR_ISO_Open().

◆ physfs_init()

bool physfs_init ( )
static

Definition at line 155 of file iso.c.

References physfs_refcount, and set_physfs_error().

Referenced by DTTR_ISO_Open().

◆ resolve_iso_path_case()

bool resolve_iso_path_case ( const char * requested,
char * out_path,
size_t out_path_size )
static

◆ sdscat_lower_segment()

bool sdscat_lower_segment ( sds * out,
const char * segment,
size_t segment_len )
static

◆ set_error()

void set_error ( const char * message)
static

Definition at line 23 of file iso.c.

References last_error.

Referenced by DTTR_ISO_ExtractFile(), DTTR_ISO_ExtractTree(), DTTR_ISO_Open(), and extract_tree_path().

◆ set_physfs_error()

void set_physfs_error ( const char * context)
static

◆ strip_iso_version_suffix_len()

size_t strip_iso_version_suffix_len ( const char * segment,
size_t segment_len )
static

Definition at line 63 of file iso.c.

References is_iso_version_suffix().

Referenced by sdscat_lower_segment().

◆ trim_trailing_separators()

void trim_trailing_separators ( sds path)
static

Definition at line 74 of file iso.c.

References DTTR_Path_IsSeparator().

Referenced by DTTR_ISO_CachePathForFile().

Variable Documentation

◆ last_error

char last_error[256]
static

Definition at line 20 of file iso.c.

Referenced by DTTR_ISO_LastError(), set_error(), and set_physfs_error().

◆ physfs_refcount

int physfs_refcount
static

Definition at line 19 of file iso.c.

Referenced by physfs_deinit(), and physfs_init().