16 #include "mysys_priv.h"
21 size_t dirname_length(
const char *
name)
23 register char *pos, *gpos;
24 #ifdef BASKSLASH_MBTAIL
28 if ((pos=(
char*)strrchr(name,FN_DEVCHAR)) == 0)
35 #ifdef BASKSLASH_MBTAIL
37 if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3)))
43 if (*pos == FN_LIBCHAR || *pos ==
'/')
46 return (
size_t) (gpos+1-(
char*) name);
63 size_t dirname_part(
char *
to,
const char *name,
size_t *to_res_length)
66 DBUG_ENTER(
"dirname_part");
67 DBUG_PRINT(
"enter",(
"'%s'",name));
69 length=dirname_length(name);
70 *to_res_length= (size_t) (convert_dirname(to, name, name+length) -
to);
101 #define FN_DEVCHAR '\0'
104 char *convert_dirname(
char *to,
const char *from,
const char *from_end)
107 #ifdef BACKSLASH_MBTAIL
110 DBUG_ENTER(
"convert_dirname");
113 if (!from_end || (from_end - from) > FN_REFLEN-2)
114 from_end=from+FN_REFLEN -2;
116 #if FN_LIBCHAR != '/'
118 for (; from != from_end && *from ; from++)
124 #ifdef BACKSLASH_MBTAIL
126 if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3)))
128 memmove(to, from, l);
144 to= strmake(to, from, (
size_t) (from_end-from));
148 if (to != to_org && (to[-1] != FN_LIBCHAR && to[-1] != FN_DEVCHAR))