Refactors

This commit is contained in:
twinaphex 2015-01-21 01:56:59 +01:00
parent 68a0f98096
commit 8d6e5811f2
3 changed files with 50 additions and 4 deletions

View File

@ -23,6 +23,28 @@
#include <file/file_path.h>
/**
* http_get_file:
* @url : URL to file.
* @buf : Buffer.
* @len : Size of @buf.
*
* Loads the contents of a file at specified URL into
* buffer @buf. Sets length of data buffer as well.
*
* Returns: HTTP return code on success, otherwise
* negative on failure.
**/
http_retcode http_get_file(char *url, char **buf, int *len)
{
char *urlfilename = NULL;
if (!http_parse_url(url, &urlfilename))
return ERRRDDT;
return http_get(urlfilename, buf, len, NULL);
}
/**
* http_download_file:
* @url : URL to file.
@ -40,11 +62,9 @@ bool http_download_file(char *url, const char *output_dir,
int len;
FILE *f;
char output_path[PATH_MAX_LENGTH];
char *buf, *urlfilename = NULL;
char *buf;
http_parse_url(url, &urlfilename);
status = http_get(urlfilename, &buf, &len, NULL);
status = http_get_file(url, &buf, &len);
if (status < 0)
{

View File

@ -21,6 +21,10 @@
#include "netplay_compat.h"
#include "http_lib.h"
#ifdef __cplusplus
extern "C" {
#endif
enum
{
HTTP_INTF_ERROR = 0,
@ -30,6 +34,20 @@ enum
HTTP_INTF_HEAD
};
/**
* http_get_file:
* @url : URL to file.
* @buf : Buffer.
* @len : Size of @buf.
*
* Loads the contents of a file at specified URL into
* buffer @buf. Sets length of data buffer as well.
*
* Returns: HTTP return code on success, otherwise
* negative on failure.
**/
http_retcode http_get_file(char *url, char **buf, int *len);
/**
* http_download_file:
* @url : URL to file.
@ -45,4 +63,8 @@ bool http_download_file(char *url, const char *output_dir,
int http_intf_command(unsigned mode, char *url);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -28,7 +28,9 @@
#include "../retroarch.h"
#include "../performance.h"
#ifdef HAVE_NETPLAY
#include "../http_intf.h"
#endif
#include "../input/input_remapping.h"
#ifdef GEKKO
@ -803,10 +805,12 @@ static int generic_action_ok_command(unsigned cmd)
static int action_ok_core_manager_list(const char *path,
const char *label, unsigned type, size_t idx)
{
#ifdef HAVE_NETPLAY
char url[] = "http://buildbot.libretro.com/nightly/android/latest/armeabi-v7a/2048_libretro.so.zip";
if (!http_download_file(url, g_settings.libretro_info_path, "2048_libretro.so.zip"))
return -1;
#endif
return 0;
}