[Add] Allow editing of executable scripts.
This commit is contained in:
parent
beae5c45a4
commit
20f2e5a104
@ -118,8 +118,19 @@ std::string Session::write_file(const std::string& path, const std::string& cont
|
|||||||
|
|
||||||
std::string Session::read_file(const std::string& path) {
|
std::string Session::read_file(const std::string& path) {
|
||||||
vfs_node* root = get_session_machine()->vfs_root;
|
vfs_node* root = get_session_machine()->vfs_root;
|
||||||
vfs_node* node = find_node_by_path(root, path);
|
vfs_node* node = nullptr;
|
||||||
if(node && node->type == FILE_NODE) {
|
|
||||||
|
if(path[0] == '/') {
|
||||||
|
node = find_node_by_path(root, path);
|
||||||
|
} else {
|
||||||
|
/* Relative path. */
|
||||||
|
vfs_node* current_dir = get_current_dir();
|
||||||
|
if(current_dir->children.count(path)) {
|
||||||
|
node = current_dir->children.at(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(node && (node->type == FILE_NODE || node->type == EXEC_NODE)) {
|
||||||
return node->content;
|
return node->content;
|
||||||
}
|
}
|
||||||
return "Error: file not found.";
|
return "Error: file not found.";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user