mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-02 18:27:18 +00:00
e24453348a
* Add support for other partition types: - msdos, acorn, bsdlabel, amiga, sun, sunpc, apple, gpt * Honour make return values
52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
|
|
|
|
#include <r_fs.h>
|
|
|
|
R_API RFSFile *r_fs_file_new (RFSRoot *root, const char *path) {
|
|
RFSFile *file = R_NEW (RFSFile);
|
|
memset (file, 0, sizeof (RFSFile));
|
|
file->root = root;
|
|
file->name = strdup (path);
|
|
// TODO: concat path?
|
|
return file;
|
|
}
|
|
|
|
R_API void r_fs_file_free (RFSFile *file) {
|
|
free (file->name);
|
|
free (file->data);
|
|
free (file);
|
|
}
|
|
|
|
// TODO: Use RFSRoot and pass it in the stack instead of heap? problematic with bindings
|
|
R_API RFSRoot *r_fs_root_new (const char *path, ut64 delta) {
|
|
char *p;
|
|
RFSRoot *root = R_NEW (RFSRoot);
|
|
root->path = strdup (path);
|
|
p = root->path + strlen (path);
|
|
if (*p == '/') *p = 0; // chop tailing slash
|
|
root->delta = delta;
|
|
return root;
|
|
}
|
|
|
|
R_API void r_fs_root_free (RFSRoot *root) {
|
|
if (root) {
|
|
if (root->p && root->p->umount)
|
|
root->p->umount (root);
|
|
free (root->path);
|
|
free (root);
|
|
}
|
|
}
|
|
|
|
R_API RFSPartition *r_fs_partition_new(int num, ut64 start, ut64 length) {
|
|
RFSPartition *p = R_NEW (RFSPartition);
|
|
memset (p, 0, sizeof (RFSPartition));
|
|
p->number = num;
|
|
p->start = start;
|
|
p->length = length;
|
|
return p;
|
|
}
|
|
|
|
R_API void r_fs_partition_free (RFSPartition *p) {
|
|
free (p);
|
|
}
|