18 #include <drizzled/internal/my_sys.h>
19 #include <drizzled/internal/m_string.h>
32 size_t dirname_length(
const char *name)
34 const char *pos, *gpos;
36 if ((pos=(
char*)strrchr(name,FN_DEVCHAR)) == 0)
43 if (*pos == FN_LIBCHAR || *pos ==
'/')
63 size_t dirname_part(
char *to,
const char *name,
size_t *to_res_length)
67 length=dirname_length(name);
68 *to_res_length= (size_t) (convert_dirname(to, name, name+length) - to);
100 #define FN_DEVCHAR '\0'
103 char *convert_dirname(
char *to,
const char *from,
const char *from_end)
108 if (!from_end || (from_end - from) > FN_REFLEN-2)
109 from_end=from+FN_REFLEN -2;
111 #if FN_LIBCHAR != '/'
113 for (; from != from_end && *from ; from++)
126 size_t len= min(strlen(from),(
size_t)(from_end-from));
127 void *ret= memmove(to, from, len);
134 if (to != to_org && (to[-1] != FN_LIBCHAR && to[-1] != FN_DEVCHAR))