mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Merge pull request #94 from jhett12321/master
Add FileTimestamp property to RemoteStorage.File.
This commit is contained in:
commit
438127288a
@ -77,7 +77,8 @@ public void WriteFiles()
|
||||
|
||||
foreach ( var file in client.RemoteStorage.Files )
|
||||
{
|
||||
Console.WriteLine( $"- {file.FileName} ({file.SizeInBytes} bytes)" );
|
||||
DateTime t = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(file.FileTimestamp);
|
||||
Console.WriteLine( $"- {file.FileName} ({file.SizeInBytes} bytes), modified {t:O}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class RemoteFile
|
||||
private readonly bool _isUgc;
|
||||
private string _fileName;
|
||||
private int _sizeInBytes = -1;
|
||||
private long _timestamp = 0;
|
||||
private UGCHandle_t _handle;
|
||||
private ulong _ownerId;
|
||||
|
||||
@ -84,6 +85,21 @@ public int SizeInBytes
|
||||
internal set { _sizeInBytes = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Date modified timestamp in epoch format.
|
||||
/// </summary>
|
||||
public long FileTimestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( _timestamp != 0 ) return _timestamp;
|
||||
if (_isUgc) throw new NotImplementedException();
|
||||
_timestamp = remoteStorage.native.GetFileTimestamp(FileName);
|
||||
return _timestamp;
|
||||
}
|
||||
internal set { _timestamp = value; }
|
||||
}
|
||||
|
||||
internal RemoteFile( RemoteStorage r, UGCHandle_t handle )
|
||||
{
|
||||
Exists = true;
|
||||
@ -94,7 +110,7 @@ internal RemoteFile( RemoteStorage r, UGCHandle_t handle )
|
||||
_handle = handle;
|
||||
}
|
||||
|
||||
internal RemoteFile( RemoteStorage r, string name, ulong ownerId, int sizeInBytes = -1 )
|
||||
internal RemoteFile( RemoteStorage r, string name, ulong ownerId, int sizeInBytes = -1, long timestamp = 0 )
|
||||
{
|
||||
remoteStorage = r;
|
||||
|
||||
@ -102,6 +118,7 @@ internal RemoteFile( RemoteStorage r, string name, ulong ownerId, int sizeInByte
|
||||
_fileName = name;
|
||||
_ownerId = ownerId;
|
||||
_sizeInBytes = sizeInBytes;
|
||||
_timestamp = timestamp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -177,16 +177,18 @@ private void UpdateFiles()
|
||||
{
|
||||
int size;
|
||||
var name = NormalizePath( native.GetFileNameAndSize( i, out size ) );
|
||||
var timestamp = native.GetFileTimestamp(name);
|
||||
|
||||
var existing = _files.FirstOrDefault( x => x.FileName == name );
|
||||
if ( existing == null )
|
||||
{
|
||||
existing = new RemoteFile( this, name, client.SteamId, size );
|
||||
existing = new RemoteFile( this, name, client.SteamId, size, timestamp );
|
||||
_files.Add( existing );
|
||||
}
|
||||
else
|
||||
{
|
||||
existing.SizeInBytes = size;
|
||||
existing.FileTimestamp = timestamp;
|
||||
}
|
||||
|
||||
existing.Exists = true;
|
||||
|
Loading…
Reference in New Issue
Block a user