Unified burn_file_source and burn_fd_source

ZeroThreeEight
Thomas Schmitt 16 years ago
parent f5a350f2cc
commit 55e6c0ba82

@ -1 +1 @@
#define Cdrskin_timestamP "2007.01.25.185214"
#define Cdrskin_timestamP "2007.01.26.173236"

@ -42,7 +42,7 @@ static int file_read(struct burn_source *source,
unsigned char *buffer,
int size)
{
struct burn_source_fd *fs = source->data;
struct burn_source_file *fs = source->data;
return read_full_buffer(fs->datafd, buffer, size);
}
@ -75,9 +75,6 @@ static off_t file_size(struct burn_source *source)
return fs->fixed_size;
if (fstat(fs->datafd, &buf) == -1)
return (off_t) 0;
/* for now we keep it compatible to the old (int) return value */
if(buf.st_size >= 1308622848) /* 2 GB - 800 MB to prevent rollover */
return (off_t) 1308622848;
return (off_t) buf.st_size;
}
@ -132,84 +129,27 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath)
}
/* ------ provisory location for the new source subclass fd --------- */
static off_t fd_get_size(struct burn_source *source)
{
struct stat buf;
struct burn_source_fd *fs = source->data;
if (fs->fixed_size > 0)
return fs->fixed_size;
if (fstat(fs->datafd, &buf) == -1)
return (off_t) 0;
/* for now we keep it compatible to the old (int) return value */
if (buf.st_size >= 1308622848) /* 2 GB - 800 MB to prevent rollover */
return (off_t) 1308622848;
return buf.st_size;
}
/* ts A70125 */
static int fd_set_size(struct burn_source *source, off_t size)
{
struct burn_source_fd *fs = source->data;
fs->fixed_size = size;
return 1;
}
static int fd_read(struct burn_source *source,
unsigned char *buffer,
int size)
{
struct burn_source_fd *fs = source->data;
return read_full_buffer(fs->datafd, buffer, size);
}
static int fd_read_sub(struct burn_source *source,
unsigned char *buffer,
int size)
{
struct burn_source_fd *fs = source->data;
return read_full_buffer(fs->subfd, buffer, size);
}
static void fd_free_data(struct burn_source *source)
{
struct burn_source_fd *fs = source->data;
close(fs->datafd);
if (source->read_sub)
close(fs->subfd);
free(fs);
}
/* ts A70126 : removed class burn_source_fd in favor of burn_source_file */
struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size)
{
struct burn_source_fd *fs;
struct burn_source_file *fs;
struct burn_source *src;
if (datafd == -1)
return NULL;
fs = malloc(sizeof(struct burn_source_fd));
fs = malloc(sizeof(struct burn_source_file));
fs->datafd = datafd;
fs->subfd = subfd;
fs->fixed_size = size;
src = burn_source_new();
src->read = fd_read;
src->read = file_read;
if(subfd != -1)
src->read = fd_read_sub;
src->get_size = fd_get_size;
src->set_size = fd_set_size;
src->free_data = fd_free_data;
src->read = file_read_sub;
src->get_size = file_size;
src->set_size = file_set_size;
src->free_data = file_free;
src->data = fs;
return src;
}

@ -3,11 +3,6 @@
#ifndef BURN__FILE_H
#define BURN__FILE_H
/* ts A70125 :
Looks like burn_source_file and burn_source_fd become identical because
of the need to set a fixed_size of at least 600 kB.
I will try to unify both classes.
*/
struct burn_source_file
{
int datafd;
@ -16,13 +11,7 @@ struct burn_source_file
};
/* ------ provisory location for the new source subclass fd --------- */
/* ts A70126 : burn_source_file obsoleted burn_source_fd */
struct burn_source_fd
{
int datafd;
int subfd;
off_t fixed_size;
};
#endif /* LIBBURN__FILE_H */

Loading…
Cancel
Save