mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 06:35:49 +03:00
Support for RemoteStorageLocalFileChange_t
This commit is contained in:
parent
12902b416e
commit
435a9fd92d
@ -818,7 +818,7 @@ internal enum UGCReadAction : int
|
|||||||
//
|
//
|
||||||
// ERemoteStorageLocalFileChange
|
// ERemoteStorageLocalFileChange
|
||||||
//
|
//
|
||||||
internal enum RemoteStorageLocalFileChange : int
|
public enum RemoteStorageLocalFileChange : int
|
||||||
{
|
{
|
||||||
Invalid = 0,
|
Invalid = 0,
|
||||||
FileUpdated = 1,
|
FileUpdated = 1,
|
||||||
@ -828,10 +828,22 @@ internal enum RemoteStorageLocalFileChange : int
|
|||||||
//
|
//
|
||||||
// ERemoteStorageFilePathType
|
// ERemoteStorageFilePathType
|
||||||
//
|
//
|
||||||
internal enum RemoteStorageFilePathType : int
|
public enum RemoteStorageFilePathType : int
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Unused.
|
||||||
|
/// </summary>
|
||||||
Invalid = 0,
|
Invalid = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An absolute disk path is provided. This type of path is used for files managed via AutoCloud.
|
||||||
|
/// </summary>
|
||||||
Absolute = 1,
|
Absolute = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An ISteamRemoteStorage API relative path is provided. This type of path is used for files
|
||||||
|
/// managed via the ISteamRemoteStorage API methods (FileWrite, FileRead, etc).
|
||||||
|
/// </summary>
|
||||||
APIFilename = 2,
|
APIFilename = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -17,8 +18,34 @@ public class SteamRemoteStorage : SteamClientClass<SteamRemoteStorage>
|
|||||||
internal override void InitializeInterface( bool server )
|
internal override void InitializeInterface( bool server )
|
||||||
{
|
{
|
||||||
SetInterface( server, new ISteamRemoteStorage( server ) );
|
SetInterface( server, new ISteamRemoteStorage( server ) );
|
||||||
|
InstallEvents( server );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void InstallEvents( bool server )
|
||||||
|
{
|
||||||
|
Dispatch.Install<RemoteStorageLocalFileChange_t>( x =>
|
||||||
|
{
|
||||||
|
var count = Internal.GetLocalFileChangeCount();
|
||||||
|
var files = new LocalFileChange[count];
|
||||||
|
|
||||||
|
for ( var i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
RemoteStorageLocalFileChange changeType = default;
|
||||||
|
RemoteStorageFilePathType filePathType = default;
|
||||||
|
|
||||||
|
var filename = Internal.GetLocalFileChange( i, ref changeType, ref filePathType );
|
||||||
|
|
||||||
|
files[i] = new LocalFileChange( filename, changeType, filePathType );
|
||||||
|
}
|
||||||
|
|
||||||
|
OnLocalFileChange?.Invoke( files );
|
||||||
|
}, server );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If a Steam app is flagged for supporting dynamic Steam Cloud sync, and a sync occurs, this callback will be posted to the app if any local files changed.
|
||||||
|
/// </summary>
|
||||||
|
public static event Action<LocalFileChange[]> OnLocalFileChange;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new file, writes the bytes to the file, and then closes the file.
|
/// Creates a new file, writes the bytes to the file, and then closes the file.
|
||||||
@ -177,6 +204,27 @@ public static IEnumerable<string> Files
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IDisposable FileWriteBatch()
|
||||||
|
{
|
||||||
|
Internal.BeginFileWriteBatch();
|
||||||
|
|
||||||
|
return new FileWriteBatchDisposable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class FileWriteBatchDisposable : IDisposable
|
||||||
|
{
|
||||||
|
private bool _disposed;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if ( _disposed ) return;
|
||||||
|
|
||||||
|
_disposed = true;
|
||||||
|
|
||||||
|
Internal.EndFileWriteBatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<LegacyDownloadResult?> LegacyDownloadSharedFile( PublishedFileId fileId, uint priority = 1000 )
|
public static async Task<LegacyDownloadResult?> LegacyDownloadSharedFile( PublishedFileId fileId, uint priority = 1000 )
|
||||||
{
|
{
|
||||||
var result = await Internal.UGCDownload( fileId.Value, priority );
|
var result = await Internal.UGCDownload( fileId.Value, priority );
|
||||||
|
19
Facepunch.Steamworks/Structs/LocalFileChange.cs
Normal file
19
Facepunch.Steamworks/Structs/LocalFileChange.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Steamworks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// References a Remote Storage file that was externally changed
|
||||||
|
/// during the lifetime of the application.
|
||||||
|
/// See <see cref="SteamRemoteStorage.OnLocalFileChange"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Filename">Name of the changed file, of type <paramref name="PathType"/></param>
|
||||||
|
/// <param name="ChangeType">What happened to this file</param>
|
||||||
|
/// <param name="PathType">Type of path to the file</param>
|
||||||
|
public record struct LocalFileChange(
|
||||||
|
string Filename,
|
||||||
|
RemoteStorageLocalFileChange ChangeType,
|
||||||
|
RemoteStorageFilePathType PathType );
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user