Change get_path() definition in IsoFileSource.

This commit is contained in:
Vreixo Formoso 2007-12-31 16:27:08 +01:00
parent 263770ab4f
commit baf7f14b11
4 changed files with 21 additions and 22 deletions

View File

@ -12,6 +12,7 @@
#include "fsource.h"
#include "error.h"
#include "util.h"
#include <stdlib.h>
#include <sys/types.h>
@ -32,8 +33,6 @@ IsoFilesystem *lfs= NULL;
typedef struct
{
/* IsoFilesystem *fs; It seems not needed */
char *path;
unsigned int openned :2; /* 0: not openned, 1: file, 2:dir */
union
@ -44,11 +43,11 @@ typedef struct
} _LocalFsFileSource;
static
const char* lfs_get_path(IsoFileSource *src)
char* lfs_get_path(IsoFileSource *src)
{
_LocalFsFileSource *data;
data = src->data;
return data->path;
return strdup(data->path);
}
static

View File

@ -76,10 +76,10 @@ typedef struct IsoFileSource_Iface
* belongs to.
*
* @return
* the path, that belong to the IsoFileSource and should not be
* freed by the user.
* the path of the FileSource inside the filesystem, it should be
* freed when no more needed.
*/
const char* (*get_path)(IsoFileSource *src);
char* (*get_path)(IsoFileSource *src);
/**
* Get the name of the file, with the dir component of the path.
@ -266,7 +266,7 @@ void iso_file_source_unref(IsoFileSource *src);
* this are just helpers to invoque methods in class
*/
extern inline
const char* iso_file_source_get_path(IsoFileSource *src)
char* iso_file_source_get_path(IsoFileSource *src)
{
return src->class->get_path(src);
}

View File

@ -118,7 +118,7 @@ char *fsrc_get_name(IsoStream *stream)
{
FSrcStreamData *data;
data = (FSrcStreamData*)stream->data;
return strdup(iso_file_source_get_path(data->src));
return iso_file_source_get_path(data->src);
}
static

View File

@ -460,8 +460,9 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
result = iso_file_source_open(dir);
if (result < 0) {
iso_msg_debug(image->messenger, "Can't open dir %s",
iso_file_source_get_path(dir));
char *path = iso_file_source_get_path(dir);
iso_msg_debug(image->messenger, "Can't open dir %s", path);
free(path);
return result;
}
@ -469,24 +470,23 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
action = 1;
while ( (result = iso_file_source_readdir(dir, &file)) == 1) {
int flag;
char *name;
char *name, *path;
IsoNode *new;
name = iso_file_source_get_name(file);
path = iso_file_source_get_path(file);
if (check_excludes(image, iso_file_source_get_path(file))) {
iso_msg_debug(image->messenger, "Skipping excluded file %s",
iso_file_source_get_path(file));
if (check_excludes(image, path)) {
iso_msg_debug(image->messenger, "Skipping excluded file %s", path);
action = 2;
} else if (check_hidden(image, name)) {
iso_msg_debug(image->messenger, "Skipping hidden file %s",
iso_file_source_get_path(file));
iso_msg_debug(image->messenger, "Skipping hidden file %s", path);
action = 2;
} else {
iso_msg_debug(image->messenger, "Adding file %s",
iso_file_source_get_path(file));
iso_msg_debug(image->messenger, "Adding file %s", path);
action = 1;
}
free(path);
/* find place where to insert */
flag = 0;
@ -522,10 +522,10 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
/* ok, file will be added */
result = builder->create_node(builder, image, file, &new);
if (result < 0) {
char *path = iso_file_source_get_path(file);
iso_msg_note(image->messenger, LIBISO_FILE_IGNORED,
"Error %d when adding file %s", result,
iso_file_source_get_path(file));
"Error %d when adding file %s", result, path);
free(path);
if (image->recOpts.report) {
action = image->recOpts.report(file, result, flag);