struct exfat_node* current;
};
+struct exfat_human_bytes
+{
+ uint64_t value;
+ const char* unit;
+};
+
extern int exfat_errors;
void exfat_bug(const char* format, ...)
le16_t exfat_calc_checksum(const struct exfat_entry_meta1* meta1,
const struct exfat_entry_meta2* meta2, const le16_t* name);
le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name);
+void exfat_humanize_bytes(uint64_t value, struct exfat_human_bytes* hb);
int utf16_to_utf8(char* output, const le16_t* input, size_t outsize,
size_t insize);
}
return cpu_to_le16(hash);
}
+
+void exfat_humanize_bytes(uint64_t value, struct exfat_human_bytes* hb)
+{
+ size_t i;
+ const char* units[] = {"bytes", "KB", "MB", "GB", "TB", "PB"};
+ uint64_t divisor = 1;
+
+ for (i = 0; i < sizeof(units) / sizeof(units[0]) - 1; i++)
+ {
+ if ((value + divisor / 2) / divisor < 1024)
+ break;
+ divisor *= 1024;
+ }
+ hb->value = (value + divisor / 2) / divisor;
+ hb->unit = units[i];
+}