/
githubmirror
/
ndctl
Обзор
Документация
Войти
/
githubmirror
/
ndctl
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
util/abspath.c
26 строк
606 B
Dan Williams
Rework license identification
17 дек 2020, 09:38
17 дек 2020, 09:38
14eacf0
Код
Авторство
О чём код?
// SPDX-License-Identifier: GPL-2.0 /* originally copied from git/abspath.c */ #include <util/util.h> #include <util/strbuf.h> char *prefix_filename(const char *pfx, const char *arg) { struct strbuf path = STRBUF_INIT; size_t pfx_len = pfx ? strlen(pfx) : 0; if (pfx_len && !is_absolute_path(arg)) strbuf_add(&path, pfx, pfx_len); strbuf_addstr(&path, arg); return strbuf_detach(&path, NULL); } void fix_filename(const char *prefix, const char **file) { if (!file || !*file || !prefix || is_absolute_path(*file) || !strcmp("-", *file)) return; *file = prefix_filename(prefix, *file); }