mirror of
https://github.com/libretro/parallel-gx2.git
synced 2026-11-07 04:25:58 -10:00
The core builds with a static Makefile (Makefile + Makefile.common) in the manner of the other ParaLLEl cores, for every target .gitlab-ci.yml has: Linux x86_64/aarch64, Windows (MinGW, native or cross), macOS, iOS, tvOS, Android arm64/x86_64 and webOS. CMake, vcpkg and their overlay ports are gone; the libraries the core needs are submodules built with it (fmt 12.1.0, glm 1.0.1, glslang 15.1.0, libusb 1.0.29, pugixml 1.15, zlib 1.3.1, zstd 1.5.7), with the generated files and the graphic packs produced by the Makefile itself (tools/pack_graphic_packs.c), and a precompiled header for gcc and clang. The core is renamed parallel_gx2 (parallel_gx2_libretro.info, library name "ParaLLEl GX2"). HTTP and TLS go through RetroArch's libretro-common (net_http with the per-request TLS settings, the built-in TLS client, x509, the hashes and the KDF) in place of libcurl, OpenSSL and mbedTLS: dependencies/curl-compat is the small libcurl API nlibcurl and napi use, on one transfer thread with lock-free submission and per-handle event queues, with its own tests against local HTTP and TLS servers, plain and under ASan/UBSan and TSan, in both CIs. The libretro-common files are plain copies from RetroArch. boost is replaced by the few headers the core uses (boost-compat), and the CI files build with the Makefile.
149 lines
5.4 KiB
C
149 lines
5.4 KiB
C
/* Copyright (C) 2010-2020 The RetroArch team
|
|
*
|
|
* ---------------------------------------------------------------------------------------
|
|
* The following license statement only applies to this file (retro_dirent.c).
|
|
* ---------------------------------------------------------------------------------------
|
|
*
|
|
* Permission is hereby granted, free of charge,
|
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <retro_common.h>
|
|
|
|
#include <boolean.h>
|
|
#include <retro_dirent.h>
|
|
#define VFS_FRONTEND
|
|
#include <vfs/vfs_implementation.h>
|
|
|
|
/* TODO/FIXME - static globals */
|
|
static retro_vfs_opendir_t dirent_opendir_cb = NULL;
|
|
static retro_vfs_readdir_t dirent_readdir_cb = NULL;
|
|
static retro_vfs_dirent_get_name_t dirent_dirent_get_name_cb = NULL;
|
|
static retro_vfs_dirent_is_dir_t dirent_dirent_is_dir_cb = NULL;
|
|
static retro_vfs_closedir_t dirent_closedir_cb = NULL;
|
|
static retro_vfs_dirent_stat_t dirent_dirent_stat_cb = NULL;
|
|
/* Set when a frontend older than VFS API v5 owns the directory
|
|
* handles: the local _impl cannot be used on a foreign handle, so
|
|
* retro_dirent_stat() reports "unavailable" instead. */
|
|
static bool dirent_stat_unavailable = false;
|
|
|
|
void dirent_vfs_init(const struct retro_vfs_interface_info* vfs_info)
|
|
{
|
|
const struct retro_vfs_interface* vfs_iface;
|
|
|
|
dirent_opendir_cb = NULL;
|
|
dirent_readdir_cb = NULL;
|
|
dirent_dirent_get_name_cb = NULL;
|
|
dirent_dirent_is_dir_cb = NULL;
|
|
dirent_closedir_cb = NULL;
|
|
dirent_dirent_stat_cb = NULL;
|
|
dirent_stat_unavailable = false;
|
|
|
|
vfs_iface = vfs_info->iface;
|
|
|
|
if (
|
|
vfs_info->required_interface_version < DIRENT_REQUIRED_VFS_VERSION
|
|
|| !vfs_iface)
|
|
return;
|
|
|
|
dirent_opendir_cb = vfs_iface->opendir;
|
|
dirent_readdir_cb = vfs_iface->readdir;
|
|
dirent_dirent_get_name_cb = vfs_iface->dirent_get_name;
|
|
dirent_dirent_is_dir_cb = vfs_iface->dirent_is_dir;
|
|
dirent_closedir_cb = vfs_iface->closedir;
|
|
|
|
/* A frontend that negotiated v5 but left the member NULL is treated
|
|
* like an older one: the local _impl must not touch its handles. */
|
|
if (vfs_info->required_interface_version >= DIRENT_STAT_REQUIRED_VFS_VERSION
|
|
&& vfs_iface->dirent_stat)
|
|
dirent_dirent_stat_cb = vfs_iface->dirent_stat;
|
|
else
|
|
dirent_stat_unavailable = true;
|
|
}
|
|
|
|
struct RDIR *retro_opendir_include_hidden(
|
|
const char *name, bool include_hidden)
|
|
{
|
|
if (dirent_opendir_cb)
|
|
return (struct RDIR *)dirent_opendir_cb(name, include_hidden);
|
|
return (struct RDIR *)retro_vfs_opendir_impl(name, include_hidden);
|
|
}
|
|
|
|
struct RDIR *retro_opendir(const char *name)
|
|
{
|
|
return retro_opendir_include_hidden(name, false);
|
|
}
|
|
|
|
bool retro_dirent_error(struct RDIR *rdir)
|
|
{
|
|
/* Left for compatibility */
|
|
return false;
|
|
}
|
|
|
|
int retro_readdir(struct RDIR *rdir)
|
|
{
|
|
if (dirent_readdir_cb)
|
|
return dirent_readdir_cb((struct retro_vfs_dir_handle *)rdir);
|
|
return retro_vfs_readdir_impl((struct retro_vfs_dir_handle *)rdir);
|
|
}
|
|
|
|
const char *retro_dirent_get_name(struct RDIR *rdir)
|
|
{
|
|
if (dirent_dirent_get_name_cb)
|
|
return dirent_dirent_get_name_cb((struct retro_vfs_dir_handle *)rdir);
|
|
return retro_vfs_dirent_get_name_impl((struct retro_vfs_dir_handle *)rdir);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* retro_dirent_is_dir:
|
|
* @rdir : pointer to the directory entry.
|
|
* @unused : deprecated, included for compatibility reasons, pass NULL
|
|
*
|
|
* Is the directory listing entry a directory?
|
|
*
|
|
* Returns: true if directory listing entry is
|
|
* a directory, false if not.
|
|
*/
|
|
bool retro_dirent_is_dir(struct RDIR *rdir, const char *unused)
|
|
{
|
|
if (dirent_dirent_is_dir_cb)
|
|
return dirent_dirent_is_dir_cb((struct retro_vfs_dir_handle *)rdir);
|
|
return retro_vfs_dirent_is_dir_impl((struct retro_vfs_dir_handle *)rdir);
|
|
}
|
|
|
|
int retro_dirent_stat(struct RDIR *rdir, int64_t *size, int64_t *mtime)
|
|
{
|
|
if (!rdir)
|
|
return 0;
|
|
if (dirent_dirent_stat_cb)
|
|
return dirent_dirent_stat_cb((struct retro_vfs_dir_handle *)rdir, size, mtime);
|
|
if (dirent_stat_unavailable)
|
|
return 0;
|
|
return retro_vfs_dirent_stat_impl((struct retro_vfs_dir_handle *)rdir, size, mtime);
|
|
}
|
|
|
|
void retro_closedir(struct RDIR *rdir)
|
|
{
|
|
if (dirent_closedir_cb)
|
|
dirent_closedir_cb((struct retro_vfs_dir_handle *)rdir);
|
|
else
|
|
retro_vfs_closedir_impl((struct retro_vfs_dir_handle *)rdir);
|
|
}
|