forked from 0ad/0ad
janwas
a859562ea7
- properly differentiate between buffer/offset alignment and length alignment (relevant since block size has been increased to 256k) - use VfsPath for most game paths instead of CStr - clean up timer interface and implementation - self-tests no longer crash - file_cache.cpp: fix for the case where allocation fails (prevent deleter from seeing a null pointer) - allocators: move all shared_ptr-related stuff to its own component; add DummySharedPtr - codec: disable checksums (important for performance at work) - File: made into an interface class to avoid export problems. not entirely sure about this.. - vfs_path.h, path.h, os_path.h: proper fix for using fs::change_extension and similar utility functions with derivatives of basic_path - lib_api: automatically link against import lib if building lib/ as a DLL - path_util: remove unused functions (this component is deprecated) - compiler.h: add INLINE - Xeromyces.cpp: pass PIVFS so that GetXMBPath works in self-test (should do this mostly everywhere rather than have one singleton g_VFS) This was SVN commit r5537.
68 lines
2.3 KiB
C
68 lines
2.3 KiB
C
/**
|
|
* =========================================================================
|
|
* File : file_system_util.h
|
|
* Project : 0 A.D.
|
|
* Description : helper functions for directory access
|
|
* =========================================================================
|
|
*/
|
|
|
|
// license: GPL; see lib/license.txt
|
|
|
|
#ifndef INCLUDED_FILE_SYSTEM_UTIL
|
|
#define INCLUDED_FILE_SYSTEM_UTIL
|
|
|
|
#include "lib/file/vfs/vfs.h"
|
|
|
|
extern void fs_SortFiles(FileInfos& files);
|
|
extern void fs_SortDirectories(DirectoryNames& directories);
|
|
|
|
extern LibError fs_GetPathnames(PIVFS fs, const VfsPath& path, const char* filter, VfsPaths& pathnames);
|
|
|
|
|
|
/**
|
|
* called for files in a directory.
|
|
*
|
|
* @param pathname full pathname (since FileInfo only gives the name).
|
|
* @param fileInfo file information
|
|
* @param cbData user-specified context
|
|
* @return INFO::CB_CONTINUE on success; any other value will immediately
|
|
* be returned to the caller (no more calls will be forthcoming).
|
|
*
|
|
* CAVEAT: pathname and fileInfo are only valid until the function
|
|
* returns!
|
|
**/
|
|
typedef LibError (*FileCallback)(const VfsPath& pathname, const FileInfo& fileInfo, const uintptr_t cbData);
|
|
|
|
enum DirFlags
|
|
{
|
|
DIR_RECURSIVE = 1
|
|
};
|
|
|
|
/**
|
|
* call back for each file in a directory tree
|
|
*
|
|
* @param cb see DirCallback
|
|
* @param pattern that file names must match. '*' and '&' wildcards
|
|
* are allowed. 0 matches everything.
|
|
* @param flags see DirFlags
|
|
* @param LibError
|
|
**/
|
|
extern LibError fs_ForEachFile(PIVFS fs, const VfsPath& path, FileCallback cb, uintptr_t cbData, const char* pattern = 0, uint flags = 0);
|
|
|
|
|
|
/**
|
|
* determine the next available pathname with a given format.
|
|
* this is useful when creating new files without overwriting the previous
|
|
* ones (screenshots are a good example).
|
|
*
|
|
* @param pathnameFormat format string for the pathname; must contain one
|
|
* format specifier for an (unsigned) int.
|
|
* example: "screenshots/screenshot%04d.png"
|
|
* @param nextNumber in: the first number to try; out: the next number.
|
|
* if 0, numbers corresponding to existing files are skipped.
|
|
* @param nextPathname receives the output.
|
|
**/
|
|
extern void fs_NextNumberedFilename(PIVFS fs, const VfsPath& pathnameFormat, unsigned& nextNumber, VfsPath& nextPathname);
|
|
|
|
#endif // #ifndef INCLUDED_FILE_SYSTEM_UTIL
|