// Bastard File System
// (C) 2007 Rene Schickbauer
//
// The Bastard File System (BFS) is a small virtual FS for Applications
// that would normally use Tarballs and/or Zipfiles but have to dynamically
// change its contents
//
// WARNING: This is still ALPHA QUALITY CODE! Use with care!
//
//
#include "bfs_magic.h"
#include "bfs.h"
#include "bfs_rawio.h"
#include "string.h"

    
bool readMagicBlock(sBFS* handle, BLOCK_MAGIC* data) {
    BLOCK_RAW raw;
    
    if(!readRawBlock(handle, 0, &raw)) {
        return false;
    }
    memcpy(data, &raw, 512); // Assume compiler adds no stupid padding
    
    
    return true;
}


bool writeMagicBlock(sBFS* handle, BLOCK_MAGIC* data) {
    BLOCK_RAW raw;
    memset(&raw, 0, sizeof(raw));
    
    // copy data to RAW block
    memcpy(&raw, data, 512); // Assume compiler adds no stupid padding
    
    return writeRawBlock(handle, 0, &raw);
    
}
