Skip to content

Commit

Permalink
Write timestamps from recctrl.bin to extracted files 'Last Modified'
Browse files Browse the repository at this point in the history
date
  • Loading branch information
emoose committed Aug 21, 2019
1 parent e0da8e0 commit 470527a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 6 additions & 9 deletions XbRecUnpack/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/* XbRecUnpack - tool for extracting Xbox recctrl.bin files
* by emoose
*
* Changelog:
* v1.234:
* - Changed out LZX decoder to a native C# version, no longer need to P/Invoke any windows DLLs :)
*
* v0.123:
* - Initial version, finally got Xbox/Xbox360 recctrl unpacking to work fine!
*/

using System;
Expand All @@ -25,7 +18,7 @@ static void Main(string[] args)
bool extractFiles = true;

Console.WriteLine("XbRecUnpack - tool for extracting Xbox recctrl.bin files");
Console.WriteLine("v1.234 by emoose");
Console.WriteLine("v1.2345 by emoose");

string filePath = @"";
int pathIdx = 0;
Expand Down Expand Up @@ -143,7 +136,11 @@ static void ProcessRecovery(string controlPath, string dataPath, string outputPa

try
{
entry.Extract(dataStream, File.Create(destPath));
using(var destStream = File.Create(destPath))
entry.Extract(dataStream, destStream);

// Set last modified time to entry's timestamp
File.SetLastWriteTime(destPath, entry.DateTime);
}
catch (LzxInvalidWindowSize)
{
Expand Down
14 changes: 11 additions & 3 deletions XbRecUnpack/RecoveryControlFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class RecoveryControlEntry
public ushort VersionIndex;
public ushort DeviceIndex;
public uint DecompressedSize;
public ulong FileTime;
public long FileTime;
public string FilePath;

// Array of LZX compression-block sizes, all should decompress to a 0x8000 byte block
Expand All @@ -36,6 +36,14 @@ public int CompressedSize
}
}

public DateTime DateTime
{
get
{
return DateTime.FromFileTime(FileTime);
}
}

public RecoveryControlEntry(RecoveryControlFile baseFile)
{
_baseFile = baseFile;
Expand All @@ -55,8 +63,8 @@ public void Read(BinaryReader reader)
// So we need this so we can trim it down to the proper size
DecompressedSize = reader.ReadUInt32();

// FILETIME timestamp of the file, we should probably convert this...
FileTime = reader.ReadUInt64();
// FILETIME timestamp of the file
FileTime = reader.ReadInt64();

// Path of this file
FilePath = reader.ReadMSString();
Expand Down

0 comments on commit 470527a

Please sign in to comment.