summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/fsmeta.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-12-14 21:38:14 -0500
committer AJR <ajrhacker@users.noreply.github.com>2021-12-14 21:42:42 -0500
commit1214aac0928e5c7ebe3484f06a5c9a000f9962ef (patch)
tree08e4ee14aa16c1fd721dfef0b9dc1eb28471eb8a /src/lib/formats/fsmeta.cpp
parent8a8b56bc24a398f5bda13b0e24a56012a1252353 (diff)
Filesystem code cleanup
- Eliminate dependencies on emu.h, replacing most fatalerror calls and floptool's ersatz emu_fatalerror class with standard exception classes - Use range-based std::string constructors in some methods - Move filesystem metadata handling to a separate source file - Eliminate src/emu as an include path for libformats (necessitates kludge in ti99_dsk.cpp)
Diffstat (limited to 'src/lib/formats/fsmeta.cpp')
-rw-r--r--src/lib/formats/fsmeta.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/formats/fsmeta.cpp b/src/lib/formats/fsmeta.cpp
new file mode 100644
index 00000000000..4f76485a5f8
--- /dev/null
+++ b/src/lib/formats/fsmeta.cpp
@@ -0,0 +1,43 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+
+// Filesystem metadata management
+
+#include "fsmeta.h"
+
+#include "strformat.h"
+
+const char *fs_meta_data::entry_name(fs_meta_name name)
+{
+ switch(name) {
+ case fs_meta_name::basic: return "basic";
+ case fs_meta_name::creation_date: return "creation_date";
+ case fs_meta_name::length: return "length";
+ case fs_meta_name::loading_address: return "loading_address";
+ case fs_meta_name::locked: return "locked";
+ case fs_meta_name::modification_date: return "modification_date";
+ case fs_meta_name::name: return "name";
+ case fs_meta_name::os_minimum_version: return "os_minimum_version";
+ case fs_meta_name::os_version: return "os_version";
+ case fs_meta_name::rsrc_length: return "rsrc_length";
+ case fs_meta_name::sequential: return "sequential";
+ case fs_meta_name::size_in_blocks: return "size_in_blocks";
+ }
+ return "";
+}
+
+std::string fs_meta::to_string(fs_meta_type type, const fs_meta &m)
+{
+ switch(type) {
+ case fs_meta_type::string: return m.as_string();
+ case fs_meta_type::number: return util::string_format("0x%x", m.as_number());
+ case fs_meta_type::flag: return m.as_flag() ? "t" : "f";
+ case fs_meta_type::date: {
+ auto dt = m.as_date();
+ return util::string_format("%04d-%02d-%02d %02d:%02d:%02d",
+ dt.year, dt.month, dt.day_of_month,
+ dt.hour, dt.minute, dt.second);
+ }
+ }
+ return std::string("");
+}