wavelength 1.0.0
Loading...
Searching...
No Matches
Tools::BuildImage::DirectoryVolume Class Referencefinal

A UDF bridge volume, ISO9660 and UDF 1.02, built from the files of a disc root directory. More...

#include <directoryvolume.h>

Inheritance diagram for Tools::BuildImage::DirectoryVolume:
Collaboration diagram for Tools::BuildImage::DirectoryVolume:

Public Member Functions

std::expected< LocatedFile, Error > find (const std::string &name) override
 Locate a file by name anywhere in the tree, ignoring case.
std::expected< void, Error > readSector (std::uint32_t lba, std::span< std::uint8_t, kSectorData > sector) override
 Read the data bytes of one sector.
std::uint32_t volumeSectors () const override
 Report the sector count of the volume.
Public Member Functions inherited from Tools::Common::Volume
virtual ~Volume ()=default
 Release the medium.
virtual std::expected< std::size_t, Error > readSectors (std::uint32_t lba, std::span< std::uint8_t > sectors)
 Read the data bytes of consecutive sectors, stopping where the medium ends.
std::expected< std::string, Error > bootExecutable ()
 Read the name of the executable the disc boots.

Static Public Member Functions

static std::expected< std::unique_ptr< DirectoryVolume >, Error > create (const std::filesystem::path &root, std::optional< std::vector< std::uint8_t > > systemArea, std::vector< Replacement > replacements)
 Build the volume layout.
static std::expected< std::string, Error > identify (const std::filesystem::path &root)
 Read the name of the executable a disc root boots, without building the volume.
Static Public Member Functions inherited from Tools::Common::Volume
static std::expected< std::string, Error > parseBoot2 (std::span< const std::uint8_t > data)
 Read the executable name from the text of SYSTEM.CNF.
static std::uint32_t sectorsFor (std::uint64_t size)
 Count the sectors that a length in bytes occupies.
static std::string upperAscii (std::string_view text)
 Convert the ASCII letters of a text to upper case.
static std::string lowerAscii (std::string_view text)
 Convert the ASCII letters of a text to lower case.
static std::string ambiguousName (std::string_view name, const std::vector< std::filesystem::path > &matches)
 Describe a name that several files share once case is ignored.
static std::unexpected< Error > pastEnd (std::uint32_t lba)
 Report that a sector lies past the end of the medium.

Additional Inherited Members

Public Types inherited from Tools::Common::Volume
using Sector = std::array<std::uint8_t, kSectorData>
 The data bytes of one sector.
Static Public Attributes inherited from Tools::Common::Volume
static constexpr std::size_t kSectorData = 2048
 Data bytes in one sector.
static constexpr std::uint32_t kPvdSector = 16
 Sector of the primary volume descriptor.
static constexpr std::string_view kPvdMagic = "CD001"
 Identifier of an ISO9660 volume descriptor.
static constexpr std::string_view kSystemCnf = "SYSTEM.CNF"
 Name of the boot configuration file.
static constexpr std::string_view kPalExecutable = "SCES_517.06"
 Executable of the European release.
static constexpr std::string_view kNtscExecutable = "SCUS_972.58"
 Executable of the North American release.

Detailed Description

A UDF bridge volume, ISO9660 and UDF 1.02, built from the files of a disc root directory.

The layout is the layout of the discs Sony's DVD-ROM generator mastered. The ISO9660 descriptors and the UDF volume structures take their usual sectors, the path tables follow the UDF anchor, and the ISO9660 directories follow in path table order. The UDF partition comes next, with the UDF directories, a file entry for each directory and file, and then the file data in the same order, which both file systems record. ISO9660 names are upper case, and UDF names keep the case of the source files. Metadata sectors are built in memory, and file sectors are read from the source files or the replacement payloads on demand. Each record has the modification time of its file, and a directory has the newest time of itself and every entry beneath it.

Member Function Documentation

◆ create()

std::expected< std::unique_ptr< DirectoryVolume >, Error > Tools::BuildImage::DirectoryVolume::create ( const std::filesystem::path & root,
std::optional< std::vector< std::uint8_t > > systemArea,
std::vector< Replacement > replacements )
static

Build the volume layout.

Parameters
rootDisc root directory with SYSTEM.CNF.
systemAreaThe 16 system area sectors (32768 bytes) with the boot logo. The sectors are zero when omitted.
replacementsFiles laid out with a payload's contents, size, and modification time in place of the disc root's file of the same name.
Returns
The volume, or an error when the directory is not a disc root, a name is not valid, a file cannot be examined, the system area has the wrong size, or a replacement does not match exactly one file.

◆ identify()

std::expected< std::string, Error > Tools::BuildImage::DirectoryVolume::identify ( const std::filesystem::path & root)
static

Read the name of the executable a disc root boots, without building the volume.

Parameters
rootDisc root directory with SYSTEM.CNF.
Returns
File name from the BOOT2 line of SYSTEM.CNF, without the version suffix, or an error when the directory lacks SYSTEM.CNF or SYSTEM.CNF does not boot a known release.

◆ find()

std::expected< LocatedFile, Error > Tools::BuildImage::DirectoryVolume::find ( const std::string & name)
overridevirtual

Locate a file by name anywhere in the tree, ignoring case.

Parameters
nameFile name without the version suffix.
Returns
Extent and containing directory of the match, or an error when the file is missing, several files have the name once case is ignored, or the file spans several extents.

Implements Tools::Common::Volume.

◆ readSector()

std::expected< void, Error > Tools::BuildImage::DirectoryVolume::readSector ( std::uint32_t lba,
std::span< std::uint8_t, kSectorData > sector )
overridevirtual

Read the data bytes of one sector.

Parameters
lbaSector number.
sectorDestination of the 2048 data bytes.
Returns
Nothing, or an error when the medium ends before the sector.

Implements Tools::Common::Volume.

◆ volumeSectors()

std::uint32_t Tools::BuildImage::DirectoryVolume::volumeSectors ( ) const
nodiscardoverridevirtual

Report the sector count of the volume.

Returns
Sectors described by the primary volume descriptor.

Implements Tools::Common::Volume.


The documentation for this class was generated from the following file: