mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-05 06:20:44 +09:00
File chooser navigation
This commit is contained in:
@@ -166,4 +166,22 @@ namespace gsr {
|
||||
fclose(file);
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string get_parent_directory(std::string_view directory) {
|
||||
std::string result;
|
||||
|
||||
while(directory.size() > 1 && directory.back() == '/') {
|
||||
directory.remove_suffix(1);
|
||||
}
|
||||
|
||||
const size_t prev_slash_index = directory.rfind('/');
|
||||
if(prev_slash_index == 0) {
|
||||
result = "/";
|
||||
} else if(prev_slash_index == std::string_view::npos) {
|
||||
result = ".";
|
||||
} else {
|
||||
result = directory.substr(0, prev_slash_index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user