Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
UOperatingSystemPartition Class Reference

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"

Inheritance diagram for UOperatingSystemPartition:
[legend]
Collaboration diagram for UOperatingSystemPartition:
[legend]

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< IOperatingSystemExplorerInterfaceGetChildDirectory (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 UOperatingSystemGetOperatingSystem () 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< IOperatingSystemExplorerInterfaceGetInterfaceFromPath (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 UOperatingSystemPartitionCreateNewPartition (UOperatingSystemHDD *OwningHDD, const double &SizeInBytes, FGenericError &OutError)
 Creates a new operating system partition.
 
static UOperatingSystemPartitionLoadNewPartition (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< UOperatingSystemHDDParentHDD
 The ParentHDD variable represents a weak reference to the parent UOperatingSystemHDD object that this UOperatingSystemPartition object belongs to.
 
TWeakObjectPtr< UOperatingSystemParentOS
 Weak reference to the parent UOperatingSystem object that this UOperatingSystemPartition object belongs to.
 

Detailed Description

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:

  • Create and load new partitions
  • Set disk name and system partition flag
  • Add directories to the partition
  • Consume and free up space in the partition
  • Get information about partition size and disk letter
  • Retrieve child directories and files
  • Check if a partition is valid and has enough space
  • Get the storage percentage of the partition
  • Get the partition ID and disk letter
  • Set the disk display name
  • Get the partition path and new partition save/load data
  • Get a child directory of a specific type

Member Function Documentation

◆ AddDirectories()

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.

Parameters
NewDirectoriesAn array of UOperatingSystemDirectory objects representing the directories to be added to the partition.
bAppendA flag indicating whether to replace the existing directories with the new directories or append them. Default value is false.
Note
If bAppend is set to false, the method will first mark the existing directories as garbage, freeing up their memory. Then it will replace the existing directories with the new directories. If bAppend is set to true, the new directories will be directly appended to the existing directories in the partition.
See also
UOperatingSystemDirectory
Here is the caller graph for this function:

◆ AddDirectory()

void UOperatingSystemPartition::AddDirectory ( UOperatingSystemDirectory * NewDirectory)

Adds a directory to the operating system partition.

This method adds a new directory to the operating system partition.

Parameters
NewDirectoryA pointer to the UOperatingSystemDirectory object representing the new directory to be added.
See also
UOperatingSystemDirectory
AddDirectories()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanCreateNewFile()

virtual bool UOperatingSystemPartition::CanCreateNewFile ( ) const
inlinefinaloverridevirtual

Checks if a new file can be created in the operating system partition.

Note
This function belongs to IOperatingSystemExplorerInterface.

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.

Returns
True if a new file can be created, false otherwise.

Implements IOperatingSystemExplorerInterface.

◆ ConsumeSpace()

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.

Parameters
SizeInBytesThe 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."
Note
This method checks if there is enough space in the partition before consuming the space. If there is not enough space, the error message will be set and no space will be consumed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateNewPartition()

UOperatingSystemPartition * UOperatingSystemPartition::CreateNewPartition ( UOperatingSystemHDD * OwningHDD,
const double & SizeInBytes,
FGenericError & OutError )
static

Creates a new operating system partition.

This method creates a new operating system partition with the specified size.

Parameters
OwningHDDThe UOperatingSystemHDD that will own the new partition.
SizeInBytesThe size of the new partition in bytes.
OutErrorThe reference to a FGenericError object which will hold any potential error messages if the creation fails.
Returns
A pointer to the created UOperatingSystemPartition object, or nullptr if the creation fails.
See also
UOperatingSystemHDD
FGenericError
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindDirectoryByTag()

bool UOperatingSystemPartition::FindDirectoryByTag ( const FGameplayTag DirectoryTag,
const bool bRecursive,
UOperatingSystemDirectory *& OutDirectory ) const
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.

Note
This function belongs to IOperatingSystemExplorerInterface.
Parameters
DirectoryTagThe tag of the directory to search for.
bRecursiveSpecifies whether the search should be recursive or not. If set to true, the function will also search in the child directories.
OutDirectoryA pointer to the found directory. Set to nullptr if the directory is not found.
Returns
True if the directory with the tag is found, false otherwise.

Implements IOperatingSystemExplorerInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeupSpace()

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.

Parameters
SizeInBytesThe size in bytes to be freed up in the operating system partition.
Note
This method modifies the FreeSpaceInBytes variable.

◆ GetAllFiles()

TArray< UOperatingSystemFile * > UOperatingSystemPartition::GetAllFiles ( const FString & WithExtension = "*") const
finaloverridevirtual

Retrieves an array of all files in the partition with the specified extension.

Parameters
WithExtensionThe extension of the files to retrieve. Default value is "*", which retrieves all files.
Note
This function belongs to IOperatingSystemExplorerInterface.
Returns
An array of UOperatingSystemFile pointers that represents the files in the partition with the specified extension. If the specified extension is "*", or an empty or invalid extension, it returns all files in the partition. If no files match the specified extension, an empty array is returned.

Implements IOperatingSystemExplorerInterface.

◆ GetChildDirectories()

virtual TArray< UOperatingSystemDirectory * > UOperatingSystemPartition::GetChildDirectories ( ) const
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.

Note
The returned array may be empty if there are no child directories in this partition.
This function belongs to IOperatingSystemExplorerInterface.
Returns
An array of UOperatingSystemDirectory pointers representing the child directories of this partition. If there are no child directories, an empty array is returned.
See also
UOperatingSystemDirectory

Implements IOperatingSystemExplorerInterface.

◆ GetChildDirectory() [1/2]

template<class T >
T * UOperatingSystemPartition::GetChildDirectory ( const FString & TargetChildDirectoryName,
const bool bRecursive = true ) const
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.

Parameters
TargetChildDirectoryNameThe 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.
Returns
A pointer to the child directory if it is found, nullptr otherwise.
Note
The returned pointer is of type T, which is expected to be a subclass of UOperatingSystemDirectory. If the child directory is found and it is of type T, a valid pointer to the child directory will be returned. Otherwise, nullptr will be returned.
See also
UOperatingSystemDirectory

Implements IOperatingSystemExplorerInterface.

◆ GetChildDirectory() [2/2]

TScriptInterface< IOperatingSystemExplorerInterface > UOperatingSystemPartition::GetChildDirectory ( const FString & TargetChildDirectoryName,
const bool bRecursive = true ) const
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.

Parameters
TargetChildDirectoryNameThe 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.
Returns
A pointer to the child directory if found, or nullptr if not found.
Note
This method returns the first child directory with the specified name that it finds. If there are multiple directories with the same name, only the first one will be returned.
This function belongs to IOperatingSystemExplorerInterface.
See also
UOperatingSystemPartition, UOperatingSystemPartition::GetChildDirectories

Implements IOperatingSystemExplorerInterface.

Here is the caller graph for this function:

◆ GetDiskLetter()

FORCEINLINE FName UOperatingSystemPartition::GetDiskLetter ( ) const
inline

◆ GetFreeSizeBytes()

FORCEINLINE double UOperatingSystemPartition::GetFreeSizeBytes ( ) const
inline

◆ GetFullPath()

virtual TOptional< FString > UOperatingSystemPartition::GetFullPath ( ) const
inlinefinaloverridevirtual

Returns the full path of the operating system partition.

This method returns the full path of the operating system partition.

Note
This function belongs to IOperatingSystemExplorerInterface.
Returns
An optional string representing the full path of the partition. If the partition path is not available, the optional value will be empty.

Implements IOperatingSystemExplorerInterface.

◆ GetInterfaceDisplayName()

virtual FText UOperatingSystemPartition::GetInterfaceDisplayName ( ) const
inlinefinaloverridevirtual

Get the display name of the interface. This method returns the display name of the interface.

Note
This function belongs to IOperatingSystemExplorerInterface.
Returns
The display name of the interface as a FText object.

Implements IOperatingSystemExplorerInterface.

◆ GetInterfaceFromPath()

TScriptInterface< IOperatingSystemExplorerInterface > UOperatingSystemPartition::GetInterfaceFromPath ( const FString & NewPath) const
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.

Parameters
NewPathThe path for which the interface is requested.
Returns
The interface corresponding to the provided path, or nullptr if not found.
Note
This function belongs to IOperatingSystemExplorerInterface.

Implements IOperatingSystemExplorerInterface.

Here is the call graph for this function:

◆ GetNewPartitionSaveLoad()

FORCEINLINE FOperatingSystemPartitionSaveLoad UOperatingSystemPartition::GetNewPartitionSaveLoad ( ) const
inline

◆ GetOperatingSystem()

UOperatingSystem * UOperatingSystemPartition::GetOperatingSystem ( ) const
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.

Note
This function belongs to IOperatingSystemExplorerInterface.
Returns
A pointer to the operating system object.

Implements IOperatingSystemExplorerInterface.

◆ GetParentExplorerInterface()

virtual void UOperatingSystemPartition::GetParentExplorerInterface ( TScriptInterface< IOperatingSystemExplorerInterface > & OutInterface) const
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.

Parameters
OutInterface[out] A reference to a TScriptInterface<IOperatingSystemExplorerInterface> object that will receive the parent explorer interface.
Note
This function belongs to IOperatingSystemExplorerInterface.

Implements IOperatingSystemExplorerInterface.

◆ GetPartitionID()

FORCEINLINE FOperatingSystemUniqueId UOperatingSystemPartition::GetPartitionID ( ) const
inline
Here is the caller graph for this function:

◆ GetPartitionPath()

FString UOperatingSystemPartition::GetPartitionPath ( ) const

Returns the partition path.

This method returns a formatted string that includes the disk letter and the path delimiter.

Returns
A formatted string representing the partition path in the format "{disk letter}:{path delimiter}".
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSizeAsText()

FText UOperatingSystemPartition::GetSizeAsText ( const EOperatingSystemSizeMethod & SizeMethod) const

Converts the partition size to a human-readable text format.

Parameters
SizeMethodThe size method used to calculate the partition size. Valid values are EOperatingSystemSizeMethod::MB and EOperatingSystemSizeMethod::GB.
Returns
A text representation of the partition size in the specified size method. The size is returned as a formatted string in the form "{Size} {SizeString}", where {Size} is the partition size and {SizeString} is the unit of measurement (e.g., "MB" or "GB").
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStoragePercentage()

FORCEINLINE float UOperatingSystemPartition::GetStoragePercentage ( ) const
inline
Here is the caller graph for this function:

◆ GetTotalSizeBytes()

FORCEINLINE double UOperatingSystemPartition::GetTotalSizeBytes ( ) const
inline
Here is the caller graph for this function:

◆ HasEnoughSpace() [1/2]

FORCEINLINE bool UOperatingSystemPartition::HasEnoughSpace ( const double & TestSpaceInBytes) const
inline

◆ HasEnoughSpace() [2/2]

bool UOperatingSystemPartition::HasEnoughSpace ( const FOperatingSystemSizeInMB & TestSpace) const
finaloverridevirtual

Checks if the operating system partition has enough space.

Note
This function belongs to IOperatingSystemExplorerInterface.
Parameters
TestSpaceThe size in megabytes of the space to test.
Returns
true if the partition has enough space, false otherwise.

Implements IOperatingSystemExplorerInterface.

Here is the caller graph for this function:

◆ IsPartition()

virtual bool UOperatingSystemPartition::IsPartition ( ) const
inlinefinaloverridevirtual

Check if the object is an operating system partition.

Note
This function belongs to IOperatingSystemExplorerInterface.
Returns
true if the object is an operating system partition, false otherwise.

Implements IOperatingSystemExplorerInterface.

◆ IsSystemPartition()

FORCEINLINE bool UOperatingSystemPartition::IsSystemPartition ( ) const
inline

◆ IsValidPartition()

FORCEINLINE bool UOperatingSystemPartition::IsValidPartition ( ) const
inline
Here is the caller graph for this function:

◆ LoadNewPartition()

UOperatingSystemPartition * UOperatingSystemPartition::LoadNewPartition ( UOperatingSystemHDD * OwningHDD,
const FOperatingSystemPartitionSaveLoad & PartitionSaveLoad )
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.

Parameters
OwningHDDThe UOperatingSystemHDD object that owns the partition.
PartitionSaveLoadThe save/load data structure that contains the partition information.
Returns
The loaded or updated UOperatingSystemPartition object.
Note
If a partition with the same ID already exists, it will be returned with its properties updated. If a partition with the same ID does not exist, a new partition will be created and returned. The returned partition will have its properties updated based on the given save/load data.
See also
UOperatingSystemHDD, FOperatingSystemPartitionSaveLoad
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDiskDisplayName()

void UOperatingSystemPartition::SetDiskDisplayName ( const FText & NewName)
protected

Sets the display name of the disk.

This method allows you to set the display name of the disk.

Parameters
NewNameThe new display name to set.

◆ SetDiskLetter()

void UOperatingSystemPartition::SetDiskLetter ( const FName & NewDiskLetter)

Sets the disk letter like C, D, E etc. Mostly used in Non-Unix Operating System

Here is the caller graph for this function:

◆ SetDiskName()

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.

Parameters
NewDiskNameThe new display name of the disk.
Here is the caller graph for this function:

◆ SetOwningOperatingSystem()

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.

Parameters
OwningOSThe owning operating system to set.

◆ SetSystemPartition()

void UOperatingSystemPartition::SetSystemPartition ( const bool bNewSystemPartition)

Sets the system partition flag for the operating system partition.

Parameters
bNewSystemPartitionThe new value to set for the system partition flag.
  • true if the partition is a system partition
  • false if the partition is not a system partition
Here is the caller graph for this function:

Member Data Documentation

◆ bIsSystemPartition

bool UOperatingSystemPartition::bIsSystemPartition
protected

Determines if this is a system partition.

◆ DiskDisplayName

FText UOperatingSystemPartition::DiskDisplayName
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.

◆ DiskLetter

FName UOperatingSystemPartition::DiskLetter
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.

Note
This variable is only visible in instances, cannot be modified, and is transient (does not persist between game sessions).

◆ DiskName

FText UOperatingSystemPartition::DiskName
protected

Specifies the name of the disk associated with an operating system partition.

◆ Files

TArray<TObjectPtr<UOperatingSystemFile> > UOperatingSystemPartition::Files
protected

Array of files created under this partition.

See also
UOperatingSystemFile

◆ FreeSpaceInBytes

double UOperatingSystemPartition::FreeSpaceInBytes
protected

Free space in this partition

◆ ParentHDD

TWeakObjectPtr<UOperatingSystemHDD> UOperatingSystemPartition::ParentHDD
protected

The ParentHDD variable represents a weak reference to the parent UOperatingSystemHDD object that this UOperatingSystemPartition object belongs to.

Usage:

See also
UOperatingSystemHDD

◆ ParentOS

TWeakObjectPtr<UOperatingSystem> UOperatingSystemPartition::ParentOS
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.

See also
UOperatingSystem

◆ PartitionID

FOperatingSystemUniqueId UOperatingSystemPartition::PartitionID
protected

Unique ID of this partition.

◆ TotalSizeInBytes

double UOperatingSystemPartition::TotalSizeInBytes
protected

Total size of this partition


The documentation for this class was generated from the following files: