Nucleus
Barry File object 015db5a (3 years, 3 months ago)
/*
* This file implements the File object and associated functions. A file
* represents an opened file, and holds a reference the the underlying inode.
* Most of the functions here are just wrappers around the file operations.
* They perform the necessary validation to ensure the operation can be called
* on the particular file. If no operation is found, they may implement a
* generic version.
*/
#include <nucleus/object.h>
#include <nucleus/vfs.h>
static void file_delete(Object *);
/* File object type */
ObjectType fileType = {
.size = sizeof(File),
.delete = file_delete,
};
/* Destroy a file */
static void
file_delete(Object *obj)
{
File *file = (void *) obj;
if (file->inode)
put(file->inode);
if (file->path)
destroy_list(file->path);
}