forked from len0rd/rockbox
FS#13519: multivolume: Ensure absolute paths get drive designation
Change-Id: I8419af670ca101b11bba29d9fd577f21fa22fd42
This commit is contained in:
parent
aeb4b6c34a
commit
7d3cc24dec
2 changed files with 36 additions and 5 deletions
|
@ -70,7 +70,7 @@
|
|||
flushed to disk when required.
|
||||
*/
|
||||
|
||||
//#define LOGF_ENABLE
|
||||
// #define LOGF_ENABLE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
@ -592,6 +592,8 @@ static ssize_t format_track_path(char *dest, char *src, int buf_length,
|
|||
dlen = -1u;
|
||||
}
|
||||
|
||||
logf("dir: %s", dir);
|
||||
|
||||
len = path_append_ex(dest, dir, dlen, src, buf_length);
|
||||
if (len >= (size_t)buf_length)
|
||||
return -1; /* buffer too small */
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include "file_internal.h"
|
||||
#include "debug.h"
|
||||
|
||||
// #define LOGF_ENABLE
|
||||
#include "logf.h"
|
||||
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#include "storage.h"
|
||||
|
||||
|
@ -521,10 +524,36 @@ size_t path_append_ex(char *buf, const char *basepath, size_t basepath_max,
|
|||
|
||||
if (path_is_absolute(component)) /* starts with a '/' path separator */
|
||||
{
|
||||
/* 'component' is absolute; replace all */
|
||||
basepath = component;
|
||||
component = "";
|
||||
basepath_max = -1u;
|
||||
#if defined(HAVE_MULTIVOLUME)
|
||||
const char *baseend;
|
||||
/* our component doesn't appear to have a drive/volume */
|
||||
if (path_strip_volume(component, &baseend, false) == ROOT_VOLUME)
|
||||
{
|
||||
/* find the basepath's drive/volume name, if it has one.
|
||||
* ensure basepath is not NULL, that causes a crash on sim */
|
||||
if (basepath != NULL && path_strip_volume(basepath, &baseend, false) != ROOT_VOLUME)
|
||||
{
|
||||
basepath_max = baseend - basepath;
|
||||
/* strip leading separators from component */
|
||||
while (*component == PATH_SEPCH)
|
||||
component++;
|
||||
} else {
|
||||
/* component is absolute with no drive/volume, but basepath doesn't
|
||||
* have a volume either... we must be on root volume */
|
||||
basepath = component;
|
||||
component = "";
|
||||
basepath_max = -1u;
|
||||
}
|
||||
}
|
||||
/* else component likely already has drive/volume name */
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* 'component' is absolute; replace all */
|
||||
basepath = component;
|
||||
component = "";
|
||||
basepath_max = -1u;
|
||||
}
|
||||
}
|
||||
|
||||
/* if basepath is not null or empty, buffer contents are replaced,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue