Function Utils::read_file_unified¶
- Defined in File utils.h 
Function Documentation¶
- 
std::string Utils::read_file_unified(const std::string &file_path, FileReadMode mode, size_t tail_lines = 0, const std::string &pattern = "")¶
- Read file content with specified mode. - Efficiently reads file content: - FULL: Reads the entire file. 
- TAIL: Reads the last specified number of lines. 
- SMART: Reads the last specified number of lines; if pattern is not found, reads the entire file. 
 - Parameters:
- file_path – Path to the file 
- mode – Reading mode (FULL, TAIL, or SMART) 
- tail_lines – Number of lines to read from end (if TAIL or SMART mode) 
- pattern – Optional pattern to search for in SMART mode (if empty, no fallback) 
 
- Throws:
- std::runtime_error – if file cannot be read 
- Returns:
- File content as string