New API function iso_stream_get_source_path() tries to obtain a source

path depending on the stream class.
This commit is contained in:
Thomas Schmitt 2009-04-06 14:19:49 +02:00
parent f709a95fda
commit e8f8876ee6
2 changed files with 61 additions and 9 deletions

View File

@ -4067,20 +4067,22 @@ int iso_stream_update_size(IsoStream *stream);
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
ino_t *ino_id); ino_t *ino_id);
/* ts A90328 */ /* ts A90406 */
/** /**
* Obtain the eventual input stream of a filter stream. * Try to get eventual source path string of a stream. Meaning and availability
* of this string depends on the stream.class . Expect valid results with
* types "fsrc" and "cout".
* @param stream * @param stream
* The eventual filter stream to be inquired. * The stream to be inquired.
* @param flag * @param flag
* Bitfield for control purposes. Submit 0 for now. * Bitfield for control purposes, unused yet, submit 0
* @return * @return
* The input stream, if one exists. Elsewise NULL. * A copy of the path string. Apply free() when no longer needed.
* No extra reference to the stream is taken by this call. * NULL if no path string is available.
* *
* @since 0.6.18 * @since 0.6.18
*/ */
IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag); char *iso_stream_get_source_path(IsoStream *stream, int flag);
/************ Error codes and return values for libisofs ********************/ /************ Error codes and return values for libisofs ********************/
@ -4811,6 +4813,22 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
int iso_file_remove_filter(IsoFile *file, int flag); int iso_file_remove_filter(IsoFile *file, int flag);
/* ts A90328 */
/**
* Obtain the eventual input stream of a filter stream.
* @param stream
* The eventual filter stream to be inquired.
* @param flag
* Bitfield for control purposes. Submit 0 for now.
* @return
* The input stream, if one exists. Elsewise NULL.
* No extra reference to the stream is taken by this call.
*
* @since 0.6.18
*/
IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag);
/* ts A90402 */ /* ts A90402 */
/** /**
* Obtain the IsoExternalFilterCommand which is eventually associated with the * Obtain the IsoExternalFilterCommand which is eventually associated with the

View File

@ -14,6 +14,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include <stdio.h>
ino_t serial_id = (ino_t)1; ino_t serial_id = (ino_t)1;
ino_t mem_serial_id = (ino_t)1; ino_t mem_serial_id = (ino_t)1;
@ -638,6 +639,8 @@ void iso_stream_get_file_name(IsoStream *stream, char *name)
strcpy(name, "BOOT CATALOG"); strcpy(name, "BOOT CATALOG");
} else if (!strncmp(type, "mem ", 4)) { } else if (!strncmp(type, "mem ", 4)) {
strcpy(name, "MEM SOURCE"); strcpy(name, "MEM SOURCE");
} else if (!strncmp(type, "extf", 4)) {
strcpy(name, "EXTERNAL FILTER");
} else { } else {
strcpy(name, "UNKNOWN SOURCE"); strcpy(name, "UNKNOWN SOURCE");
} }
@ -653,3 +656,34 @@ IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag)
return class->get_input_stream(stream, 0); return class->get_input_stream(stream, 0);
} }
/* ts A90406 API */
char *iso_stream_get_source_path(IsoStream *stream, int flag)
{
char *path = NULL, ivd[80], *raw_path = NULL;
if (stream == NULL) {
return NULL;
}
if (stream->class == &fsrc_stream_class) {
FSrcStreamData *fsrc_data = stream->data;
path = iso_file_source_get_path(fsrc_data->src);
} else if (stream->class == &cut_out_stream_class) {
struct cut_out_stream *cout_data = stream->data;
raw_path = iso_file_source_get_path(cout_data->src);
sprintf(ivd, " %.f %.f",
(double) cout_data->offset, (double) cout_data->size);
path= calloc(strlen(raw_path) + strlen(ivd) + 1, 1);
if (path == NULL) {
goto ex;
}
strcpy(path, raw_path);
strcat(path, ivd);
}
ex:;
if (raw_path != NULL)
free(raw_path);
return path;
}