Skip to content

UOperatingSystemPartition

#include <OperatingSystemSimulator/Public/Core/OperatingSystemPartition.h>
class UOperatingSystemPartition

Defined in OperatingSystemPartition.h:40

Inherits: UObject, IOperatingSystemExplorerInterface

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemPartition["UOperatingSystemPartition"]
  class UObject["UObject"]
  UObject <|-- UOperatingSystemPartition
  class IOperatingSystemExplorerInterface["IOperatingSystemExplorerInterface"]
  IOperatingSystemExplorerInterface <|-- UOperatingSystemPartition
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemPartition["UOperatingSystemPartition"]
  class UOperatingSystemDirectory["UOperatingSystemDirectory"]
  UOperatingSystemPartition *-- UOperatingSystemDirectory
  class FOperatingSystemUniqueId["FOperatingSystemUniqueId"]
  UOperatingSystemPartition *-- FOperatingSystemUniqueId
  class UOperatingSystemFile["UOperatingSystemFile"]
  UOperatingSystemPartition *-- UOperatingSystemFile
  class UOperatingSystemHDD["UOperatingSystemHDD"]
  UOperatingSystemPartition *-- UOperatingSystemHDD
  class UOperatingSystem["UOperatingSystem"]
  UOperatingSystemPartition *-- UOperatingSystem
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemPartition {
    +SetDiskName(const FString &NewDiskName)
    +SetSystemPartition(const bool bNewSystemPartition)
    +SetOwningOperatingSystem(UOperatingSystem *OwningOS)
    +AddDirectories(const TArray< UOperatingSystemDirectory * >
    +AddDirectory(UOperatingSystemDirectory *NewDirectory)
    +ConsumeSpace(const double &SizeInBytes, FGenericError &O
    +FreeupSpace(const double &SizeInBytes)
    +GetSizeAsText(const EOperatingSystemSizeMethod &SizeMetho FText
    +GetChildDirectories() const override final TArray< UOperatingSystemDirectory() * >
    +GetParentExplorerInterface(TScriptInterface< IOperatingSystemExplorerI
    +IsPartition() const override final bool
    +GetInterfaceDisplayName() const override final FText
    +FindDirectoryByTag(const FGameplayTag DirectoryTag, const bool bool
    +GetChildDirectory(const FString &TargetChildDirectoryName, co TScriptInterface< IOperatingSystemExplor
    +GetAllFiles(const FString &WithExtension="*") const ove TArray< UOperatingSystemFile() * >
    +CanCreateNewFile() const override final bool
    +HasEnoughSpace(const FOperatingSystemSizeInMB &TestSpace)  bool
    +GetOperatingSystem() const override final UOperatingSystem() *
    +GetFullPath() const override final TOptional< FString >
    +GetInterfaceFromPath(const FString &NewPath) const override fina TScriptInterface< IOperatingSystemExplor
    +SetDiskLetter(const FName &NewDiskLetter)
    +GetPartitionPath() const FString
    +IsValidPartition() const bool
    +HasEnoughSpace(const double &TestSpaceInBytes) const bool
    +GetStoragePercentage() const float
    +GetTotalSizeBytes() const double
    +GetFreeSizeBytes() const double
    +IsSystemPartition() const bool
    +GetPartitionID() const FOperatingSystemUniqueId()
    +GetDiskLetter() const FName
    +GetNewPartitionSaveLoad() const FOperatingSystemPartitionSaveLoad()
    +GetChildDirectory(const FString &TargetChildDirectoryName, co T *
    +CreateNewPartition(UOperatingSystemHDD *OwningHDD, const doubl UOperatingSystemPartition() *
    +LoadNewPartition(UOperatingSystemHDD *OwningHDD, const FOper UOperatingSystemPartition() *
    +DiskName : FText
    +DiskDisplayName : FText
    +TotalSizeInBytes : double
    +FreeSpaceInBytes : double
    +bIsSystemPartition : bool
    +PartitionID : FOperatingSystemUniqueId()
    +DiskLetter : FName
    +Files : TArray< TObjectPtr< UOperatingSystemFile
    +ParentHDD : TWeakObjectPtr< UOperatingSystemHDD() >
    +ParentOS : TWeakObjectPtr< UOperatingSystem() >
    +SetDiskDisplayName(const FText &NewName)
    +Directories : TArray< TObjectPtr< UOperatingSystemDire
  }

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

ReturnNameDescription
voidSetDiskNameSets the display name of the disk.
voidSetSystemPartitionSets the system partition flag for the operating system partition.
voidSetOwningOperatingSystemSets the owning operating system of the UOperatingSystemPartition.
voidAddDirectoriesAdds directories to the operating system partition.
voidAddDirectoryAdds a directory to the operating system partition.
voidConsumeSpaceConsume space in the operating system partition.
voidFreeupSpaceThe 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.
FTextGetSizeAsText constConverts the partition size to a human-readable text format.
TArray< UOperatingSystemDirectory * >GetChildDirectories virtual const inline override finalRetrieves the child directories of this operating system partition.
voidGetParentExplorerInterface virtual const inline override finalThis method retrieves the parent explorer interface associated with the operating system partition.
boolIsPartition virtual const inline override finalCheck if the object is an operating system partition.
FTextGetInterfaceDisplayName virtual const inline override finalGet the display name of the interface. This method returns the display name of the interface.
boolFindDirectoryByTag virtual const override finalSearches for a directory by tag in the operating system partition.
TScriptInterface< IOperatingSystemExplorerInterface >GetChildDirectory virtual const override finalReturns a child directory with the specified name.
TArray< UOperatingSystemFile * >GetAllFiles virtual const override finalRetrieves an array of all files in the partition with the specified extension.
boolCanCreateNewFile virtual const inline override finalChecks if a new file can be created in the operating system partition.
boolHasEnoughSpace virtual const override finalChecks if the operating system partition has enough space.
UOperatingSystem *GetOperatingSystem virtual const override finalGet the operating system of the partition.
TOptional< FString >GetFullPath virtual const inline override finalReturns the full path of the operating system partition.
TScriptInterface< IOperatingSystemExplorerInterface >GetInterfaceFromPath virtual const override finalGet the interface from a given path.
voidSetDiskLetterSets the disk letter like C, D, E etc. Mostly used in Non-Unix Operating System
FStringGetPartitionPath constReturns the partition path.
boolIsValidPartition const inline
boolHasEnoughSpace const inline
floatGetStoragePercentage const inline
doubleGetTotalSizeBytes const inline
doubleGetFreeSizeBytes const inline
boolIsSystemPartition const inline
FOperatingSystemUniqueIdGetPartitionID const inline
FNameGetDiskLetter const inline
FOperatingSystemPartitionSaveLoadGetNewPartitionSaveLoad const inline
T *GetChildDirectory virtual const inlineGets a child directory with the given name.

void SetDiskName(const FString & NewDiskName)

Defined in OperatingSystemPartition.h:170 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 SetSystemPartition(const bool bNewSystemPartition)

Defined in OperatingSystemPartition.h:179 Sets the system partition flag for the operating system partition.

  • bNewSystemPartition The 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


void SetOwningOperatingSystem(UOperatingSystem * OwningOS)

Defined in OperatingSystemPartition.h:189 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 AddDirectories(const TArray< UOperatingSystemDirectory * > & NewDirectories, const bool bAppend = false)

Defined in OperatingSystemPartition.h:208 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.

See also: UOperatingSystemDirectory


void AddDirectory(UOperatingSystemDirectory * NewDirectory)

Defined in OperatingSystemPartition.h:220 Adds a directory to the operating system partition.

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

See also: UOperatingSystemDirectory

See also: AddDirectories()


void ConsumeSpace(const double & SizeInBytes, FGenericError & OutError)

Defined in OperatingSystemPartition.h:234 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.”


void FreeupSpace(const double & SizeInBytes)

Defined in OperatingSystemPartition.h:245 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.

const

FText GetSizeAsText(const EOperatingSystemSizeMethod & SizeMethod) const

Defined in OperatingSystemPartition.h:255 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.

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”).


virtual const inline override final

virtual inline TArray< UOperatingSystemDirectory * > GetChildDirectories() const override final

Defined in OperatingSystemPartition.h:275 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.

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


virtual const inline override final

virtual inline void GetParentExplorerInterface(TScriptInterface< IOperatingSystemExplorerInterface > & OutInterface) const override final

Defined in OperatingSystemPartition.h:285 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.

virtual const inline override final

virtual inline bool IsPartition() const override final

Defined in OperatingSystemPartition.h:294 Check if the object is an operating system partition.

true if the object is an operating system partition, false otherwise.


virtual const inline override final

virtual inline FText GetInterfaceDisplayName() const override final

Defined in OperatingSystemPartition.h:304 Get the display name of the interface. This method returns the display name of the interface.

The display name of the interface as a FText object.


virtual const override final

virtual bool FindDirectoryByTag(const FGameplayTag DirectoryTag, const bool bRecursive, UOperatingSystemDirectory *& OutDirectory) const override final

Defined in OperatingSystemPartition.h:320 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.

True if the directory with the tag is found, false otherwise.


virtual const override final

virtual TScriptInterface< IOperatingSystemExplorerInterface > GetChildDirectory(const FString & TargetChildDirectoryName, const bool bRecursive = true) const override final

Defined in OperatingSystemPartition.h:339 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.

A pointer to the child directory if found, or nullptr if not found.

See also: UOperatingSystemPartition, UOperatingSystemPartition::GetChildDirectories


virtual const override final

virtual TArray< UOperatingSystemFile * > GetAllFiles(const FString & WithExtension = "*") const override final

Defined in OperatingSystemPartition.h:353 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.

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.


virtual const inline override final

virtual inline bool CanCreateNewFile() const override final

Defined in OperatingSystemPartition.h:363 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.

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


virtual const override final

virtual bool HasEnoughSpace(const FOperatingSystemSizeInMB & TestSpace) const override final

Defined in OperatingSystemPartition.h:373 Checks if the operating system partition has enough space.

  • TestSpace The size in megabytes of the space to test.

true if the partition has enough space, false otherwise.


virtual const override final

virtual UOperatingSystem * GetOperatingSystem() const override final

Defined in OperatingSystemPartition.h:385 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.

A pointer to the operating system object.


virtual const inline override final

virtual inline TOptional< FString > GetFullPath() const override final

Defined in OperatingSystemPartition.h:397 Returns the full path of the operating system partition.

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

An optional string representing the full path of the partition. If the partition path is not available, the optional value will be empty.


virtual const override final

virtual TScriptInterface< IOperatingSystemExplorerInterface > GetInterfaceFromPath(const FString & NewPath) const override final

Defined in OperatingSystemPartition.h:415 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.

The interface corresponding to the provided path, or nullptr if not found.


void SetDiskLetter(const FName & NewDiskLetter)

Defined in OperatingSystemPartition.h:419 Sets the disk letter like C, D, E etc. Mostly used in Non-Unix Operating System


const

FString GetPartitionPath() const

Defined in OperatingSystemPartition.h:441 Returns the partition path.

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

A formatted string representing the partition path in the format “{disk letter}:{path delimiter}”.


const inline

inline bool IsValidPartition() const

Defined in OperatingSystemPartition.h:443


const inline

inline bool HasEnoughSpace(const double & TestSpaceInBytes) const

const inline

inline float GetStoragePercentage() const

Defined in OperatingSystemPartition.h:445


const inline

inline double GetTotalSizeBytes() const

Defined in OperatingSystemPartition.h:446


const inline

inline double GetFreeSizeBytes() const

const inline

inline bool IsSystemPartition() const

const inline

inline FOperatingSystemUniqueId GetPartitionID() const

const inline

inline FName GetDiskLetter() const

const inline

inline FOperatingSystemPartitionSaveLoad GetNewPartitionSaveLoad() const

Defined in OperatingSystemPartition.h:451


virtual const inline

template<class T> virtual inline T * GetChildDirectory(const FString & TargetChildDirectoryName, const bool bRecursive = true) const

Defined in OperatingSystemPartition.h:484 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.

A pointer to the child directory if it is found, nullptr otherwise.

See also: UOperatingSystemDirectory

ReturnNameDescription
UOperatingSystemPartition *CreateNewPartition staticCreates a new operating system partition.
UOperatingSystemPartition *LoadNewPartition staticLoads a new operating system partition.

static

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

Defined in OperatingSystemPartition.h:140 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.

A pointer to the created UOperatingSystemPartition object, or nullptr if the creation fails.

See also: UOperatingSystemHDD

See also: FGenericError


static

static UOperatingSystemPartition * LoadNewPartition(UOperatingSystemHDD * OwningHDD, const FOperatingSystemPartitionSaveLoad & PartitionSaveLoad)

Defined in OperatingSystemPartition.h:160 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.

The loaded or updated UOperatingSystemPartition object.

See also: UOperatingSystemHDD, FOperatingSystemPartitionSaveLoad

ReturnNameDescription
FTextDiskNameSpecifies the name of the disk associated with an operating system partition.
FTextDiskDisplayNameRepresents 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.
doubleTotalSizeInBytesTotal size of this partition
doubleFreeSpaceInBytesFree space in this partition
boolbIsSystemPartitionDetermines if this is a system partition.
FOperatingSystemUniqueIdPartitionIDUnique ID of this partition.
FNameDiskLetterRepresents 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.
TArray< TObjectPtr< UOperatingSystemFile > >FilesArray of files created under this partition.
TWeakObjectPtr< UOperatingSystemHDD >ParentHDDThe ParentHDD variable represents a weak reference to the parent UOperatingSystemHDD object that this UOperatingSystemPartition object belongs to.
TWeakObjectPtr< UOperatingSystem >ParentOSWeak reference to the parent UOperatingSystem object that this UOperatingSystemPartition object belongs to.

FText DiskName

Defined in OperatingSystemPartition.h:53 Specifies the name of the disk associated with an operating system partition.


FText DiskDisplayName

Defined in OperatingSystemPartition.h:61 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.


double TotalSizeInBytes

Defined in OperatingSystemPartition.h:65 Total size of this partition


double FreeSpaceInBytes

Defined in OperatingSystemPartition.h:69 Free space in this partition


bool bIsSystemPartition

Defined in OperatingSystemPartition.h:73 Determines if this is a system partition.


FOperatingSystemUniqueId PartitionID

Defined in OperatingSystemPartition.h:77 Unique ID of this partition.


FName DiskLetter

Defined in OperatingSystemPartition.h:86 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.


TArray< TObjectPtr< UOperatingSystemFile > > Files

Defined in OperatingSystemPartition.h:94 Array of files created under this partition.

See also: UOperatingSystemFile


TWeakObjectPtr< UOperatingSystemHDD > ParentHDD

Defined in OperatingSystemPartition.h:106 The ParentHDD variable represents a weak reference to the parent UOperatingSystemHDD object that this UOperatingSystemPartition object belongs to.

Usage:

See also: UOperatingSystemHDD


TWeakObjectPtr< UOperatingSystem > ParentOS

Defined in OperatingSystemPartition.h:118 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

ReturnNameDescription
voidSetDiskDisplayNameSets the display name of the disk.

void SetDiskDisplayName(const FText & NewName)

Defined in OperatingSystemPartition.h:430 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.
ReturnNameDescription
TArray< TObjectPtr< UOperatingSystemDirectory > >Directories

TArray< TObjectPtr< UOperatingSystemDirectory > > Directories

Defined in OperatingSystemPartition.h:45