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)
|
||||
{
|
||||
// copy so that the lambda gets a copy as well
|
||||
Regex regex(parser[2].begin(), parser[2].end());
|
||||
String command = parser[3];
|
||||
Regex regex(parser[2].begin(), parser[2].end(),
|
||||
Regex::optimize | Regex::nosubs | Regex::ECMAScript);
|
||||
const String& command = parser[3];
|
||||
|
||||
auto hook_func = [=](StringView param, Context& context) {
|
||||
if (context.user_hooks_support().is_disabled())
|
||||
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)
|
||||
{
|
||||
StringView dir, file = path;
|
||||
ByteCount dir_end = -1;
|
||||
for (ByteCount i = 0; i < path.length(); ++i)
|
||||
{
|
||||
if (path[i] == '/')
|
||||
dir_end = i;
|
||||
}
|
||||
if (dir_end != -1)
|
||||
{
|
||||
dir = path.substr(0, dir_end + 1);
|
||||
file = path.substr(dir_end + 1);
|
||||
}
|
||||
return { dir, file };
|
||||
auto it = find(reversed(path), '/');
|
||||
if (it == path.rend())
|
||||
return { {}, path };
|
||||
const char* slash = it.base()-1;
|
||||
return { {path.begin(), slash}, {slash+1, path.end()} };
|
||||
}
|
||||
|
||||
String real_path(StringView filename)
|
||||
|
|
|
@ -32,6 +32,9 @@ String parse_filename(StringView filename);
|
|||
String real_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 read_fd(int fd);
|
||||
|
|
|
@ -22,9 +22,7 @@ ShellManager::ShellManager()
|
|||
if (path)
|
||||
new_path = path + ":"_str;
|
||||
|
||||
String kak_path = get_kak_binary_path();
|
||||
StringView kak_dir{kak_path.begin(), find(reversed(kak_path), '/').base()-1};
|
||||
new_path += kak_dir;
|
||||
new_path += split_path(get_kak_binary_path()).first;
|
||||
setenv("PATH", new_path.c_str(), 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user