Skip to content

Commit

Permalink
(UWP) Add support for loading cores from optional packages
Browse files Browse the repository at this point in the history
  • Loading branch information
krzys-h committed Jan 1, 2019
1 parent 556bcc1 commit 48d8292
Show file tree
Hide file tree
Showing 85 changed files with 1,009 additions and 466 deletions.
38 changes: 31 additions & 7 deletions core_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "core_info.h"
#include "file_path_special.h"

#ifdef __WINRT__
#include "uwp/uwp_func.h"
#endif

static const char *core_info_tmp_path = NULL;
static const struct string_list *core_info_tmp_list = NULL;
static core_info_t *core_info_current = NULL;
Expand Down Expand Up @@ -232,11 +236,31 @@ static core_info_list_t *core_info_list_new(const char *path,
core_info_t *core_info = NULL;
core_info_list_t *core_info_list = NULL;
const char *path_basedir = libretro_info_dir;
struct string_list *contents = dir_list_new(
path, exts,
false,
show_hidden_files,
false, false);
struct string_list *contents = string_list_new();
bool ok;

ok = dir_list_append(contents, path, exts,
false, show_hidden_files, false, false);

#ifdef __WINRT__
/* UWP: browse the optional packages for additional cores */
struct string_list *core_packages = string_list_new();
uwp_fill_installed_core_packages(core_packages);
for (i = 0; i < core_packages->size; i++)
{
dir_list_append(contents, core_packages->elems[i].data, exts,
false, show_hidden_files, false, false);
}
string_list_free(core_packages);
#else
/* Keep the old 'directory not found' behavior */
if (!ok)
{
string_list_free(contents);
contents = NULL;
}
#endif

if (!contents)
return NULL;

Expand Down Expand Up @@ -430,12 +454,12 @@ static core_info_list_t *core_info_list_new(const char *path,
core_info_list_resolve_all_firmware(core_info_list);
}

dir_list_free(contents);
string_list_free(contents);
return core_info_list;

error:
if (contents)
dir_list_free(contents);
string_list_free(contents);
core_info_list_free(core_info_list);
return NULL;
}
Expand Down
17 changes: 17 additions & 0 deletions libretro-common/include/lists/dir_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@

RETRO_BEGIN_DECLS

/**
* dir_list_append:
* @list : existing list to append to.
* @dir : directory path.
* @ext : allowed extensions of file directory entries to include.
* @include_dirs : include directories as part of the finished directory listing?
* @include_hidden : include hidden files and directories as part of the finished directory listing?
* @include_compressed : Only include files which match ext. Do not try to match compressed files, etc.
* @recursive : list directory contents recursively
*
* Create a directory listing, appending to an existing list
*
* Returns: true success, false in case of error.
**/
bool dir_list_append(struct string_list *list, const char *dir, const char *ext,
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);

/**
* dir_list_new:
* @dir : directory path.
Expand Down
46 changes: 38 additions & 8 deletions libretro-common/lists/dir_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,42 @@ static int dir_list_read(const char *dir,
return -1;
}

/**
* dir_list_append:
* @list : existing list to append to.
* @dir : directory path.
* @ext : allowed extensions of file directory entries to include.
* @include_dirs : include directories as part of the finished directory listing?
* @include_hidden : include hidden files and directories as part of the finished directory listing?
* @include_compressed : Only include files which match ext. Do not try to match compressed files, etc.
* @recursive : list directory contents recursively
*
* Create a directory listing, appending to an existing list
*
* Returns: true success, false in case of error.
**/
bool dir_list_append(struct string_list *list,
const char *dir,
const char *ext, bool include_dirs,
bool include_hidden, bool include_compressed,
bool recursive)
{
struct string_list *ext_list = NULL;

if (ext)
ext_list = string_split(ext, "|");

if(dir_list_read(dir, list, ext_list, include_dirs,
include_hidden, include_compressed, recursive) == -1)
{
string_list_free(ext_list);
return false;
}

string_list_free(ext_list);
return true;
}

/**
* dir_list_new:
* @dir : directory path.
Expand All @@ -249,24 +285,18 @@ struct string_list *dir_list_new(const char *dir,
bool include_hidden, bool include_compressed,
bool recursive)
{
struct string_list *ext_list = NULL;
struct string_list *list = NULL;

if (!(list = string_list_new()))
return NULL;

if (ext)
ext_list = string_split(ext, "|");

if(dir_list_read(dir, list, ext_list, include_dirs,
include_hidden, include_compressed, recursive) == -1)
if (!dir_list_append(list, dir, ext, include_dirs,
include_hidden, include_compressed, recursive))
{
string_list_free(list);
string_list_free(ext_list);
return NULL;
}

string_list_free(ext_list);
return list;
}

23 changes: 22 additions & 1 deletion menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3609,6 +3609,7 @@ static unsigned menu_displaylist_parse_cores(
unsigned items_found = 0;
settings_t *settings = config_get_ptr();
const char *path = info->path;
bool ok;

if (string_is_empty(path))
{
Expand All @@ -3619,9 +3620,29 @@ static unsigned menu_displaylist_parse_cores(
return items_found;
}

str_list = dir_list_new(path, info->exts,
str_list = string_list_new();
ok = dir_list_append(str_list, path, info->exts,
true, settings->bools.show_hidden_files, true, false);

#ifdef __WINRT__
/* UWP: browse the optional packages for additional cores */
struct string_list *core_packages = string_list_new();
uwp_fill_installed_core_packages(core_packages);
for (i = 0; i < core_packages->size; i++)
{
dir_list_append(str_list, core_packages->elems[i].data, info->exts,
true, settings->bools.show_hidden_files, true, false);
}
string_list_free(core_packages);
#else
/* Keep the old 'directory not found' behavior */
if (!ok)
{
string_list_free(str_list);
str_list = NULL;
}
#endif

{
char *out_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));

Expand Down
3 changes: 3 additions & 0 deletions pkg/msvc-uwp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AppPackages/
*/BundleArtifacts/
.vs/
23 changes: 23 additions & 0 deletions pkg/msvc-uwp/RetroArch-UWP-cores-nonfree/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:uap6="http://schemas.microsoft.com/appx/manifest/uap/windows10/6" IgnorableNamespaces="uap uap3 uap6 mp">
<Identity Name="176695a3-0144-488b-9a1a-68e6eb1318ff" Publisher="CN=krzys" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="176695a3-0144-488b-9a1a-68e6eb1318ff" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>RetroArch: non-free cores</DisplayName>
<PublisherDisplayName>libretro</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.17763.0" />
<uap3:MainPackageDependency Name="1e4cf179-f3c2-404f-b9f3-cb2070a5aad8" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="CoresNonFree" Executable="$targetnametoken$.exe" EntryPoint="RetroArch.CoresNonFree">
<uap:VisualElements AppListEntry="none" DisplayName="RetroArch: non-free cores" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="The 'non-free' cores package for RetroArch" BackgroundColor="transparent">
</uap:VisualElements>
</Application>
</Applications>
</Package>
Loading

0 comments on commit 48d8292

Please sign in to comment.