[sword-svn] r3915 - in trunk: include src/mgr
scribe at crosswire.org
scribe at crosswire.org
Mon Mar 9 16:44:22 EDT 2026
Author: scribe
Date: 2026-03-09 16:44:22 -0400 (Mon, 09 Mar 2026)
New Revision: 3915
Modified:
trunk/include/filemgr.h
trunk/src/mgr/filemgr.cpp
Log:
added loadfile to filemgr
Modified: trunk/include/filemgr.h
===================================================================
--- trunk/include/filemgr.h 2025-08-11 20:02:39 UTC (rev 3914)
+++ trunk/include/filemgr.h 2026-03-09 20:44:22 UTC (rev 3915)
@@ -195,6 +195,14 @@
static int removeFile(const char *fName);
static char getLine(FileDesc *fDesc, SWBuf &line, bool strip = true);
+ /** load a full file up into a buffer
+ * @param fDesc file descriptor to load (from FileMgr::open)
+ * @param strip if we should strip the whitespace from front and back of each line
+ * @param skipCommentLines skip lines which start with '#'
+ * @return SWBuf filled with full file contents
+ */
+ static SWBuf loadFile(FileDesc *fDesc, bool strip = false, bool skipCommentLines = false);
+
/**
* Determines where SWORD looks for the user's home folder. This is
* typically used as a place to find any additional personal SWORD
Modified: trunk/src/mgr/filemgr.cpp
===================================================================
--- trunk/src/mgr/filemgr.cpp 2025-08-11 20:02:39 UTC (rev 3914)
+++ trunk/src/mgr/filemgr.cpp 2026-03-09 20:44:22 UTC (rev 3915)
@@ -590,6 +590,31 @@
}
+SWBuf FileMgr::loadFile(FileDesc *fDesc, bool strip, bool skipCommentLines) {
+ SWBuf line;
+ SWBuf bufferedFile;
+ bool first = true;
+
+ bool goodLine = FileMgr::getLine(fDesc, line, strip);
+ // clean UTF encoding tags at start of file
+ while (goodLine && line.length() &&
+ ((((unsigned char)line[0]) == 0xEF) ||
+ (((unsigned char)line[0]) == 0xBB) ||
+ (((unsigned char)line[0]) == 0xBF))) {
+ line << 1;
+ }
+
+ while (goodLine) {
+ // ignore commented lines
+ if (!skipCommentLines || !line.startsWith("#")) {
+ bufferedFile += line;
+ }
+ goodLine = FileMgr::getLine(fDesc, line);
+ }
+ return bufferedFile;
+}
+
+
char FileMgr::isDirectory(const char *path) {
#ifndef WIN32
struct stat stats;
More information about the sword-cvs
mailing list