mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Minor tweaks to get_streamfile_name and co
This commit is contained in:
parent
dabbf07014
commit
2b63d451d9
@ -385,14 +385,14 @@ static STREAMFILE * open_txth(STREAMFILE * streamFile) {
|
||||
STREAMFILE * streamText;
|
||||
|
||||
/* try "(path/)(name.ext).txth" */
|
||||
if (!get_streamfile_name(streamFile,filename,PATH_LIMIT)) goto fail;
|
||||
get_streamfile_name(streamFile,filename,PATH_LIMIT);
|
||||
strcat(filename, ".txth");
|
||||
streamText = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (streamText) return streamText;
|
||||
|
||||
/* try "(path/)(.ext).txth" */
|
||||
if (!get_streamfile_path(streamFile,filename,PATH_LIMIT)) goto fail;
|
||||
if (!get_streamfile_ext(streamFile,fileext,PATH_LIMIT)) goto fail;
|
||||
get_streamfile_path(streamFile,filename,PATH_LIMIT);
|
||||
get_streamfile_ext(streamFile,fileext,PATH_LIMIT);
|
||||
strcat(filename,".");
|
||||
strcat(filename, fileext);
|
||||
strcat(filename, ".txth");
|
||||
@ -400,14 +400,13 @@ static STREAMFILE * open_txth(STREAMFILE * streamFile) {
|
||||
if (streamText) return streamText;
|
||||
|
||||
/* try "(path/).txth" */
|
||||
if (!get_streamfile_path(streamFile,filename,PATH_LIMIT)) goto fail;
|
||||
get_streamfile_path(streamFile,filename,PATH_LIMIT);
|
||||
strcat(filename, ".txth");
|
||||
streamText = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (streamText) return streamText;
|
||||
|
||||
fail:
|
||||
/* not found */
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Simple text parser of "key = value" lines.
|
||||
|
@ -772,7 +772,7 @@ STREAMFILE * open_stream_ext(STREAMFILE *streamFile, const char * ext) {
|
||||
return streamFile->open(streamFile,filename_ext,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/* Opens an stream using the passed name (in the same folder) */
|
||||
/* Opens an stream using the passed name, in the same folder */
|
||||
STREAMFILE * open_stream_name(STREAMFILE *streamFile, const char * name) {
|
||||
char foldername[PATH_LIMIT];
|
||||
char filename[PATH_LIMIT];
|
||||
@ -871,9 +871,8 @@ fail:
|
||||
|
||||
|
||||
/**
|
||||
* checks if the stream filename is one of the extensions (comma-separated, ex. "adx" or "adx,aix")
|
||||
*
|
||||
* returns 0 on failure
|
||||
* Checks if the stream filename is one of the extensions (comma-separated, ex. "adx" or "adx,aix").
|
||||
* Empty is ok to accept files without extension ("", "adx,,aix"). Returns 0 on failure
|
||||
*/
|
||||
int check_extensions(STREAMFILE *streamFile, const char * cmp_exts) {
|
||||
char filename[PATH_LIMIT];
|
||||
@ -948,14 +947,15 @@ int find_chunk(STREAMFILE *streamFile, uint32_t chunk_id, off_t start_offset, in
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_streamfile_name(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
void get_streamfile_name(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
streamFile->get_name(streamFile,buffer,size);
|
||||
return 1;
|
||||
}
|
||||
int get_streamfile_filename(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
/* copies the filename without path */
|
||||
void get_streamfile_filename(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
char foldername[PATH_LIMIT];
|
||||
const char *path;
|
||||
|
||||
|
||||
streamFile->get_name(streamFile,foldername,sizeof(foldername));
|
||||
|
||||
//todo Windows CMD accepts both \\ and /, better way to handle this?
|
||||
@ -971,9 +971,8 @@ int get_streamfile_filename(STREAMFILE *streamFile, char * buffer, size_t size)
|
||||
} else {
|
||||
strcpy(buffer, foldername);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int get_streamfile_path(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
void get_streamfile_path(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
const char *path;
|
||||
|
||||
streamFile->get_name(streamFile,buffer,size);
|
||||
@ -986,11 +985,8 @@ int get_streamfile_path(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
} else {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
int get_streamfile_ext(STREAMFILE *streamFile, char * filename, size_t size) {
|
||||
void get_streamfile_ext(STREAMFILE *streamFile, char * filename, size_t size) {
|
||||
streamFile->get_name(streamFile,filename,size);
|
||||
strcpy(filename, filename_extension(filename));
|
||||
return 1;
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ int find_chunk_be(STREAMFILE *streamFile, uint32_t chunk_id, off_t start_offset,
|
||||
int find_chunk_le(STREAMFILE *streamFile, uint32_t chunk_id, off_t start_offset, int full_chunk_size, off_t *out_chunk_offset, size_t *out_chunk_size);
|
||||
int find_chunk(STREAMFILE *streamFile, uint32_t chunk_id, off_t start_offset, int full_chunk_size, off_t *out_chunk_offset, size_t *out_chunk_size, int size_big_endian, int zero_size_end);
|
||||
|
||||
int get_streamfile_name(STREAMFILE *streamFile, char * buffer, size_t size);
|
||||
int get_streamfile_filename(STREAMFILE *streamFile, char * buffer, size_t size);
|
||||
int get_streamfile_path(STREAMFILE *streamFile, char * buffer, size_t size);
|
||||
int get_streamfile_ext(STREAMFILE *streamFile, char * filename, size_t size);
|
||||
void get_streamfile_name(STREAMFILE *streamFile, char * buffer, size_t size);
|
||||
void get_streamfile_filename(STREAMFILE *streamFile, char * buffer, size_t size);
|
||||
void get_streamfile_path(STREAMFILE *streamFile, char * buffer, size_t size);
|
||||
void get_streamfile_ext(STREAMFILE *streamFile, char * filename, size_t size);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user