
use mem

+ class InMemoryFile {
    ~ data: ptr
    ~ size: uint
    filename: String ("")
    mime_type: String ("application/octet-stream")

    + static fn create_from_ptr(data: ptr, size: uint) SELF {
        let d : ptr = null.@cast(.)
        if size > 0 {
            d = mem:alloc(size)
            mem:copy(data, d, size)
        }
        return SELF {
            data: d
            size: size
        }
    }

    + fn save(path: String) {
        write_bytes(path, this.data, this.size, false) _
    }
}
