mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Add util to get base filename without path
This commit is contained in:
parent
494dfb8194
commit
15ca185052
@ -993,6 +993,29 @@ int 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) {
|
||||
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?
|
||||
path = strrchr(foldername,'\\');
|
||||
if (!path)
|
||||
path = strrchr(foldername,'/');
|
||||
if (path != NULL)
|
||||
path = path+1;
|
||||
|
||||
//todo validate sizes and copy sensible max
|
||||
if (path) {
|
||||
VGM_LOG("path\n");
|
||||
strcpy(buffer, path);
|
||||
} else {
|
||||
VGM_LOG("no path\n");
|
||||
strcpy(buffer, foldername);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int get_streamfile_path(STREAMFILE *streamFile, char * buffer, size_t size) {
|
||||
const char *path;
|
||||
|
||||
|
@ -179,6 +179,7 @@ int find_chunk_le(STREAMFILE *streamFile, uint32_t chunk_id, off_t start_offset,
|
||||
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);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user