0ad/source/lib/res/file/file_internal.h
janwas e6be7e36d2 FILE_WRITE_TO_MOD is now FILE_WRITE_TO_TARGET
ERR_(FILE|PATH)_NOT_FOUND -> ERR_TNODE_NOT_FOUND, ERR_NOT_(FILE|DIR) ->
ERR_TNODE_WRONG TYPE
path_util:
- path_append: bugfix (no more extraneous /); add support for appending
slash
- path_replace: bugfix (no more warnings for expected error)
- add path_last_component, path_foreach_component
- move some defs to the header that belong there from vfs.h/path.h

file: add dir_create; move PosixFile definition here and provide
accessor for fileio
vfs: no longer automatically append slash; instead, make sure caller
does
vfs_mount:
- mount_realpath: bugfix (strip trailing /), interface improvement
- document write_target; clarify MULTIPLE_MOUNTINGS; add support for
creating real dirs
vfs_tree:
- refactor TDir::add into find, add, find_and_add
- fix TDir and TNode for dir-ends-with-slash requirement
- split up lookup into lookup_cb and path_foreach_component
- add support for inserting dirs with given mount point: tree_add_path
(needed when mounting)

wposix: get rid of weird PATH_MAX = 260 (Win32 weirdness)


TextureManager: remove no longer needed SupportedTextureFormats
GameSetup, Xeromyces: setup XMB location to data/cache/mods/official/xmb
Util: HardcodedErrorString now uses error_description_r
VFSUtil, i18n: fixes for dir slash issue

Closes #79, #80

This was SVN commit r3874.
2006-05-17 14:48:18 +00:00

89 lines
3.1 KiB
C

/**
* =========================================================================
* File : file_internal.h
* Project : 0 A.D.
* Description : master (private) header for all file code.
*
* @author Jan.Wassenberg@stud.uni-karlsruhe.de
* =========================================================================
*/
/*
* Copyright (c) 2006 Jan Wassenberg
*
* Redistribution and/or modification are also permitted under the
* terms of the GNU General Public License as published by the
* Free Software Foundation (version 2 or later, at your option).
*
* 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.
*/
#include "lib/path_util.h"
#include "path.h"
#include "file.h"
#include "file_cache.h"
#include "file_io.h"
#include "file_stats.h" // must come after file and file_cache
#include "compression.h"
#include "zip.h"
#include "archive.h"
#include "archive_builder.h"
#include "vfs.h"
#include "vfs_mount.h"
#include "vfs_tree.h"
#include "vfs_redirector.h"
#include "trace.h"
#include "vfs_optimizer.h"
const size_t AIO_SECTOR_SIZE = 512;
// block := power-of-two sized chunk of a file.
// all transfers are expanded to naturally aligned, whole blocks
// (this makes caching parts of files feasible; it is also much faster
// for some aio implementations, e.g. wposix).
//
// this is not exposed to users because it's an implementation detail and
// they shouldn't care.
//
// measurements show this value to yield best read throughput.
const size_t FILE_BLOCK_SIZE = 32*KiB;
// helper routine used by functions that call back to a FileIOCB.
//
// bytes_processed is 0 if return value != { ERR_OK, INFO_CB_CONTINUE }
// note: don't abort if = 0: zip callback may not actually
// output anything if passed very little data.
extern LibError file_io_call_back(const void* block, size_t size,
FileIOCB cb, uintptr_t ctx, size_t& bytes_processed);
// retrieve the next (order is unspecified) dir entry matching <filter>.
// return 0 on success, ERR_DIR_END if no matching entry was found,
// or a negative error code on failure.
// filter values:
// - 0: anything;
// - "/": any subdirectory;
// - "/|<pattern>": any subdirectory, or as below with <pattern>;
// - <pattern>: any file whose name matches; ? and * wildcards are allowed.
//
// note that the directory entries are only scanned once; after the
// end is reached (-> ERR_DIR_END returned), no further entries can
// be retrieved, even if filter changes (which shouldn't happen - see impl).
//
// rationale: we do not sort directory entries alphabetically here.
// most callers don't need it and the overhead is considerable
// (we'd have to store all entries in a vector). it is left up to
// higher-level code such as VfsUtil.
extern LibError dir_filtered_next_ent(DirIterator* di, DirEnt* ent, const char* filter);
// returns file descriptor (int) given File (assumed to represent PosixFile).
// this avoids the need for declaring PosixFile here for file_io's use.
extern int file_fd_from_PosixFile(File* f);