[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) {
 | 
			
		||||
  vfs_node* root = get_session_machine()->vfs_root;
 | 
			
		||||
  vfs_node* node = find_node_by_path(root, path);
 | 
			
		||||
  if(node && node->type == FILE_NODE) {
 | 
			
		||||
  vfs_node* node = nullptr;
 | 
			
		||||
 | 
			
		||||
  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 "Error: file not found.";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user