2023-05-06 21:56:27 +02:00
//===== Copyright <20> 2005-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Helper methods + classes for file access.
//
//===========================================================================//
# ifndef FILEUTILS_H
# define FILEUTILS_H
# if defined( _WIN32 )
# pragma once
# endif
# include "filesystem/filesystem.h"
// Builds a directory which is a subdirectory of the current mod.
2023-08-09 14:43:54 +02:00
void GetModSubdirectory ( const char * pSubDir , char * pBuf , ssize_t nBufLen ) ;
2023-05-06 21:56:27 +02:00
// Builds a directory which is a subdirectory of the current mod's *content*.
2023-08-09 14:43:54 +02:00
void GetModContentSubdirectory ( const char * pSubDir , char * pBuf , ssize_t nBufLen ) ;
2023-05-06 21:56:27 +02:00
// Generates a filename under the 'game' subdirectory given a subdirectory of 'content'.
2023-08-09 14:43:54 +02:00
void ComputeModFilename ( const char * pContentFileName , char * pBuf , ssize_t nBufLen ) ;
2023-05-06 21:56:27 +02:00
// Generates a filename under the 'content' subdirectory given a subdirectory of 'game'.
2023-08-09 14:43:54 +02:00
void ComputeModContentFilename ( const char * pGameFileName , char * pBuf , ssize_t nBufLen ) ;
2023-05-06 21:56:27 +02:00
// Finds all files matching the a name within a directory and its sub directories. Output entries are paths to found files (relative to and including szStartDirectory).
2023-07-15 16:24:01 +02:00
void RecursiveFindFilesMatchingName ( CUtlVector < CUtlString > & fileList , const char * szStartDirectory , const char * szTargetFileName , const char * pPathID , char separator = CORRECT_PATH_SEPARATOR ) ;
2023-05-06 21:56:27 +02:00
// Builds a list of all files under a directory with a particular extension.
2023-07-15 16:24:01 +02:00
void AddFilesToList ( CUtlVector < CUtlString > & fileList , const char * pDirectory , const char * pExtension = nullptr , const char * pPathID = nullptr , char separator = CORRECT_PATH_SEPARATOR ) ;
2023-05-06 21:56:27 +02:00
// Returns the search path as a list of paths.
2023-07-15 16:24:01 +02:00
void GetSearchPath ( CUtlVector < CUtlString > & pathList , const char * pPathID ) ;
2023-05-06 21:56:27 +02:00
// Given file name generate a full path using the following rules.
// 1. if its full path already return.
// 2. if its a relative path try to find it under the path id.
// 3. if find fails treat relative path as relative to the current dir.
2023-08-09 14:43:54 +02:00
bool GenerateFullPath ( const char * pFileName , char const * pPathID , char * pBuf , ssize_t nBufLen ) ;
2023-05-06 21:56:27 +02:00
# endif // FILEUTILS_H