mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
File metadata for CPMFS works.
This commit is contained in:
@@ -133,7 +133,7 @@ public:
|
||||
|
||||
Bytes getFile(const Path& path)
|
||||
{
|
||||
AcornDfsDirectory dir(this);
|
||||
AcornDfsDirectory dir(this);
|
||||
auto dirent = dir.findFile(path);
|
||||
int sectors = (dirent->length + 255) / 256;
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
{
|
||||
std::map<std::string, std::string> attributes;
|
||||
|
||||
AcornDfsDirectory dir(this);
|
||||
AcornDfsDirectory dir(this);
|
||||
auto dirent = dir.findFile(path);
|
||||
attributes[FILENAME] = dirent->filename;
|
||||
attributes[LENGTH] = fmt::format("{}", dirent->length);
|
||||
@@ -172,7 +172,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
const AcornDfsProto& _config;
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ class BrotherDirectory
|
||||
public:
|
||||
BrotherDirectory(Filesystem* fs)
|
||||
{
|
||||
/* Read directory. */
|
||||
/* Read directory. */
|
||||
|
||||
int inode = 0;
|
||||
for (int block = 0; block < DIRECTORY_SECTORS; block++)
|
||||
@@ -68,11 +68,11 @@ public:
|
||||
|
||||
auto de = std::make_unique<Brother120Dirent>(inode, buffer);
|
||||
usedSectors += de->sector_length;
|
||||
//dirents.push_back(std::move(de));
|
||||
// dirents.push_back(std::move(de));
|
||||
}
|
||||
}
|
||||
|
||||
/* Read FAT. */
|
||||
/* Read FAT. */
|
||||
|
||||
Bytes bytes = fs->getLogicalSector(FAT_START_SECTOR, FAT_SECTORS);
|
||||
ByteReader br(bytes);
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<uint16_t> fat;
|
||||
std::vector<uint16_t> fat;
|
||||
std::vector<std::unique_ptr<Brother120Dirent>> dirents;
|
||||
uint32_t usedSectors = 0;
|
||||
};
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
if (!path.empty())
|
||||
throw FileNotFoundException();
|
||||
|
||||
BrotherDirectory dir(this);
|
||||
BrotherDirectory dir(this);
|
||||
|
||||
std::vector<std::shared_ptr<Dirent>> result;
|
||||
for (auto& dirent : dir.dirents)
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
|
||||
Bytes getFile(const Path& path)
|
||||
{
|
||||
BrotherDirectory dir(this);
|
||||
BrotherDirectory dir(this);
|
||||
auto dirent = dir.findFile(path);
|
||||
int sector = dirent->start_sector;
|
||||
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
{
|
||||
std::map<std::string, std::string> attributes;
|
||||
|
||||
BrotherDirectory dir(this);
|
||||
BrotherDirectory dir(this);
|
||||
auto dirent = dir.findFile(path);
|
||||
attributes[FILENAME] = dirent->filename;
|
||||
attributes[LENGTH] = fmt::format("{}", dirent->length);
|
||||
|
||||
@@ -82,6 +82,32 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> getMetadata()
|
||||
{
|
||||
mount();
|
||||
|
||||
unsigned usedBlocks = _dirBlocks;
|
||||
for (int d = 0; d < _config.dir_entries(); d++)
|
||||
{
|
||||
auto entry = getEntry(d);
|
||||
if (!entry)
|
||||
continue;
|
||||
|
||||
for (unsigned block : entry->allocation_map)
|
||||
{
|
||||
if (block)
|
||||
usedBlocks++;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> attributes;
|
||||
attributes[VOLUME_NAME] = "";
|
||||
attributes[TOTAL_BLOCKS] = fmt::format("{}", _filesystemBlocks);
|
||||
attributes[USED_BLOCKS] = fmt::format("{}", usedBlocks);
|
||||
attributes[BLOCK_SIZE] = fmt::format("{}", _config.block_size());
|
||||
return attributes;
|
||||
}
|
||||
|
||||
FilesystemStatus check()
|
||||
{
|
||||
return FS_OK;
|
||||
|
||||
Reference in New Issue
Block a user