Operating System Simulator Plugin
3.5.1
Unreal Engine plugin that simulates an Operating System Environment
|
The UOperatingSystemPartition class represents an operating system partition. It inherits from UObject and implements the IOperatingSystemExplorerInterface. This class provides functionality to manage directories, disk information, and file operations. More...
#include "OperatingSystemPartition.h"
Public Member Functions | |
void | SetDiskName (const FString &NewDiskName) |
Sets the display name of the disk. | |
void | SetSystemPartition (const bool bNewSystemPartition) |
Sets the system partition flag for the operating system partition. | |
void | SetOwningOperatingSystem (UOperatingSystem *OwningOS) |
Sets the owning operating system of the UOperatingSystemPartition. | |
void | AddDirectories (const TArray< UOperatingSystemDirectory * > &NewDirectories, const bool bAppend=false) |
Adds directories to the operating system partition. | |
void | AddDirectory (UOperatingSystemDirectory *NewDirectory) |
Adds a directory to the operating system partition. | |
void | ConsumeSpace (const double &SizeInBytes, FGenericError &OutError) |
Consume space in the operating system partition. | |
void | FreeupSpace (const double &SizeInBytes) |
The FreeupSpace method allows you to free up space in the operating system partition. This method updates the FreeSpaceInBytes variable by adding the specified size in bytes. If the updated value of FreeSpaceInBytes exceeds the TotalSizeInBytes, it is set to TotalSizeInBytes to ensure the partition does not have more free space than the total size. | |
FText | GetSizeAsText (const EOperatingSystemSizeMethod &SizeMethod) const |
Converts the partition size to a human-readable text format. | |
virtual TArray< UOperatingSystemDirectory * > | GetChildDirectories () const override final |
Retrieves the child directories of this operating system partition. | |
virtual void | GetParentExplorerInterface (TScriptInterface< IOperatingSystemExplorerInterface > &OutInterface) const override final |
This method retrieves the parent explorer interface associated with the operating system partition. | |
virtual bool | IsPartition () const override final |
Check if the object is an operating system partition. | |
virtual FText | GetInterfaceDisplayName () const override final |
Get the display name of the interface. This method returns the display name of the interface. | |
virtual bool | FindDirectoryByTag (const FGameplayTag DirectoryTag, const bool bRecursive, UOperatingSystemDirectory *&OutDirectory) const override final |
Searches for a directory by tag in the operating system partition. | |
virtual TScriptInterface< IOperatingSystemExplorerInterface > | GetChildDirectory (const FString &TargetChildDirectoryName, const bool bRecursive=true) const override final |
Returns a child directory with the specified name. | |
virtual TArray< UOperatingSystemFile * > | GetAllFiles (const FString &WithExtension="*") const override final |
Retrieves an array of all files in the partition with the specified extension. | |
virtual bool | CanCreateNewFile () const override final |
Checks if a new file can be created in the operating system partition. | |
virtual bool | HasEnoughSpace (const FOperatingSystemSizeInMB &TestSpace) const override final |
Checks if the operating system partition has enough space. | |
virtual UOperatingSystem * | GetOperatingSystem () const override final |
Get the operating system of the partition. | |
virtual TOptional< FString > | GetFullPath () const override final |
Returns the full path of the operating system partition. | |
virtual TScriptInterface< IOperatingSystemExplorerInterface > | GetInterfaceFromPath (const FString &NewPath) const override final |
Get the interface from a given path. | |
void | SetDiskLetter (const FName &NewDiskLetter) |
FString | GetPartitionPath () const |
Returns the partition path. | |
FORCEINLINE bool | IsValidPartition () const |
FORCEINLINE bool | HasEnoughSpace (const double &TestSpaceInBytes) const |
FORCEINLINE float | GetStoragePercentage () const |
FORCEINLINE double | GetTotalSizeBytes () const |
FORCEINLINE double | GetFreeSizeBytes () const |
FORCEINLINE bool | IsSystemPartition () const |
FORCEINLINE FOperatingSystemUniqueId | GetPartitionID () const |
FORCEINLINE FName | GetDiskLetter () const |
FORCEINLINE FOperatingSystemPartitionSaveLoad | GetNewPartitionSaveLoad () const |
template<class T > | |
T * | GetChildDirectory (const FString &TargetChildDirectoryName, const bool bRecursive=true) const |
Gets a child directory with the given name. | |
Static Public Member Functions | |
static UOperatingSystemPartition * | CreateNewPartition (UOperatingSystemHDD *OwningHDD, const double &SizeInBytes, FGenericError &OutError) |
Creates a new operating system partition. | |
static UOperatingSystemPartition * | LoadNewPartition (UOperatingSystemHDD *OwningHDD, const FOperatingSystemPartitionSaveLoad &PartitionSaveLoad) |
Loads a new operating system partition. | |
Protected Member Functions | |
void | SetDiskDisplayName (const FText &NewName) |
Protected Attributes | |
FText | DiskName |
FText | DiskDisplayName |
double | TotalSizeInBytes |
double | FreeSpaceInBytes |
bool | bIsSystemPartition |
FOperatingSystemUniqueId | PartitionID |
FName | DiskLetter |
TArray< TObjectPtr< UOperatingSystemFile > > | Files |
TWeakObjectPtr< UOperatingSystemHDD > | ParentHDD |
The ParentHDD variable represents a weak reference to the parent UOperatingSystemHDD object that this UOperatingSystemPartition object belongs to. | |
TWeakObjectPtr< UOperatingSystem > | ParentOS |
Weak reference to the parent UOperatingSystem object that this UOperatingSystemPartition object belongs to. | |
The UOperatingSystemPartition class represents an operating system partition. It inherits from UObject and implements the IOperatingSystemExplorerInterface. This class provides functionality to manage directories, disk information, and file operations.
Key Features:
void UOperatingSystemPartition::AddDirectories | ( | const TArray< UOperatingSystemDirectory * > & | NewDirectories, |
const bool | bAppend = false ) |
Adds directories to the operating system partition.
This method is used to add directories to the operating system partition. It takes an array of UOperatingSystemDirectory objects as input. By default, the added directories will replace the existing directories in the partition. However, if the 'bAppend' parameter is set to true, the new directories will be appended to the existing directories in the partition.
NewDirectories | An array of UOperatingSystemDirectory objects representing the directories to be added to the partition. |
bAppend | A flag indicating whether to replace the existing directories with the new directories or append them. Default value is false. |
void UOperatingSystemPartition::AddDirectory | ( | UOperatingSystemDirectory * | NewDirectory | ) |
Adds a directory to the operating system partition.
This method adds a new directory to the operating system partition.
NewDirectory | A pointer to the UOperatingSystemDirectory object representing the new directory to be added. |
|
inlinefinaloverridevirtual |
Checks if a new file can be created in the operating system partition.
This method determines whether it is possible to create a new file in the current operating system partition. It returns true if a new file can be created and false otherwise.
Implements IOperatingSystemExplorerInterface.
void UOperatingSystemPartition::ConsumeSpace | ( | const double & | SizeInBytes, |
FGenericError & | OutError ) |
Consume space in the operating system partition.
This method is used to consume a specified amount of space in the operating system partition.
SizeInBytes | The size of space to consume in bytes. |
OutError | (output) A reference to a FGenericError object to store any error occurred during the operation. If there is not enough space, the error message will be set to "Not enough space." |
|
static |
Creates a new operating system partition.
This method creates a new operating system partition with the specified size.
OwningHDD | The UOperatingSystemHDD that will own the new partition. |
SizeInBytes | The size of the new partition in bytes. |
OutError | The reference to a FGenericError object which will hold any potential error messages if the creation fails. |
|
finaloverridevirtual |
Searches for a directory by tag in the operating system partition.
This function is used to search for a directory with a specific tag in the given operating system partition. If the directory with the tag is found, the function sets the OutDirectory parameter to the found directory.
DirectoryTag | The tag of the directory to search for. |
bRecursive | Specifies whether the search should be recursive or not. If set to true, the function will also search in the child directories. |
OutDirectory | A pointer to the found directory. Set to nullptr if the directory is not found. |
Implements IOperatingSystemExplorerInterface.
void UOperatingSystemPartition::FreeupSpace | ( | const double & | SizeInBytes | ) |
The FreeupSpace method allows you to free up space in the operating system partition. This method updates the FreeSpaceInBytes variable by adding the specified size in bytes. If the updated value of FreeSpaceInBytes exceeds the TotalSizeInBytes, it is set to TotalSizeInBytes to ensure the partition does not have more free space than the total size.
SizeInBytes | The size in bytes to be freed up in the operating system partition. |
|
finaloverridevirtual |
Retrieves an array of all files in the partition with the specified extension.
WithExtension | The extension of the files to retrieve. Default value is "*", which retrieves all files. |
Implements IOperatingSystemExplorerInterface.
|
inlinefinaloverridevirtual |
Retrieves the child directories of this operating system partition.
This method returns an array of UOperatingSystemDirectory pointers, representing the child directories of this operating system partition. The returned array contains all the child directories, including subdirectories, that exist within this partition.
Implements IOperatingSystemExplorerInterface.
|
inlinevirtual |
Gets a child directory with the given name.
This method searches for a child directory with the specified name within the current directory. The search can be recursive, meaning it will also search within subdirectories.
TargetChildDirectoryName | The name of the child directory to search for. |
bRecursive | (optional) Whether to perform a recursive search. Defaults to true, meaning it will search within subdirectories. |
Implements IOperatingSystemExplorerInterface.
|
finaloverridevirtual |
Returns a child directory with the specified name.
This method searches for a child directory with the given name in the current partition. If the recursive flag is set to true, it also searches for the directory in the child directories of the child directories (grandchild directories) of the current partition.
TargetChildDirectoryName | The name of the child directory to search for. |
bRecursive | (optional) If set to true, the method searches for the directory recursively in the child directories. Default is true. |
Implements IOperatingSystemExplorerInterface.
|
inline |
|
inline |
|
inlinefinaloverridevirtual |
Returns the full path of the operating system partition.
This method returns the full path of the operating system partition.
Implements IOperatingSystemExplorerInterface.
|
inlinefinaloverridevirtual |
Get the display name of the interface. This method returns the display name of the interface.
Implements IOperatingSystemExplorerInterface.
|
finaloverridevirtual |
Get the interface from a given path.
This method searches for the interface corresponding to the provided path.
If the provided path matches the partition path of the current object, this method returns a writable interface of this object. If the provided path is "..", this method returns nullptr. If the provided path starts with a disk letter followed by a delimiter, this method searches for the corresponding partition and continues the search for the remaining path. If the provided path does not start with a disk letter, the search starts from the current object and continues for each directory specified in the path. If, at any stage, a directory in the path is not found, this method returns nullptr.
NewPath | The path for which the interface is requested. |
Implements IOperatingSystemExplorerInterface.
|
inline |
|
finaloverridevirtual |
Get the operating system of the partition.
This method returns the operating system object associated with the partition. The returned operating system object represents the operating system installed on the partition.
Implements IOperatingSystemExplorerInterface.
|
inlinefinaloverridevirtual |
This method retrieves the parent explorer interface associated with the operating system partition.
This method sets the OutInterface parameter to nullptr, indicating that there is no parent explorer interface associated with the operating system partition.
OutInterface | [out] A reference to a TScriptInterface<IOperatingSystemExplorerInterface> object that will receive the parent explorer interface. |
Implements IOperatingSystemExplorerInterface.
|
inline |
FString UOperatingSystemPartition::GetPartitionPath | ( | ) | const |
Returns the partition path.
This method returns a formatted string that includes the disk letter and the path delimiter.
FText UOperatingSystemPartition::GetSizeAsText | ( | const EOperatingSystemSizeMethod & | SizeMethod | ) | const |
Converts the partition size to a human-readable text format.
SizeMethod | The size method used to calculate the partition size. Valid values are EOperatingSystemSizeMethod::MB and EOperatingSystemSizeMethod::GB. |
|
inline |
|
inline |
|
inline |
|
finaloverridevirtual |
Checks if the operating system partition has enough space.
TestSpace | The size in megabytes of the space to test. |
Implements IOperatingSystemExplorerInterface.
|
inlinefinaloverridevirtual |
Check if the object is an operating system partition.
Implements IOperatingSystemExplorerInterface.
|
inline |
|
inline |
|
static |
Loads a new operating system partition.
This method is used to load a new operating system partition from a save/load data structure. If a partition with the same ID already exists, it updates the existing partition instead of creating a new one, and updates its properties based on the given save/load data.
OwningHDD | The UOperatingSystemHDD object that owns the partition. |
PartitionSaveLoad | The save/load data structure that contains the partition information. |
|
protected |
Sets the display name of the disk.
This method allows you to set the display name of the disk.
NewName | The new display name to set. |
void UOperatingSystemPartition::SetDiskLetter | ( | const FName & | NewDiskLetter | ) |
Sets the disk letter like C, D, E etc. Mostly used in Non-Unix Operating System
void UOperatingSystemPartition::SetDiskName | ( | const FString & | NewDiskName | ) |
Sets the display name of the disk.
This method sets the display name of the disk to the provided string. The disk name is used to identify and label the disk in the operating system.
NewDiskName | The new display name of the disk. |
void UOperatingSystemPartition::SetOwningOperatingSystem | ( | UOperatingSystem * | OwningOS | ) |
Sets the owning operating system of the UOperatingSystemPartition.
This method is used to set the owning operating system of the UOperatingSystemPartition. The owning operating system is responsible for managing the partition and its associated operations.
OwningOS | The owning operating system to set. |
void UOperatingSystemPartition::SetSystemPartition | ( | const bool | bNewSystemPartition | ) |
Sets the system partition flag for the operating system partition.
bNewSystemPartition | The new value to set for the system partition flag.
|
|
protected |
Determines if this is a system partition.
|
protected |
Represents the display name of the disk. The display name is a user-friendly string that can be shown to the user. It is typically used to identify the disk in UI elements such as dropdown menus or dialogs.
|
protected |
Represents the disk letter of a storage device. The disk letter is used to identify a specific storage device, typically a drive on the operating system.
|
protected |
Specifies the name of the disk associated with an operating system partition.
|
protected |
Array of files created under this partition.
|
protected |
Free space in this partition
|
protected |
The ParentHDD variable represents a weak reference to the parent UOperatingSystemHDD object that this UOperatingSystemPartition object belongs to.
Usage:
|
protected |
Weak reference to the parent UOperatingSystem object that this UOperatingSystemPartition object belongs to.
The ParentOS variable is a weak reference to the parent UOperatingSystem object that this UOperatingSystemPartition object belongs to. It represents the parent-child relationship between UOperatingSystemPartition and UOperatingSystem objects. It allows UOperatingSystemPartition to access properties and methods of its parent UOperatingSystem object. Weak references are used here to avoid creating strong references that could lead to memory leaks or circular dependencies.
|
protected |
Unique ID of this partition.
|
protected |
Total size of this partition