Commit 75f2ac72 authored by Petri Hintukainen's avatar Petri Hintukainen

API: add functions to read files from VFS.

parent 38c7e68c
......@@ -3575,7 +3575,37 @@ int bd_get_sound_effect(BLURAY *bd, unsigned sound_id, BLURAY_SOUND_EFFECT *effe
}
/*
*
* Direct file access
*/
static int _bd_read_file(BLURAY *bd, const char *dir, const char *file, void **data, int64_t *size)
{
if (!bd || !bd->disc || !file || !data || !size) {
BD_DEBUG(DBG_CRIT, "Invalid arguments for bd_read_file()\n");
return 0;
}
*data = NULL;
*size = (int64_t)disc_read_file(bd->disc, dir, file, (uint8_t**)data);
if (!*data || *size < 0) {
BD_DEBUG(DBG_BLURAY, "bd_read_file() failed\n");
X_FREE(*data);
return 0;
}
BD_DEBUG(DBG_CRIT, "bd_read_file(): read %"PRId64" bytes from %s"DIR_SEP"%s\n",
*size, dir, file);
return 1;
}
int bd_read_file(BLURAY *bd, const char *path, void **data, int64_t *size)
{
return _bd_read_file(bd, NULL, path, data, size);
}
/*
* Metadata
*/
const struct meta_dl *bd_get_meta(BLURAY *bd)
......@@ -3612,6 +3642,15 @@ const struct meta_dl *bd_get_meta(BLURAY *bd)
return meta;
}
int bd_get_meta_file(BLURAY *bd, const char *name, void **data, int64_t *size)
{
return _bd_read_file(bd, DIR_SEP "BDMV" DIR_SEP "META" DIR_SEP "DL", name, data, size);
}
/*
* Database access
*/
struct clpi_cl *bd_get_clpi(BLURAY *bd, unsigned clip_ref)
{
if (bd->title && clip_ref < bd->title->clip_list.count) {
......
......@@ -355,12 +355,29 @@ const BLURAY_DISC_INFO *bd_get_disc_info(BLURAY *bd);
* If information is provided in multiple languages, currently
* selected language (BLURAY_PLAYER_SETTING_MENU_LANG) is used.
*
* Referenced thumbnail images should be read with bd_get_meta_file().
*
* @param bd BLURAY object
* @return META_DL (disclib) object, NULL on error
*/
struct meta_dl;
const struct meta_dl *bd_get_meta(BLURAY *bd);
/**
*
* Read metadata file from BluRay disc.
*
* Allocate large enough memory block and read file contents.
* Caller must free the memory block with free().
*
* @param bd BLURAY object
* @param file_name name of metadata file
* @param data where to store pointer to file data
* @param size where to store file size
* @return 1 on success, 0 on error
*/
int bd_get_meta_file(BLURAY *bd, const char *file_name, void **data, int64_t *size);
/*
* Title selection without on-disc menus
......@@ -1001,6 +1018,21 @@ void bd_free_bdjo(struct bdjo_data *);
int bd_start_bdj(BLURAY *bd, const char* start_object); // start BD-J from the specified BD-J object (should be a 5 character string)
void bd_stop_bdj(BLURAY *bd); // shutdown BD-J and clean up resources
/**
*
* Read a file from BluRay Virtual File System.
*
* Allocate large enough memory block and read file contents.
* Caller must free the memory block with free().
*
* @param bd BLURAY object
* @param file_name path to the file (relative to disc root)
* @param data where to store pointer to allocated data
* @param size where to store file size
* @return 1 on success, 0 on error
*/
int bd_read_file(BLURAY *, const char *path, void **data, int64_t *size);
#ifdef __cplusplus
}
......
......@@ -399,7 +399,11 @@ size_t disc_read_file(BD_DISC *disc, const char *dir, const char *file,
*data = NULL;
fp = disc_open_file(disc, dir, file);
if (dir) {
fp = disc_open_file(disc, dir, file);
} else {
fp = disc_open_path(disc, file);
}
if (!fp) {
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment