[Refactor] Use Lua script for C2S_BUILD_FILE handling.
This commit is contained in:
		
							parent
							
								
									ea6853f037
								
							
						
					
					
						commit
						785e6ddc38
					
				@ -222,14 +222,13 @@ void NetworkManager::on_message(std::shared_ptr<net::TcpConnection> connection,
 | 
			
		||||
            /* Save the file to ensure the VFS is up to date. */
 | 
			
		||||
            session->write_file(path, content);
 | 
			
		||||
 | 
			
		||||
            /* The 'build.lua' script is just a wrapper around 'api::create_executable'. */
 | 
			
		||||
            std::string exec_path = path;
 | 
			
		||||
            size_t dot_pos = exec_path.rfind(".lua");
 | 
			
		||||
            if(dot_pos != std::string::npos) {
 | 
			
		||||
              exec_path.erase(dot_pos);
 | 
			
		||||
            }
 | 
			
		||||
            /* The api function returns an error string, but we'll ignore it here for now. */
 | 
			
		||||
            api::create_executable(*session, exec_path, content);
 | 
			
		||||
            /* Execute the build command via the session. */
 | 
			
		||||
            std::string response = session->process_command("build " + path);
 | 
			
		||||
            /* Send response back to client. */
 | 
			
		||||
            std::string new_prompt = get_full_path(session->get_current_dir());
 | 
			
		||||
            response += "\n" + new_prompt;
 | 
			
		||||
            connection->send(net_protocol::build_message(net_protocol::Opcode::S2C_COMMAND_RESPONSE,
 | 
			
		||||
                                                         {args[0], response}));
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user