get_NewLineEnding
C++ Function Reference
1 Signature
bool BigDataStatMeth::get_NewLineEnding(const char *filename)2 Description
Checks if a file ends with a newline character.
3 Parameters
filename(const char *): Path to the file to check
4 Returns
bool True if file ends with newline, false otherwise
5 Details
filenamePath to the file to check bool True if file ends with newline, false otherwiseOpens file in binary mode to ensure consistent behavior across platforms
6 Caller Graph
7 Source Code
NoteImplementation
File: inst/include/hdf5Utilities/hdf5ImportFiles.hpp • Lines 93-102
inline bool get_NewLineEnding(const char *filename) {
const int LINE_FEED = '\x0A';
FILE *f = fopen(filename, "rb"); /* binary mode */
if (f == NULL) return false;
const bool empty_file = fseek(f, 0, SEEK_END) == 0 && ftell(f) == 0;
const bool result = !empty_file ||
(fseek(f, -1, SEEK_END) == 0 && fgetc(f) == LINE_FEED);
fclose(f);
return result;
}8 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = get_NewLineEnding(...);