Skip to content

UOperatingSystemTerminal

#include <OperatingSystemSimulator/Public/Programs/Terminal/OperatingSystemTerminal.h>
class UOperatingSystemTerminal

Defined in OperatingSystemTerminal.h:22

Inherits: UOperatingSystemBaseProgram

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemTerminal["UOperatingSystemTerminal"]
  class UOperatingSystemBaseProgram["UOperatingSystemBaseProgram"]
  UOperatingSystemBaseProgram <|-- UOperatingSystemTerminal
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemTerminal["UOperatingSystemTerminal"]
  class UOperatingSystemBaseProgram["UOperatingSystemBaseProgram"]
  UOperatingSystemTerminal *-- UOperatingSystemBaseProgram
  class UOperatingSystemTerminalCommand["UOperatingSystemTerminalCommand"]
  UOperatingSystemTerminal *-- UOperatingSystemTerminalCommand
  class IOperatingSystemExplorerInterface["IOperatingSystemExplorerInterface"]
  UOperatingSystemTerminal *-- IOperatingSystemExplorerInterface
  class FOperatingSystemUser["FOperatingSystemUser"]
  UOperatingSystemTerminal *-- FOperatingSystemUser
  class UOperatingSystemCmdCollection["UOperatingSystemCmdCollection"]
  UOperatingSystemTerminal *-- UOperatingSystemCmdCollection
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemTerminal {
    +UOperatingSystemTerminal()
    +ProcessCommand(const FString &TestCommand, FGenericError & void()
    +ChangeCurrentPath(const FString &TargetPath) bool()
    +DestroyActiveCommand(const FGenericError &ErrorMessage) void()
    +ChangeCurrentUser(const FOperatingSystemUser &NewUser) void()
    +PromptRootPassword() void()
    +PromptUserContinue() void()
    +CheckRootPassword(const FText &TestPassword, const bool bCase bool()
    +MessageReceivedFromCommand(const FText &CmdMsg, const EOperatingSystem void()
    +VerifyUserPrompt(const bool bIsYes) const void()
    +ClearHistory() void()
    +HasRepository() const bool()
    +GetNextCommandFromHistory(FString &OutCommand) const bool()
    +GetPreviousCommandFromHistory(FString &OutCommand) const bool()
    +IsTerminalBusy() const bool()
    +ValidateFlags() const bool()
    +GetCommandFlagPrefixes() const const()TSet()< FName() > &
    +GetMultiCommandOperatorString() const FString()
    +CommandCollection : TSoftObjectPtr()< UOperatingSystemCmdCol
    +bSupportMultipleCommands : uint8()
    +MultiCommandOperator : FName()
    +CommandFlagPrefixes : TSet()< FName() >
    +bValidateFlags : bool()
    +OnValidate(FGenericError &OutError) const override void()
    +OnStart(FGenericError &OutError) override void()
    +GetCommand(const FString &TestCommand, FGenericError & UOperatingSystemTerminalCommand() *
    +GetCurrentDirectoryPath(FString &OutPath) const bool()
    +K2_CommandFinished(const FGenericError &ErrorMessage) void()
    +K2_UserChanged() void()
    +K2_PromptRootPassword() void()
    +K2_PromptUserContinue() void()
    +K2_MessageReceivedFromCommand(const FText &CmdMsg, const EOperatingSystem void()
    +CachedAdditionalCommands : TSet()< TSoftClassPtr()< UOperatingSyste
    +ActiveCommand : TObjectPtr()< UOperatingSystemTerminalCo
    +CurrentExplorerInterface : TScriptInterface()< IOperatingSystemExpl
    +QueuedCommands : TArray()< FString() >
    +CurrentUser : FOperatingSystemUser()
    +bIsRunningAsRoot : uint8()
    +Internal_FindAdditionalCommands(TSet< TSoftClassPtr< UOperatingSystemTermin void()
  }

The UOperatingSystemTerminal class is a subclass of UOperatingSystemBaseProgram and represents a terminal in the Operating System. It allows users to execute commands and interact with the operating system.

ReturnNameDescription
UOperatingSystemTerminal
voidProcessCommandProcess the given command in the Operating System terminal If the terminal is busy, it sets the output error indicating that the terminal is busy and cannot run new commands. If the command is empty, it destroys the active command and returns. If the command is not recognized, it sets the output error indicating that the command is not recognized. If the command supports multiple commands and contains a multi-command operator, it splits the command into multiple commands and processes them one by one.
boolChangeCurrentPathChanges the current path to the specified target path.
voidDestroyActiveCommandDestroys the active command and processes the next queued command (if any).
voidChangeCurrentUserChanges the current user of the Operating System terminal.
voidPromptRootPasswordPrompts the user for the root password.
voidPromptUserContinuePrompts the user to continue the execution in the operating system terminal.
boolCheckRootPassword constThis function checks if the provided password matches the password of the root user of the operating system. If the password matches, it will process the command as the root user.
voidMessageReceivedFromCommandFunction to handle received messages from the command. This function is called when a message is received from the command. It can be used to handle and process the message in the operating system terminal.
voidVerifyUserPrompt constVerifies the user prompt and takes the appropriate action. It checks if the user prompt is “Yes” or “No” and performs the necessary action based on the value of bIsYes parameter.
voidClearHistoryClears the history of the operating system terminal.
boolHasRepository constChecks if the operating system terminal has a repository.
boolGetNextCommandFromHistory constRetrieves the next command from the history of the operating system terminal.
boolGetPreviousCommandFromHistory constRetrieves the previous command from the command history.
boolIsTerminalBusy constChecks if the terminal is busy or not. A terminal is considered busy if there is an active command being executed.
boolValidateFlags const inlineGets the value of the bValidateFlags flag.
constTSet< FName > &GetCommandFlagPrefixes const inlineReturns the set of command flag prefixes.
FStringGetMultiCommandOperatorString const inlineReturns the multi-command operator string.

UOperatingSystemTerminal()
void ProcessCommand(constFString & TestCommand, FGenericError & OutError)

Defined in OperatingSystemTerminal.h:130 Process the given command in the Operating System terminal If the terminal is busy, it sets the output error indicating that the terminal is busy and cannot run new commands. If the command is empty, it destroys the active command and returns. If the command is not recognized, it sets the output error indicating that the command is not recognized. If the command supports multiple commands and contains a multi-command operator, it splits the command into multiple commands and processes them one by one.

  • TestCommand The command to be processed.

  • OutError The output error if any error occurs during the command processing


bool ChangeCurrentPath(constFString & TargetPath)

Defined in OperatingSystemTerminal.h:139 Changes the current path to the specified target path.

  • TargetPath The target path to change to.

True if the current path was successfully changed, false otherwise.


void DestroyActiveCommand(constFGenericError & ErrorMessage)

Defined in OperatingSystemTerminal.h:152 Destroys the active command and processes the next queued command (if any).

This function is called to destroy the active command and process the next command in the queue, if any. If the active command is a blueprint command, it calls the K2_CommandFinished function to notify the blueprint. Then, it marks the active command as garbage and sets it to nullptr. If there is no error message and there is a next command in the queue, it removes the next command from the queue and calls the ProcessCommand function to process it.

  • ErrorMessage The error message to pass to the K2_CommandFinished function, if applicable

void ChangeCurrentUser(constFOperatingSystemUser & NewUser)

Defined in OperatingSystemTerminal.h:162 Changes the current user of the Operating System terminal.

This function changes the current user of the operating system terminal to the given user. If the given user is already the current user, the function returns without making any changes.

  • NewUser The new user to set as the current user.

void PromptRootPassword()

Defined in OperatingSystemTerminal.h:170 Prompts the user for the root password.


void PromptUserContinue()

Defined in OperatingSystemTerminal.h:177 Prompts the user to continue the execution in the operating system terminal.


const

bool CheckRootPassword(constFText & TestPassword, constbool bCaseSensitive = true) const

Defined in OperatingSystemTerminal.h:194 This function checks if the provided password matches the password of the root user of the operating system. If the password matches, it will process the command as the root user.

  • TestPassword The password to test against the root user’s password.

  • bCaseSensitive Whether the password comparison should be case-sensitive.

True if the provided password matches the root user’s password and the command was processed as the root user, false otherwise.

See also: UOperatingSystemTerminal::GetOperatingSystem()

See also: FOperatingSystem::GetRootUser()

See also: UOperatingSystemTerminal::ActiveCommand

See also: FTerminalCommand::ProcessCommandAsRoot()


void MessageReceivedFromCommand(constFText & CmdMsg, constEOperatingSystemTerminalMessageType & CmdMsgType)

Defined in OperatingSystemTerminal.h:203 Function to handle received messages from the command. This function is called when a message is received from the command. It can be used to handle and process the message in the operating system terminal.

  • CmdMsg The message received from the command.

  • CmdMsgType The type of the message received.


const

void VerifyUserPrompt(constbool bIsYes) const

Defined in OperatingSystemTerminal.h:212 Verifies the user prompt and takes the appropriate action. It checks if the user prompt is “Yes” or “No” and performs the necessary action based on the value of bIsYes parameter.

  • bIsYes A boolean indicating if the user prompt is “Yes” or “No”.

void ClearHistory()

Defined in OperatingSystemTerminal.h:218 Clears the history of the operating system terminal.


const

bool HasRepository() const

Defined in OperatingSystemTerminal.h:235 Checks if the operating system terminal has a repository.

It will return true if there is at least one valid repository class, otherwise it will return false.

It first checks if the operating system is Unix. If it is, it retrieves the repository classes from the Unix operating system object. It then iterates through each repository class and checks if it is null. If at least one repository class is not null, the function returns true. If all repository classes are null or the operating system is not Unix, the function returns false.

True if the operating system terminal has at least one valid repository class, false otherwise.


const

bool GetNextCommandFromHistory(FString & OutCommand) const

Defined in OperatingSystemTerminal.h:246 Retrieves the next command from the history of the operating system terminal.

  • OutCommand [out] - The next command retrieved from the terminal history.

True if the retrieval is successful, false otherwise.

See also: GetPreviousCommandFromHistory


const

bool GetPreviousCommandFromHistory(FString & OutCommand) const

Defined in OperatingSystemTerminal.h:258 Retrieves the previous command from the command history.

  • OutCommand [out] - The output parameter that will contain the previous command if it exists

True if the previous command was successfully retrieved from the history, false otherwise.

See also: GetNextCommandFromHistory


const

bool IsTerminalBusy() const

Defined in OperatingSystemTerminal.h:344 Checks if the terminal is busy or not. A terminal is considered busy if there is an active command being executed.

true if the terminal is busy (there is an active command), false otherwise.


const inline

inline bool ValidateFlags() const

Defined in OperatingSystemTerminal.h:354 Gets the value of the bValidateFlags flag.

This method returns the value of the bValidateFlags flag. The bValidateFlags flag is used to determine whether the flags are being validated or not.

True if the flags are being validated, false otherwise.


const inline

inline constTSet< FName > & GetCommandFlagPrefixes() const

Defined in OperatingSystemTerminal.h:364 Returns the set of command flag prefixes.

This method returns a reference to the set of command flag prefixes used in the operating system terminal. A command flag prefix is a character or string that is placed before a command parameter to indicate that it is a flag.

A reference to the set of command flag prefixes.


const inline

inline FString GetMultiCommandOperatorString() const

Defined in OperatingSystemTerminal.h:377 Returns the multi-command operator string.

The GetMultiCommandOperatorString method returns the string representation of the multi-command operator. If the multi-command operator is set to None, the method returns the string ” && ”. Otherwise, it retrieves the string representation of the multi-command operator, removes any spaces, and formats it using the FString::Printf function with the format specifier “%s”. The formatted string is then returned.

The multi-command operator string.

ReturnNameDescription
TSoftObjectPtr< UOperatingSystemCmdCollection >CommandCollectionSoft Object Pointer representing the UOperatingSystemCmdCollection for the operating system terminal.
uint8bSupportMultipleCommandsDetermines if the OperatingSystemTerminal supports multiple commands.
FNameMultiCommandOperatorString to use for separating multiple commands. E.g: pwd && ls. NOTE: Does not support space so if you have space, it is automatically removed.
TSet< FName >CommandFlagPrefixesList of prefixes that must be included when adding flags.
boolbValidateFlagsThe flag to indicate whether to validate the operating system terminal.

TSoftObjectPtr< UOperatingSystemCmdCollection > CommandCollection

Defined in OperatingSystemTerminal.h:39 Soft Object Pointer representing the UOperatingSystemCmdCollection for the operating system terminal.


uint8 bSupportMultipleCommands

Defined in OperatingSystemTerminal.h:48 Determines if the OperatingSystemTerminal supports multiple commands.

If set to true, the OperatingSystemTerminal supports executing multiple commands at once. If set to false, the OperatingSystemTerminal only supports executing one command at a time.


FName MultiCommandOperator

Defined in OperatingSystemTerminal.h:54 String to use for separating multiple commands. E.g: pwd && ls. NOTE: Does not support space so if you have space, it is automatically removed.


TSet< FName > CommandFlagPrefixes

Defined in OperatingSystemTerminal.h:58 List of prefixes that must be included when adding flags.


bool bValidateFlags

Defined in OperatingSystemTerminal.h:64 The flag to indicate whether to validate the operating system terminal.

ReturnNameDescription
voidOnValidate virtual const overrideOnValidate method for validating program-specific logic.
voidOnStart virtual overrideCalled when the program starts. It should be overridden in derived classes to provide the necessary functionality for the specific program.
UOperatingSystemTerminalCommand *GetCommand constRetrieves the command associated with the given test command string.
boolGetCurrentDirectoryPath constRetrieves the current directory path and stores it in the provided output parameter.
voidK2_CommandFinishedA function that is called when a command finishes execution.
voidK2_UserChangedThis function is called when the user is changed. It can be implemented in blueprints to handle the event of user change in the operating system terminal.
voidK2_PromptRootPasswordEvent triggered when the root password is prompted.
voidK2_PromptUserContinueEvent triggered when user wants to continue.
voidK2_MessageReceivedFromCommandBlueprintImplementableEvent function for receiving messages from the operating system terminal. This function is tied to a blueprint and is called when a message is received from the operating system terminal.

virtual const override

virtual void OnValidate(FGenericError & OutError) const override

Defined in OperatingSystemTerminal.h:262 OnValidate method for validating program-specific logic.

This method is a virtual function that can be overridden by derived classes to perform additional validation specific to the program’s requirements. The method takes an FGenericError& parameter, which can be used to report any validation errors encountered during the validation process.

  • OutError The error object used to report any validation errors.

See also: FGenericError


virtual override

virtual void OnStart(FGenericError & OutError) override

Defined in OperatingSystemTerminal.h:263 Called when the program starts. It should be overridden in derived classes to provide the necessary functionality for the specific program.

  • OutError A reference to the FGenericError object, used to report any errors that occur during startup.

See also: FGenericError


const

UOperatingSystemTerminalCommand * GetCommand(constFString & TestCommand, FGenericError & OutError) const

Defined in OperatingSystemTerminal.h:273 Retrieves the command associated with the given test command string.

  • TestCommand The test command string to match with a command.

  • OutError [out] The error message if an error occurs.

The command associated with the test command string, or nullptr if no command is found.


const

bool GetCurrentDirectoryPath(FString & OutPath) const

Defined in OperatingSystemTerminal.h:282 Retrieves the current directory path and stores it in the provided output parameter.

  • OutPath [out] The output parameter to store the current directory path.

True if the current directory path was successfully retrieved, false otherwise.


void K2_CommandFinished(constFGenericError & ErrorMessage)

Defined in OperatingSystemTerminal.h:290 A function that is called when a command finishes execution.

  • ErrorMessage The error message generated during the command execution.

void K2_UserChanged()

Defined in OperatingSystemTerminal.h:297 This function is called when the user is changed. It can be implemented in blueprints to handle the event of user change in the operating system terminal.


void K2_PromptRootPassword()

Defined in OperatingSystemTerminal.h:303 Event triggered when the root password is prompted.


void K2_PromptUserContinue()

Defined in OperatingSystemTerminal.h:309 Event triggered when user wants to continue.


void K2_MessageReceivedFromCommand(constFText & CmdMsg, constEOperatingSystemTerminalMessageType & CmdMsgType)

Defined in OperatingSystemTerminal.h:320 BlueprintImplementableEvent function for receiving messages from the operating system terminal. This function is tied to a blueprint and is called when a message is received from the operating system terminal.

  • CmdMsg The received message from the operating system terminal as a FText object

  • CmdMsgType The type of the received message as an EOperatingSystemTerminalMessageType enumeration value

ReturnNameDescription
TSet< TSoftClassPtr< UOperatingSystemTerminalCommand > >CachedAdditionalCommandsRepresents a set of soft class pointers to additional operating system terminal commands. The property is marked as Transient, meaning it is not saved when the object is serialized.
TObjectPtr< UOperatingSystemTerminalCommand >ActiveCommandProperty for the active command in the Operating System terminal.
TScriptInterface< IOperatingSystemExplorerInterface >CurrentExplorerInterfaceProperty for the current operating system explorer interface.
TArray< FString >QueuedCommandsQueuedCommands property is a TArray of FString objects, used to store a queue of commands. Transient specifier indicates that the value of this property will not be serialized and saved in-between play sessions.
FOperatingSystemUserCurrentUserRepresents the current user of this terminal. It is marked as transient meaning it will not be saved when serializing the object.
uint8bIsRunningAsRootFlag indicating whether the application is running as root.

TSet< TSoftClassPtr< UOperatingSystemTerminalCommand > > CachedAdditionalCommands

Defined in OperatingSystemTerminal.h:31 Represents a set of soft class pointers to additional operating system terminal commands. The property is marked as Transient, meaning it is not saved when the object is serialized.


TObjectPtr< UOperatingSystemTerminalCommand > ActiveCommand

Defined in OperatingSystemTerminal.h:74 Property for the active command in the Operating System terminal.

This property is transient, meaning it will not be saved or loaded when the object is serialized.


TScriptInterface< IOperatingSystemExplorerInterface > CurrentExplorerInterface

Defined in OperatingSystemTerminal.h:80 Property for the current operating system explorer interface.


TArray< FString > QueuedCommands

Defined in OperatingSystemTerminal.h:87 QueuedCommands property is a TArray of FString objects, used to store a queue of commands. Transient specifier indicates that the value of this property will not be serialized and saved in-between play sessions.


FOperatingSystemUser CurrentUser

Defined in OperatingSystemTerminal.h:94 Represents the current user of this terminal. It is marked as transient meaning it will not be saved when serializing the object.


uint8 bIsRunningAsRoot

Defined in OperatingSystemTerminal.h:103 Flag indicating whether the application is running as root.

This flag represents whether the application is currently running with root (superuser) privileges or not. It is used to determine if certain privileged operations can be performed by the application.

ReturnNameDescription
voidInternal_FindAdditionalCommands staticFinds additional commands for the terminal.

static

static void Internal_FindAdditionalCommands(TSet< TSoftClassPtr< UOperatingSystemTerminalCommand > > & OutCommands)

Defined in OperatingSystemTerminal.h:334 Finds additional commands for the terminal.

This method scans the specified asset paths for primary assets of type UOperatingSystemTerminalCommand. It populates the given OutCommands set with the found classes.

  • OutCommands The set to populate with the found classes.

See also: UOperatingSystemTerminalCommand

See also: UOperatingSystemPluginSettings::GetAdditionalTerminalCommandsPath