Make split_path public
This commit is contained in:
parent
2f20399d03
commit
b4f6b50dbb
|
@ -591,9 +591,10 @@ const CommandDesc add_hook_cmd = {
|
||||||
},
|
},
|
||||||
[](const ParametersParser& parser, Context& context)
|
[](const ParametersParser& parser, Context& context)
|
||||||
{
|
{
|
||||||
// copy so that the lambda gets a copy as well
|
Regex regex(parser[2].begin(), parser[2].end(),
|
||||||
Regex regex(parser[2].begin(), parser[2].end());
|
Regex::optimize | Regex::nosubs | Regex::ECMAScript);
|
||||||
String command = parser[3];
|
const String& command = parser[3];
|
||||||
|
|
||||||
auto hook_func = [=](StringView param, Context& context) {
|
auto hook_func = [=](StringView param, Context& context) {
|
||||||
if (context.user_hooks_support().is_disabled())
|
if (context.user_hooks_support().is_disabled())
|
||||||
return;
|
return;
|
||||||
|
|
18
src/file.cc
18
src/file.cc
|
@ -56,19 +56,11 @@ String parse_filename(StringView filename)
|
||||||
|
|
||||||
std::pair<StringView, StringView> split_path(StringView path)
|
std::pair<StringView, StringView> split_path(StringView path)
|
||||||
{
|
{
|
||||||
StringView dir, file = path;
|
auto it = find(reversed(path), '/');
|
||||||
ByteCount dir_end = -1;
|
if (it == path.rend())
|
||||||
for (ByteCount i = 0; i < path.length(); ++i)
|
return { {}, path };
|
||||||
{
|
const char* slash = it.base()-1;
|
||||||
if (path[i] == '/')
|
return { {path.begin(), slash}, {slash+1, path.end()} };
|
||||||
dir_end = i;
|
|
||||||
}
|
|
||||||
if (dir_end != -1)
|
|
||||||
{
|
|
||||||
dir = path.substr(0, dir_end + 1);
|
|
||||||
file = path.substr(dir_end + 1);
|
|
||||||
}
|
|
||||||
return { dir, file };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String real_path(StringView filename)
|
String real_path(StringView filename)
|
||||||
|
|
|
@ -32,6 +32,9 @@ String parse_filename(StringView filename);
|
||||||
String real_path(StringView filename);
|
String real_path(StringView filename);
|
||||||
String compact_path(StringView filename);
|
String compact_path(StringView filename);
|
||||||
|
|
||||||
|
// returns pair { directory, filename }
|
||||||
|
std::pair<StringView, StringView> split_path(StringView path);
|
||||||
|
|
||||||
String get_kak_binary_path();
|
String get_kak_binary_path();
|
||||||
|
|
||||||
String read_fd(int fd);
|
String read_fd(int fd);
|
||||||
|
|
|
@ -22,9 +22,7 @@ ShellManager::ShellManager()
|
||||||
if (path)
|
if (path)
|
||||||
new_path = path + ":"_str;
|
new_path = path + ":"_str;
|
||||||
|
|
||||||
String kak_path = get_kak_binary_path();
|
new_path += split_path(get_kak_binary_path()).first;
|
||||||
StringView kak_dir{kak_path.begin(), find(reversed(kak_path), '/').base()-1};
|
|
||||||
new_path += kak_dir;
|
|
||||||
setenv("PATH", new_path.c_str(), 1);
|
setenv("PATH", new_path.c_str(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user