Re-implement VFS internals in C++, removing the constraints of the previous implementation.

PiperOrigin-RevId: 649433087
Change-Id: Icaa3e6b7f2ef14f56b04fef2f4360b46d8b5f022
This commit is contained in:
Kyle Bayes
2024-07-04 09:21:18 -07:00
committed by Copybara-Service
parent 118b6810b3
commit 57e6760ec9
19 changed files with 513 additions and 717 deletions
+1 -7
View File
@@ -41,8 +41,6 @@ public const double mjMINIMP = 0.0001;
public const double mjMAXIMP = 0.9999;
public const int mjMAXCONPAIR = 50;
public const int mjMAXTREEDEPTH = 50;
public const int mjMAXVFS = 2000;
public const int mjMAXVFSNAME = 1000;
public const int mjNEQDATA = 11;
public const int mjNDYN = 10;
public const int mjNGAIN = 10;
@@ -4978,11 +4976,7 @@ public unsafe struct mjLROpt_ {
[StructLayout(LayoutKind.Sequential)]
public unsafe struct _mjVFS
{
public int nfile;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2000 * 1000)] public char[] filename;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2000)] public UIntPtr[] filesize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2000)] public IntPtr[] filedata;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2000)] public UInt64[] filestamp;
public void* impl_;
}
[StructLayout(LayoutKind.Sequential)]
-5
View File
@@ -40,11 +40,6 @@ public sealed class MjVfs : IDisposable {
}
}
// Number of files added to the filesystem.
public int FilesCount {
get { return Data.nfile; }
}
// Adds a new file to the virtual filesystem.
public unsafe void AddFile(string filename, string contents) {
var contents_bytes = Encoding.UTF8.GetBytes(contents);
+1 -1
View File
@@ -40,7 +40,7 @@ namespace Mujoco {
var filename = "filename";
var contents = "contents";
_vfs.AddFile(filename, contents);
Assert.That(_vfs.FilesCount, Is.EqualTo(1));
Assert.That(() => { _vfs.AddFile(filename, contents); }, Throws.Exception); // duplicate file
}
}
}