use StringView::zstr() in place of StringView::str().c_str()
This commit is contained in:
parent
7cdb94d5c7
commit
61619d82bf
10
src/file.cc
10
src/file.cc
|
@ -35,7 +35,7 @@ String parse_filename(StringView filename)
|
||||||
while (end != filename.length() and is_word(filename[end]))
|
while (end != filename.length() and is_word(filename[end]))
|
||||||
++end;
|
++end;
|
||||||
StringView var_name = filename.substr(i+1, end - i - 1);
|
StringView var_name = filename.substr(i+1, end - i - 1);
|
||||||
const char* var_value = getenv(var_name.str().c_str());
|
const char* var_value = getenv(var_name.zstr());
|
||||||
if (var_value)
|
if (var_value)
|
||||||
result += var_value;
|
result += var_value;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ String real_path(StringView filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[PATH_MAX+1];
|
char buffer[PATH_MAX+1];
|
||||||
char* res = realpath(dirname.str().c_str(), buffer);
|
char* res = realpath(dirname.zstr(), buffer);
|
||||||
if (not res)
|
if (not res)
|
||||||
throw file_not_found{dirname};
|
throw file_not_found{dirname};
|
||||||
return res + "/"_str + basename;
|
return res + "/"_str + basename;
|
||||||
|
@ -244,7 +244,7 @@ String find_file(StringView filename, memoryview<String> paths)
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (filename.length() > 1 and filename[0] == '/')
|
if (filename.length() > 1 and filename[0] == '/')
|
||||||
{
|
{
|
||||||
if (stat(filename.str().c_str(), &buf) == 0 and S_ISREG(buf.st_mode))
|
if (stat(filename.zstr(), &buf) == 0 and S_ISREG(buf.st_mode))
|
||||||
return filename.str();
|
return filename.str();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ std::vector<String> list_files(StringView prefix, StringView dirname,
|
||||||
Filter filter)
|
Filter filter)
|
||||||
{
|
{
|
||||||
kak_assert(dirname.empty() or dirname.back() == '/');
|
kak_assert(dirname.empty() or dirname.back() == '/');
|
||||||
DIR* dir = opendir(dirname.empty() ? "./" : dirname.str().c_str());
|
DIR* dir = opendir(dirname.empty() ? "./" : dirname.zstr());
|
||||||
if (not dir)
|
if (not dir)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ std::vector<String> complete_command(StringView prefix, ByteCount cursor_pos)
|
||||||
time_t get_fs_timestamp(StringView filename)
|
time_t get_fs_timestamp(StringView filename)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(filename.str().c_str(), &st) != 0)
|
if (stat(filename.zstr(), &st) != 0)
|
||||||
return InvalidTime;
|
return InvalidTime;
|
||||||
return st.st_mtime;
|
return st.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user