hex-editor/src/source-loaded-file.h

28 lines
847 B
C

// source-loaded-file: A file fully loaded to memory
//
// This data source is a normal file entirely loaded to RAM. The flexibility of
// RAM accesses allow us to implement all of the capabilities.
#pragma once
#include "buffer.h"
#include <stddef.h>
typedef struct {
/* Path to file (owned by this structure) */
char *path;
/* Original file size. This is used to determine whether we can save the
file by a normal overwrite (with expansion) or we need to delete and
re-create the file to shrink it */
size_t original_size;
/* The entire file, as a RAM buffer */
buffer_t *buf;
/* Whether the source is dirty (ie. we changed the buffer through a call
to write()) */
bool dirty;
} loaded_file_t;
source_t *source_loaded_file_open(char const *path);
source_t *source_loaded_file_new(void);