primoburner / primoburner-support

PrimoBurner Support
1 stars 0 forks source link

LoadLastTrackLayout and DataDisc get ImageLayout is null #4

Open fengjiannan2010 opened 2 months ago

fengjiannan2010 commented 2 months ago

LoadLastTrackLayout and DataDisc get ImageLayout is null

Library.EnableTraceLog();
Library.SetLicense("");
using var engine = new Engine();
engine.Initialize();
engine.OnDeviceChange += Engine_OnDeviceChange;
engine.OnMediaChange += Engine_OnMediaChange;
var driveLetter = "F";
var device = GetDevice(driveLetter, engine);
if (device == null)
{
    return;
}

DataDisc dataDisc = new DataDisc();
dataDisc.Device = device;
// Set the session start address. This must be done before intializing the file system.
dataDisc.SessionStartAddress = device.NewSessionStartAddress;
int nPrevTrackNumber = GetLastCompleteTrack(device);
if (nPrevTrackNumber > 0)
{
    // Set the track number here. DataDisc will load it later.
    dataDisc.LoadTrackLayout = nPrevTrackNumber;
    dataDisc.DataOverwrite = DataOverwriteFlags.Overwrite;
}

DataFile dataFile = dataDisc.ImageLayout;

// dataFile is null ,

Is the method I'm using incorrect? Can you provide me with a Demo? My requirement is that the burned data cannot be written to the HDD. The data needs to be read directly through the network and written to the disc, so I use BlockDevice for data writing. I need to retain already written data and append write new data.

Windows 11 x64 .net core

Version Windows 11 Professional Workstation Edition
Version 23H2
Installation date ‎2023/‎11/‎9
Operating system version 22631.3447
Processor 13th Gen Intel(R) Core(TM) i9-13900H 2.60 GHz
Onboard RAM 32.0 GB (31.8 GB available)
vkantchev commented 2 months ago

dataDisc.ImageLayout is null because the ImageLayout (i.e. the file system tree) has not been set or loaded. dataDisc.LoadTrackLayout just instructs DataDisc to load the file system later from the corresponding disc track. That will happen at the time of next WriteToDisc() call.

See: https://doc.primoburner.com/net/latest/class_primo_software_1_1_burner_1_1_data_disc.html

If you have to use BlockDevice then you need to keep track of all the files that you manually write and use that information to create the file layout yourself, then pass the layout you created when you call BlockDevice.FinalizeDisc

For an example of how to create the file layout see the CreateFileSystem method in the legacy BlockDevice sample available here: https://github.com/primoburner/primoburner-samples-legacy/blob/main/windows/cpp/samples/BlockDevice/main.cpp#L384

We are in the process of porting all legacy samples to v5.0 but unfortunately have not gotten to do that for the .NET BlockDevice sample yet.

In general, I would study the BlockDevice sample. I think it pretty much covers your use case. Once you can run it for files just update the code to read file data from the network and you should be good.

fengjiannan2010 commented 2 months ago

I have used this sample code: https://github.com/primoburner/primoburner-samples-legacy/blob/main/windows/net/samples/BlockDevice/MainClass.cs#L337 Now I can burn and read files. I recorded the address and size of the file myself, and used BlockDevice.FinalizeDisc to write the file system layout. I hope you can provide an interface to get the address and size of the burned file through the CD. , so that I can append the file system layout using BlockDevice when burning multi-session