2004-03-03 00:56:51 +01:00
|
|
|
// virtual file system - transparent access to files in archives;
|
2004-05-13 15:52:48 +02:00
|
|
|
// allows multiple mount points
|
2004-03-03 00:56:51 +01:00
|
|
|
//
|
2004-05-13 15:52:48 +02:00
|
|
|
// Copyright (c) 2004 Jan Wassenberg
|
2004-03-03 00:56:51 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// Contact info:
|
|
|
|
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
|
|
// http://www.stud.uni-karlsruhe.de/~urkt/
|
|
|
|
|
|
|
|
#ifndef __VFS_H__
|
|
|
|
#define __VFS_H__
|
|
|
|
|
|
|
|
#include "h_mgr.h"
|
2004-05-07 03:27:05 +02:00
|
|
|
#include "posix.h" // struct stat
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2004-05-13 15:52:48 +02:00
|
|
|
// the VFS doesn't require this length restriction - VFS internal storage
|
|
|
|
// is not fixed-length. the purpose here is to allow fixed-sized path buffers
|
|
|
|
// allocated on the stack.
|
|
|
|
//
|
|
|
|
// length includes trailing '\0'.
|
|
|
|
#define VFS_MAX_PATH 256
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2004-05-08 03:11:51 +02:00
|
|
|
extern int vfs_mount(const char* vfs_mount_point, const char* name, uint pri);
|
2004-05-06 19:14:30 +02:00
|
|
|
extern int vfs_umount(const char* name);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2004-05-06 19:14:30 +02:00
|
|
|
extern int vfs_stat(const char* fn, struct stat*);
|
2004-03-03 00:56:51 +01:00
|
|
|
extern int vfs_realpath(const char* fn, char* realpath);
|
|
|
|
|
|
|
|
extern Handle vfs_load(const char* fn, void*& p, size_t& size);
|
|
|
|
|
2004-05-08 03:11:51 +02:00
|
|
|
extern Handle vfs_open(const char* fn, uint flags = 0);
|
2004-03-03 00:56:51 +01:00
|
|
|
extern int vfs_close(Handle& h);
|
|
|
|
|
2004-05-08 03:11:51 +02:00
|
|
|
extern Handle vfs_map(Handle hf, uint flags, void*& p, size_t& size);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2004-05-06 19:14:30 +02:00
|
|
|
|
2004-05-29 14:00:53 +02:00
|
|
|
struct vfsDirEnt
|
|
|
|
{
|
|
|
|
// the filename is currently stored internally as std::string. returning as char* for C compat
|
|
|
|
// stored internally as std::string. returning as char* for C compat
|
|
|
|
// would mean we have to return a copy. we try to avoid fixed-size
|
|
|
|
// buffers, so that leaves a reference.
|
|
|
|
const char* name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern Handle vfs_open_dir(const char* path);
|
|
|
|
extern int vfs_close_dir(Handle& hd);
|
|
|
|
extern int vfs_next_dirent(Handle hd, vfsDirEnt* ent, const char* filter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-05-13 15:52:48 +02:00
|
|
|
extern int vfs_rebuild();
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-05-06 19:14:30 +02:00
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
//
|
|
|
|
// async read interface
|
|
|
|
//
|
|
|
|
|
|
|
|
extern Handle vfs_start_read(const Handle hf, size_t ofs, size_t& advance, void* buf);
|
|
|
|
extern int vfs_wait_read(Handle hr, void*& p, size_t& size);
|
|
|
|
extern int vfs_discard_read(Handle& hr);
|
|
|
|
|
|
|
|
extern ssize_t vfs_io(Handle hf, size_t ofs, size_t size, void*& p);
|
|
|
|
|
|
|
|
|
2004-03-05 17:23:31 +01:00
|
|
|
// keep in sync with File flags!
|
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VFS_WRITE = 1, // write-only access; otherwise, read only
|
2004-03-05 17:23:31 +01:00
|
|
|
VFS_MEM_READONLY = 2, // !want to be able to change in memory data
|
2004-03-03 00:56:51 +01:00
|
|
|
VFS_NOCACHE = 4, // don't cache whole file, e.g. if cached on a higher level
|
|
|
|
VFS_RANDOM = 8 // random access hint, allow offset
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-06-02 17:31:55 +02:00
|
|
|
#endif // #ifndef __VFS_H__
|