Compare commits

..

No commits in common. "f6d3bf65bc7d7630efdad46886f72953b933284e" and "04e032164b7d85c2d81c7b725f75753070d12fec" have entirely different histories.

3 changed files with 40 additions and 21 deletions

View File

@ -1,8 +1,5 @@
using System.Runtime.InteropServices; using AssetDependencyGraph;
using System.Text.Json; using System.Text.Json;
using AssetDependencyGraph;
using UnityFileApi;
UnityFileSystem.Init();
switch (Environment.GetCommandLineArgs()[1]) switch (Environment.GetCommandLineArgs()[1])
{ {

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace UnityFileApi namespace UnityFileApi
{ {
public static class DependencyTool public static class DependencyTool
@ -11,17 +12,38 @@ namespace UnityFileApi
public static List<string> GetDependencies(string path) public static List<string> GetDependencies(string path)
{ {
List<string> dependencies = new List<string>(); List<string> dependencies = new List<string>();
try
// Try as SerializedFile
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{ {
foreach (var extRef in serializedFile.ExternalReferences) using var archive = UnityFileSystem.MountArchive(path, "/");
foreach (var node in archive.Nodes)
{ {
dependencies.Add(extRef.Guid); Console.WriteLine($"Processing {node.Path} {node.Size} {node.Flags}");
}
}
return dependencies; if (node.Flags.HasFlag(ArchiveNodeFlags.SerializedFile))
{
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{
foreach (var extRef in serializedFile.ExternalReferences)
{
dependencies.Add(extRef.Guid);
}
}
}
}
return dependencies;
}
catch (NotSupportedException)
{
// Try as SerializedFile
using (var serializedFile = UnityFileSystem.OpenSerializedFile(path))
{
foreach (var extRef in serializedFile.ExternalReferences)
{
dependencies.Add(extRef.Guid);
}
}
return dependencies;
}
} }
} }
} }

View File

@ -152,7 +152,7 @@ namespace UnityFileApi
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "UFS_MountArchive")] EntryPoint = "UFS_MountArchive")]
public static extern ReturnCode MountArchive([MarshalAs(UnmanagedType.LPUTF8Str)] string path, [MarshalAs(UnmanagedType.LPUTF8Str)] string mountPoint, out UnityArchiveHandle handle); public static extern ReturnCode MountArchive([MarshalAs(UnmanagedType.LPStr)] string path, [MarshalAs(UnmanagedType.LPStr)] string mountPoint, out UnityArchiveHandle handle);
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
@ -172,14 +172,14 @@ namespace UnityFileApi
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "UFS_CreateArchive")] EntryPoint = "UFS_CreateArchive")]
public static extern ReturnCode CreateArchive([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPUTF8Str)] string[] sourceFiles, public static extern ReturnCode CreateArchive([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] string[] sourceFiles,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPUTF8Str)] string[] aliases, bool[] isSerializedFile, int count, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] string[] aliases, bool[] isSerializedFile, int count,
[MarshalAs(UnmanagedType.LPUTF8Str)] string archiveFile, CompressionType compression, out int crc); [MarshalAs(UnmanagedType.LPStr)] string archiveFile, CompressionType compression, out int crc);
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "UFS_OpenFile")] EntryPoint = "UFS_OpenFile")]
public static extern ReturnCode OpenFile([MarshalAs(UnmanagedType.LPUTF8Str)] string path, out UnityFileHandle handle); public static extern ReturnCode OpenFile([MarshalAs(UnmanagedType.LPStr)] string path, out UnityFileHandle handle);
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, EntryPoint = "UFS_ReadFile")] CallingConvention = CallingConvention.Cdecl, EntryPoint = "UFS_ReadFile")]
@ -204,7 +204,7 @@ namespace UnityFileApi
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "UFS_OpenSerializedFile")] EntryPoint = "UFS_OpenSerializedFile")]
public static extern ReturnCode OpenSerializedFile([MarshalAs(UnmanagedType.LPUTF8Str)] string path, out SerializedFileHandle handle); public static extern ReturnCode OpenSerializedFile([MarshalAs(UnmanagedType.LPStr)] string path, out SerializedFileHandle handle);
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
@ -239,8 +239,8 @@ namespace UnityFileApi
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "UFS_GetRefTypeTypeTree")] EntryPoint = "UFS_GetRefTypeTypeTree")]
public static extern ReturnCode GetRefTypeTypeTree(SerializedFileHandle handle, [MarshalAs(UnmanagedType.LPUTF8Str)] string className, public static extern ReturnCode GetRefTypeTypeTree(SerializedFileHandle handle, [MarshalAs(UnmanagedType.LPStr)] string className,
[MarshalAs(UnmanagedType.LPUTF8Str)] string namespaceName, [MarshalAs(UnmanagedType.LPUTF8Str)] string assemblyName, out TypeTreeHandle typeTree); [MarshalAs(UnmanagedType.LPStr)] string namespaceName, [MarshalAs(UnmanagedType.LPStr)] string assemblyName, out TypeTreeHandle typeTree);
[DllImport("UnityFileSystemApi", [DllImport("UnityFileSystemApi",
CallingConvention = CallingConvention.Cdecl, CallingConvention = CallingConvention.Cdecl,