use file name as volume name

This commit is contained in:
Denis Molony 2021-04-19 12:46:45 +10:00
parent 43ff3c203e
commit 4ab834300d

View File

@ -24,13 +24,14 @@ public class NuFX
private int totalDisks; private int totalDisks;
private int totalBlocks; private int totalBlocks;
private VolumeName volumeName = new VolumeName (); private VolumeName volumeName;
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public NuFX (Path path) throws FileFormatException, IOException public NuFX (Path path) throws FileFormatException, IOException
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
buffer = Files.readAllBytes (path); buffer = Files.readAllBytes (path);
volumeName = new VolumeName (path);
masterHeader = new MasterHeader (buffer); masterHeader = new MasterHeader (buffer);
@ -82,8 +83,6 @@ public class NuFX
if (record.hasDisk ()) if (record.hasDisk ())
++totalDisks; ++totalDisks;
} }
// volumeName.info ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -211,6 +210,18 @@ public class NuFX
private String volumeName = "DiskBrowser"; private String volumeName = "DiskBrowser";
private int nameOffset = 0; private int nameOffset = 0;
// -------------------------------------------------------------------------------//
VolumeName (Path path)
// -------------------------------------------------------------------------------//
{
volumeName = path.getFileName ().toString ();
int pos = volumeName.lastIndexOf ('.');
if (pos > 0)
volumeName = volumeName.substring (0, pos);
if (volumeName.length () > 15)
volumeName = volumeName.substring (0, 15);
}
// -------------------------------------------------------------------------------// // -------------------------------------------------------------------------------//
private void storePath (String fileName) private void storePath (String fileName)
// -------------------------------------------------------------------------------// // -------------------------------------------------------------------------------//
@ -240,6 +251,9 @@ public class NuFX
private String getVolumeName () private String getVolumeName ()
// -------------------------------------------------------------------------------// // -------------------------------------------------------------------------------//
{ {
if (true)
return volumeName;
if (rootContainsFiles) if (rootContainsFiles)
return volumeName; return volumeName;