1
0
forked from mirrors/0ad
Files
0ad/source/lib/file/io/io.h
T
janwas 4c44602ea0 add support for hotloading (i.e. reacting to directory change notifications and reloading the affected files)
also clean up VFS a bit.
ogl_tex now tolerates deleting/renaming texture files that are in use
(except for a warning message which can be 'continue'd)

This was SVN commit r7166.
2009-11-04 22:35:54 +00:00

52 lines
2.0 KiB
C

/* Copyright (C) 2009 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. 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.
*
* 0 A.D. 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.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* IO manager: splits requests into asynchronously issued blocks,
* thus simplifying caching and enabling periodic callbacks.
*/
#ifndef INCLUDED_IO
#define INCLUDED_IO
#include "lib/file/file.h"
// memory will be allocated from the heap, not the (limited) file cache.
// this makes sense for write buffers that are never used again,
// because we avoid having to displace some other cached items.
LIB_API shared_ptr<u8> io_Allocate(size_t size, off_t ofs = 0);
/**
* called after a block IO has completed.
*
* @return INFO::CB_CONTINUE to continue; any other value will cause the
* IO splitter to abort immediately and return that.
*
* this is useful for user progress notification or processing data while
* waiting for the next I/O to complete (without the complexity of threads).
**/
typedef LibError (*IoCallback)(uintptr_t cbData, const u8* block, size_t blockSize);
LIB_API LibError io_Scan(const PFile& file, off_t ofs, off_t size, IoCallback cb, uintptr_t cbData);
LIB_API LibError io_Read(const PFile& file, off_t ofs, u8* alignedBuf, off_t size, u8*& data);
LIB_API LibError io_WriteAligned(const PFile& file, off_t alignedOfs, const u8* alignedData, off_t size);
LIB_API LibError io_ReadAligned(const PFile& file, off_t alignedOfs, u8* alignedBuf, off_t size);
#endif // #ifndef INCLUDED_IO