Add fix_dir_separators util

This commit is contained in:
bnnm 2018-11-24 00:44:17 +01:00
parent ecde3e0ce0
commit e8ca19ba2c
3 changed files with 15 additions and 13 deletions

View File

@ -365,20 +365,9 @@ static int add_filename(txtp_header * txtp, char *filename) {
}
/* hack to allow relative paths in various OSs */
{
char c;
fix_dir_separators(filename); /* clean paths */
i = 0;
while ((c = filename[i]) != '\0') {
if ((c == '\\' && DIR_SEPARATOR == '/') || (c == '/' && DIR_SEPARATOR == '\\'))
filename[i] = DIR_SEPARATOR;
i++;
}
}
/* add filesnames */
/* add filenames */
for (i = range_start; i < range_end; i++){
txtp_entry *current;

View File

@ -955,6 +955,17 @@ fail:
return 0;
}
/* hack to allow relative paths in various OSs */
void fix_dir_separators(char * filename) {
char c;
int i = 0;
while ((c = filename[i]) != '\0') {
if ((c == '\\' && DIR_SEPARATOR == '/') || (c == '/' && DIR_SEPARATOR == '\\'))
filename[i] = DIR_SEPARATOR;
i++;
}
}
/**
* Checks if the stream filename is one of the extensions (comma-separated, ex. "adx" or "adx,aix").

View File

@ -206,6 +206,8 @@ size_t read_string(char * buf, size_t bufsize, off_t offset, STREAMFILE *streamF
size_t read_key_file(uint8_t * buf, size_t bufsize, STREAMFILE *streamFile);
void fix_dir_separators(char * filename);
int check_extensions(STREAMFILE *streamFile, const char * cmp_exts);
int find_chunk_be(STREAMFILE *streamFile, uint32_t chunk_id, off_t start_offset, int full_chunk_size, off_t *out_chunk_offset, size_t *out_chunk_size);