ArchivePlugin: scan_next() returns const string
This commit is contained in:
parent
e66005563e
commit
a42f9fd4e2
@ -70,7 +70,7 @@ archive_file_scan_reset(struct archive_file *file)
|
|||||||
file->plugin->scan_reset(file);
|
file->plugin->scan_reset(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
archive_file_scan_next(struct archive_file *file)
|
archive_file_scan_next(struct archive_file *file)
|
||||||
{
|
{
|
||||||
assert(file != NULL);
|
assert(file != NULL);
|
||||||
|
@ -62,7 +62,7 @@ struct archive_plugin {
|
|||||||
* (as pathnames) and move read index to next file. When there is no
|
* (as pathnames) and move read index to next file. When there is no
|
||||||
* next file it return NULL.
|
* next file it return NULL.
|
||||||
*/
|
*/
|
||||||
char *(*scan_next)(struct archive_file *);
|
const char *(*scan_next)(struct archive_file *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens an input_stream of a file within the archive.
|
* Opens an input_stream of a file within the archive.
|
||||||
@ -98,7 +98,7 @@ archive_file_close(struct archive_file *file);
|
|||||||
void
|
void
|
||||||
archive_file_scan_reset(struct archive_file *file);
|
archive_file_scan_reset(struct archive_file *file);
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
archive_file_scan_next(struct archive_file *file);
|
archive_file_scan_next(struct archive_file *file);
|
||||||
|
|
||||||
struct input_stream *
|
struct input_stream *
|
||||||
|
@ -33,17 +33,19 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_archive_tree(Directory *directory, char *name)
|
update_archive_tree(Directory *directory, const char *name)
|
||||||
{
|
{
|
||||||
char *tmp = strchr(name, '/');
|
const char *tmp = strchr(name, '/');
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
*tmp = 0;
|
char *child_name = g_strndup(name, tmp - name);
|
||||||
//add dir is not there already
|
//add dir is not there already
|
||||||
db_lock();
|
db_lock();
|
||||||
Directory *subdir =
|
Directory *subdir =
|
||||||
directory->MakeChild(name);
|
directory->MakeChild(child_name);
|
||||||
subdir->device = DEVICE_INARCHIVE;
|
subdir->device = DEVICE_INARCHIVE;
|
||||||
db_unlock();
|
db_unlock();
|
||||||
|
g_free(child_name);
|
||||||
|
|
||||||
//create directories first
|
//create directories first
|
||||||
update_archive_tree(subdir, tmp+1);
|
update_archive_tree(subdir, tmp+1);
|
||||||
} else {
|
} else {
|
||||||
@ -122,7 +124,7 @@ update_archive_file2(Directory *parent, const char *name,
|
|||||||
|
|
||||||
archive_file_scan_reset(file);
|
archive_file_scan_reset(file);
|
||||||
|
|
||||||
char *filepath;
|
const char *filepath;
|
||||||
while ((filepath = archive_file_scan_next(file)) != NULL) {
|
while ((filepath = archive_file_scan_next(file)) != NULL) {
|
||||||
/* split name into directory and file */
|
/* split name into directory and file */
|
||||||
g_debug("adding archive file: %s", filepath);
|
g_debug("adding archive file: %s", filepath);
|
||||||
|
@ -158,11 +158,11 @@ bz2_scan_reset(struct archive_file *file)
|
|||||||
context->reset = true;
|
context->reset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
bz2_scan_next(struct archive_file *file)
|
bz2_scan_next(struct archive_file *file)
|
||||||
{
|
{
|
||||||
Bzip2ArchiveFile *context = (Bzip2ArchiveFile *) file;
|
Bzip2ArchiveFile *context = (Bzip2ArchiveFile *) file;
|
||||||
char *name = NULL;
|
const char *name = NULL;
|
||||||
|
|
||||||
if (context->reset) {
|
if (context->reset) {
|
||||||
name = context->name;
|
name = context->name;
|
||||||
|
@ -141,16 +141,16 @@ iso9660_archive_scan_reset(struct archive_file *file)
|
|||||||
context->iter = context->list;
|
context->iter = context->list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
iso9660_archive_scan_next(struct archive_file *file)
|
iso9660_archive_scan_next(struct archive_file *file)
|
||||||
{
|
{
|
||||||
Iso9660ArchiveFile *context =
|
Iso9660ArchiveFile *context =
|
||||||
(Iso9660ArchiveFile *)file;
|
(Iso9660ArchiveFile *)file;
|
||||||
|
|
||||||
char *data = NULL;
|
const char *data = NULL;
|
||||||
if (context->iter != NULL) {
|
if (context->iter != NULL) {
|
||||||
///fetch data and goto next
|
///fetch data and goto next
|
||||||
data = (char *)context->iter->data;
|
data = (const char *)context->iter->data;
|
||||||
context->iter = g_slist_next(context->iter);
|
context->iter = g_slist_next(context->iter);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -109,14 +109,14 @@ zzip_archive_scan_reset(struct archive_file *file)
|
|||||||
context->iter = context->list;
|
context->iter = context->list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
zzip_archive_scan_next(struct archive_file *file)
|
zzip_archive_scan_next(struct archive_file *file)
|
||||||
{
|
{
|
||||||
ZzipArchiveFile *context = (ZzipArchiveFile *) file;
|
ZzipArchiveFile *context = (ZzipArchiveFile *) file;
|
||||||
char *data = NULL;
|
const char *data = NULL;
|
||||||
if (context->iter != NULL) {
|
if (context->iter != NULL) {
|
||||||
///fetch data and goto next
|
///fetch data and goto next
|
||||||
data = (char *)context->iter->data;
|
data = (const char *)context->iter->data;
|
||||||
context->iter = g_slist_next(context->iter);
|
context->iter = g_slist_next(context->iter);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
Reference in New Issue
Block a user