Utility class for the editor that copies a video file into the editor project temporary filesystem under humanoid_mocap/video using a SHA256 hash filename, and returns the relative path in that virtual filesystem.
using System;
using System.IO;
using System.Security.Cryptography;
namespace HumanoidMocap.EditorTools;
/// <summary>Copies source footage into the editor's local preview filesystem without changing the original.</summary>
public static class VideoFiles
{
public static string CacheVideo(string absolutePath)
{
using var input=File.OpenRead(absolutePath);
var hash=Convert.ToHexString(SHA256.HashData(input)).ToLowerInvariant();
var relative="humanoid_mocap/video/"+hash+Path.GetExtension(absolutePath).ToLowerInvariant();
var fs=global::Editor.FileSystem.ProjectTemporary;
fs.CreateDirectory("humanoid_mocap/video");
var destination=fs.GetFullPath(relative);
if(!File.Exists(destination))File.Copy(absolutePath,destination);
return relative;
}
}