You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/App/Project/ProjectDB.bf
+75-4Lines changed: 75 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -13,24 +13,34 @@ namespace Nanoforge.App
13
13
{
14
14
///Project database. Tracks editor objects and changes made to them through transactions.
15
15
///If you're comparing this to the C++ codebase this is really the Project + Registry classes combined. They only ever exist together so they were merged.
16
-
///This implementation the more generic data model used by the C++ codebase for ease of use and type checks.
16
+
///This implementation was exchanged was chosen over the more generic data model used by the C++ codebase for ease of use and comptime type checks.
17
17
publicstaticclassProjectDB
18
18
{
19
19
publicstaticStringProjectFilePath{get;privateset;}=new.()~delete _;//Path of project file
staticDictionary<EditorObject,String> _objectNames =new.()~DeleteDictionaryAndValues!(_);//Names owned by Project so we don't add unnecessary bloat to unnamed objects
staticappendDictionary<EditorObject,String> _objectNames ~ClearDictionaryAndDeleteValues!(_);//Names owned by Project so we don't add unnecessary bloat to unnamed objects
//Undo/redo stacks. Just using plain lists + Add() & PopBack() to handle pushing onto the stack and popping off it.
30
34
//Eventually should replace with a Stack<T> class that inherits List<T> and hides non stack function. At the moment Beef doesn't have a standard stack class.
//Used to add objects created by DiffUtil when it commits changes. It creates its own objects so they can be destroyed on rollback and don't exist program wide until commit.
45
68
publicstaticvoidAddObject(EditorObjectobj)
46
69
{
@@ -149,4 +172,52 @@ namespace Nanoforge.App
149
172
}
150
173
}
151
174
}
175
+
176
+
//Binary blob of data attached to the project. Useful for bulk binary data such as textures and meshes.
//Read buffer from hard drive. Caller takes ownership of the result if it returns .Ok
199
+
publicResult<List<u8>>Load()
200
+
{
201
+
ScopedLock!(_lock);
202
+
varbytes=newList<u8>();
203
+
if(File.ReadAll(GetPath(.. scope.()),bytes) case .Ok)
204
+
{
205
+
return.Ok(bytes);
206
+
}
207
+
else
208
+
{
209
+
deletebytes;
210
+
return.Err;
211
+
}
212
+
}
213
+
214
+
publicResult<void>Save(Span<u8>data)
215
+
{
216
+
//TODO: Port tiny buffer merge optimization from the C++ version. Prevents having 1000s of 1KB or less files in the buffers folder since that causes performance issues.
0 commit comments