Unmount
Unmount
#Overview
name: Unmount
This variable is created as a Console Variable (cvar).
- type:
Exec
- help:
Sorry: Exec commands have no help
It is referenced in 17
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Unmount is to remove a mounted file or package from the system, typically used in Unreal Engine’s file handling and package management subsystems. This operation is crucial for managing game resources, particularly when dealing with downloadable content, streaming assets, or dynamic loading of game features.
Based on the provided callsites, the Unmount operation is used in several Unreal Engine subsystems and modules:
- GameFeatures plugin
- PakFile system
- IoStore (Input/Output Store) system
- AddContentDialog (Editor)
The value of this variable is not set directly, as it’s typically used as a function name or an enumeration value. It’s invoked in various contexts to perform the unmounting operation.
Other variables that interact with Unmount include:
- Mount (often used as a counterpart operation)
- EMountOperation enum (which includes Mount and Unmount as values)
Developers must be aware of the following when using Unmount:
- It’s critical for resource management and should be used carefully to avoid leaving resources in an inconsistent state.
- Unmounting affects file accessibility, so ensure all operations on the mounted resource are completed before unmounting.
- In some contexts (e.g., PakFile system), unmounting may involve updating internal data structures and notifying other systems.
Best practices when using Unmount:
- Always pair Mount and Unmount operations to maintain system consistency.
- Use appropriate locking mechanisms when unmounting to prevent race conditions in multi-threaded environments.
- Handle potential failures during the unmount process gracefully.
- In editor contexts, ensure unmounting doesn’t interfere with ongoing content creation or editing processes.
- When working with game features or downloadable content, coordinate unmounting with the game’s state management to prevent accessing unmounted resources.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturePluginStateMachine.cpp:1613
Scope (from outer to inner):
file
function void Unmount
Source code excerpt:
bool bCheckedRealtimeMode = false;
void Unmount()
{
if (TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(StateProperties.PluginName);
Plugin && Plugin->GetDescriptor().bExplicitlyLoaded)
{
if (!UE::GameFeatures::bDeferLocalizationDataLoad)
{
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturePluginStateMachine.cpp:1743
Scope (from outer to inner):
file
function virtual void UpdateState
Source code excerpt:
{
bUnmounting = true;
Unmount();
}
if (!Result.HasValue())
{
StateStatus.SetTransitionError(EGameFeaturePluginState::ErrorMounting, Result);
return;
#Loc: <Workspace>/Engine/Source/Editor/AddContentDialog/Private/ContentSourceProviders/FeaturePack/FeaturePackContentSource.cpp:202
Scope (from outer to inner):
file
function FFeaturePackContentSource::FFeaturePackContentSource
Source code excerpt:
LoadFeaturePackImageDataFromPackFile(*PakPlatformFile);
}
PakPlatformFile->Unmount(*InFeaturePackPath);
}
else
{
bContentsInPakFile = false;
FString TemplatesFolder = TEXT("FeaturePack");
FString ThisTemplateRoot = FPaths::GetPath(FeaturePackPath);
#Loc: <Workspace>/Engine/Source/Runtime/Core/Internal/Misc/CoreDelegatesInternal.h:13
Scope: file
Source code excerpt:
{
Mount,
Unmount
};
/** Delegate to indicate that a pakfile has been mounted/unmounted */
DECLARE_TS_MULTICAST_DELEGATE_ThreeParams(FMountOperationPak, EMountOperation /*Operation*/, const TCHAR* /*PakPath*/, int32 /*Order*/);
struct FMountedPakInfo
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/IoStoreOnDemand/Private/OnDemandIoDispatcherBackend.cpp:2164
Scope (from outer to inner):
file
namespace UE::IO::IAS
function void FOnDemandIoBackend::Mount
lambda-function
Source code excerpt:
this->MountContainer(ContainerPath);
break;
case EMountOperation::Unmount:
this->UnmountContainer(ContainerPath);
break;
default:
checkNoEntry();
}
}
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/FilePackageStore.cpp:401
Scope (from outer to inner):
file
function void FFilePackageStoreBackend::Unmount
Source code excerpt:
}
void FFilePackageStoreBackend::Unmount(const FIoContainerHeader* ContainerHeader)
{
FWriteScopeLock _(EntriesLock);
for (auto It = MountedContainers.CreateIterator(); It; ++It)
{
if (It->ContainerHeader == ContainerHeader)
{
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/FilePackageStore.h:91
Scope (from outer to inner):
file
class class FFilePackageStoreBackend : public IPackageStoreBackend
Source code excerpt:
void Mount(FIoContainerHeader* ContainerHeader, uint32 Order);
void Unmount(const FIoContainerHeader* ContainerHeader);
private:
using FMountedDataRange = UE::FilePackageStorePrivate::FMountedDataRange;
using FMountedContainer = UE::FilePackageStorePrivate::FMountedContainer;
using FEntryHandle = UE::FilePackageStorePrivate::FEntryHandle;
using FPackageIdMap = UE::FilePackageStorePrivate::FPackageIdMap;
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:3521
Scope (from outer to inner):
file
class class FPakPrecacher
function void Unmount
Source code excerpt:
}
void Unmount(FName PakFile, FPakFile* UnmountedPak)
{
FScopeLock Lock(&CachedFilesScopeLock);
for (TMap<FPakFile*, uint16>::TIterator It(CachedPaks); It; ++It)
{
if( It->Key->GetFilenameName() == PakFile )
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:7963
Scope (from outer to inner):
file
class class FPakExec : private FSelfRegisteringExec
function virtual bool Exec_Dev
Source code excerpt:
return true;
}
else if (FParse::Command(&Cmd, TEXT("Unmount")))
{
PlatformFile.HandleUnmountCommand(Cmd, Ar);
return true;
}
else if (FParse::Command(&Cmd, TEXT("PakList")))
{
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:8003
Scope (from outer to inner):
file
function void FPakPlatformFile::HandleUnmountCommand
Source code excerpt:
if (!PakFilename.IsEmpty())
{
Unmount(*PakFilename);
}
}
void FPakPlatformFile::HandlePakListCommand(const TCHAR* Cmd, FOutputDevice& Ar)
{
TArray<FPakListEntry> Paks;
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:8678
Scope (from outer to inner):
file
function bool FPakPlatformFile::Unmount
Source code excerpt:
}
bool FPakPlatformFile::Unmount(const TCHAR* InPakFilename)
{
TRefCountPtr<FPakFile> UnmountedPak;
bool bRemovedContainerFile = false;
{
FScopeLock ScopedLock(&PakListCritical);
for (int32 PakIndex = 0; PakIndex < PakFiles.Num(); PakIndex++)
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:8705
Scope (from outer to inner):
file
function bool FPakPlatformFile::Unmount
Source code excerpt:
if (UnmountedPak)
{
PackageStoreBackend->Unmount(UnmountedPak->IoContainerHeader.Get());
}
FString ContainerPath = FPaths::ChangeExtension(InPakFilename, FString());
bRemovedContainerFile = IoDispatcherFileBackend->Unmount(*ContainerPath);
#if WITH_EDITOR
if (UnmountedPak && UnmountedPak->OptionalSegmentIoContainerHeader.IsValid())
{
PackageStoreBackend->Unmount(UnmountedPak->OptionalSegmentIoContainerHeader.Get());
FString OptionalSegmentContainerPath = ContainerPath + FPackagePath::GetOptionalSegmentExtensionModifier();
IoDispatcherFileBackend->Unmount(*OptionalSegmentContainerPath);
}
#endif
}
if (UnmountedPak)
{
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:8728
Scope (from outer to inner):
file
function bool FPakPlatformFile::Unmount
Source code excerpt:
// If the Precacher is running, we need to clear the IsMounted flag inside of its lock,
// to avoid races with RegisterPakFile which reads the flag inside of the lock
FPakPrecacher::Get().Unmount(InPakFilename, UnmountedPak.GetReference());
check(!UnmountedPak || !UnmountedPak->GetIsMounted())
}
else
#endif
{
if (UnmountedPak)
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp:8914
Scope (from outer to inner):
file
function bool FPakPlatformFile::HandleUnmountPakDelegate
Source code excerpt:
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Unmounting pak file: %s \n"), *PakFilePath);
return Unmount(*PakFilePath);
}
void FPakPlatformFile::RegisterEncryptionKey(const FGuid& InGuid, const FAES::FAESKey& InKey)
{
int32 NumMounted = 0;
TSet<int32> ChunksToNotify;
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IoDispatcherFileBackend.cpp:1332
Scope (from outer to inner):
file
function bool FFileIoStore::Unmount
Source code excerpt:
}
bool FFileIoStore::Unmount(const TCHAR* InTocPath)
{
TUniquePtr<FFileIoStoreReader> ReaderToUnmount;
{
FWriteScopeLock _(IoStoreReadersLock);
for (int32 Idx = 0; Idx < IoStoreReaders.Num(); ++Idx)
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Private/IoDispatcherFileBackend.h:108
Scope (from outer to inner):
file
class class FFileIoStore final : public FRunnable , public IIoDispatcherBackend
Source code excerpt:
void Shutdown() override;
TIoStatusOr<FIoContainerHeader> Mount(const TCHAR* InTocPath, int32 Order, const FGuid& EncryptionKeyGuid, const FAES::FAESKey& EncryptionKey);
bool Unmount(const TCHAR* InTocPath);
bool Resolve(FIoRequestImpl* Request) override;
void CancelIoRequest(FIoRequestImpl* Request) override;
void UpdatePriorityForIoRequest(FIoRequestImpl* Request) override;
bool DoesChunkExist(const FIoChunkId& ChunkId) const override;
TIoStatusOr<uint64> GetSizeForChunk(const FIoChunkId& ChunkId) const;
FIoRequestImpl* GetCompletedRequests() override;
#Loc: <Workspace>/Engine/Source/Runtime/PakFile/Public/IPlatformFilePak.h:2192
Scope (from outer to inner):
file
class class FPakPlatformFile : public IPlatformFile
Source code excerpt:
PAKFILE_API bool Mount(const TCHAR* InPakFilename, uint32 PakOrder, const TCHAR* InPath = nullptr, bool bLoadIndex = true, FPakListEntry* OutPakListEntry = nullptr);
PAKFILE_API bool Unmount(const TCHAR* InPakFilename);
PAKFILE_API int32 MountAllPakFiles(const TArray<FString>& PakFolders);
PAKFILE_API int32 MountAllPakFiles(const TArray<FString>& PakFolders, const FString& WildCard);
/**
* Re-creates all the pak readers