janwas
c0ed950657
this snowballed into a massive search+destroy of the hodgepodge of mostly equivalent types we had in use (int, uint, unsigned, unsigned int, i32, u32, ulong, uintN). it is more efficient to use 64-bit types in 64-bit mode, so the preferred default is size_t (for anything remotely resembling a size or index). tile coordinates are ssize_t to allow more efficient conversion to/from floating point. flags are int because we almost never need more than 15 distinct bits, bit test/set is not slower and int is fastest to type. finally, some data that is pretty much directly passed to OpenGL is now typed accordingly. after several hours, the code now requires fewer casts and less guesswork. other changes: - unit and player IDs now have an "invalid id" constant in the respective class to avoid casting and -1 - fix some endian/64-bit bugs in the map (un)packing. added a convenience function to write/read a size_t. - ia32: change CPUID interface to allow passing in ecx (required for cache topology detection, which I need at work). remove some unneeded functions from asm, replace with intrinsics where possible. This was SVN commit r5942.
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
/**
|
|
* =========================================================================
|
|
* File : vfs_lookup.h
|
|
* Project : 0 A.D.
|
|
* Description : look up directories/files by traversing path components.
|
|
* =========================================================================
|
|
*/
|
|
|
|
// license: GPL; see lib/license.txt
|
|
|
|
#ifndef INCLUDED_VFS_LOOKUP
|
|
#define INCLUDED_VFS_LOOKUP
|
|
|
|
#include "vfs_path.h"
|
|
|
|
class VfsFile;
|
|
class VfsDirectory;
|
|
|
|
// note: VfsDirectory pointers are non-const because they may be
|
|
// populated during the lookup.
|
|
|
|
enum VfsLookupFlags
|
|
{
|
|
// add (if they do not already exist) subdirectory components
|
|
// encountered in the path[name].
|
|
VFS_LOOKUP_ADD = 1,
|
|
|
|
// create a real directory
|
|
VFS_LOOKUP_CREATE = 2
|
|
};
|
|
|
|
/**
|
|
* Resolve a pathname.
|
|
*
|
|
* @param pathname
|
|
* @param vfsStartDirectory
|
|
* @param directory is set to the last directory component that is encountered.
|
|
* @param file is set to 0 if there is no name component, otherwise the
|
|
* corresponding file.
|
|
* @param flags see VfsLookupFlags.
|
|
* @return LibError (INFO::OK if all components in pathname exist).
|
|
*
|
|
* to allow noiseless file-existence queries, this does not raise warnings.
|
|
**/
|
|
extern LibError vfs_Lookup(const VfsPath& pathname, VfsDirectory* startDirectory, VfsDirectory*& directory, VfsFile** pfile, int flags = 0);
|
|
|
|
#endif // #ifndef INCLUDED_VFS_LOOKUP
|