MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / normalize_dirname

Function normalize_dirname

mysys/mf_pack.c:294–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292*/
293
294size_t normalize_dirname(char *to, const char *from)
295{
296 size_t length;
297 char buff[FN_REFLEN];
298 DBUG_ENTER("normalize_dirname");
299
300 /*
301 Despite the name, this actually converts the name to the system's
302 format (TODO: name this properly).
303 */
304 (void) intern_filename(buff, from);
305 length= strlen(buff); /* Fix that '/' is last */
306 if (length &&
307#ifdef FN_DEVCHAR
308 buff[length - 1] != FN_DEVCHAR &&
309#endif
310 buff[length - 1] != FN_LIBCHAR && buff[length - 1] != '/')
311 {
312 /* we need reserve 2 bytes for the trailing slash and the zero */
313 if (length >= sizeof (buff) - 1)
314 length= sizeof (buff) - 2;
315 buff[length]= FN_LIBCHAR;
316 buff[length + 1]= '\0';
317 }
318
319 length=cleanup_dirname(to, buff);
320
321 DBUG_RETURN(length);
322}
323
324
325/**

Callers 2

unpack_dirnameFunction · 0.85
add_directoryFunction · 0.85

Calls 2

intern_filenameFunction · 0.85
cleanup_dirnameFunction · 0.85

Tested by

no test coverage detected