@ -298,6 +298,46 @@ void UTTSManagerBase::WipeCache()
}
}
void UTTSManagerBase : : WipeLastCachedFile ( )
{
IPlatformFile & PlatformFile = FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) ;
FString CacheDir = GetCacheDirectory ( ) ;
if ( ! PlatformFile . DirectoryExists ( * CacheDir ) )
{
UE_LOG ( LogTemp , Warning , TEXT ( " Directory does not exist: %s - Cache disable? " ) , * CacheDir ) ;
return ;
}
TArray < FString > FileNames ;
const FString Wildcard = FPaths : : Combine ( CacheDir , TEXT ( " * " ) ) ;
IFileManager : : Get ( ) . FindFiles ( FileNames , * Wildcard , /*Files=*/ true , /*Directories=*/ false ) ;
if ( FileNames . Num ( ) = = 0 )
{
UE_LOG ( LogTemp , Warning , TEXT ( " No files in dir: %s - Cache disable? " ) , * CacheDir ) ;
return ;
}
FDateTime NewestTimestamp = FDateTime : : MinValue ( ) ;
FString NewestFullPath ;
for ( const FString & FileName : FileNames )
{
const FString FullPath = FPaths : : Combine ( CacheDir , FileName ) ;
const FDateTime Timestamp = IFileManager : : Get ( ) . GetTimeStamp ( * FullPath ) ;
if ( Timestamp > NewestTimestamp )
{
NewestTimestamp = Timestamp ;
NewestFullPath = FullPath ;
}
}
if ( ! NewestFullPath . IsEmpty ( ) & & PlatformFile . FileExists ( * NewestFullPath ) )
{
IFileManager : : Get ( ) . Delete ( * NewestFullPath , /*RequireExists=*/ false , /*EvenReadOnly=*/ true , /*Quiet=*/ true ) ;
UE_LOG ( LogTemp , Warning , TEXT ( " File deleted: %s " ) , * NewestFullPath ) ;
}
}
void UTTSManagerBase : : OnTTSManagerFinished ( )
{
// Reset procedural sound wave