[sword-svn] r2599 - in trunk: include src/modules/comments/rawfiles
scribe at crosswire.org
scribe at crosswire.org
Fri Feb 11 22:11:09 MST 2011
Author: scribe
Date: 2011-02-11 22:11:09 -0700 (Fri, 11 Feb 2011)
New Revision: 2599
Modified:
trunk/include/rawfiles.h
trunk/src/modules/comments/rawfiles/rawfiles.cpp
Log:
Fixed bug reported by Gary Holmund regarding safe handline of absense of incfile
Modified: trunk/include/rawfiles.h
===================================================================
--- trunk/include/rawfiles.h 2011-02-11 20:28:28 UTC (rev 2598)
+++ trunk/include/rawfiles.h 2011-02-12 05:11:09 UTC (rev 2599)
@@ -33,7 +33,7 @@
class SWDLLEXPORT RawFiles : public RawVerse, public SWCom {
- char *getNextFilename();
+ const char *getNextFilename();
public:
Modified: trunk/src/modules/comments/rawfiles/rawfiles.cpp
===================================================================
--- trunk/src/modules/comments/rawfiles/rawfiles.cpp 2011-02-11 20:28:28 UTC (rev 2598)
+++ trunk/src/modules/comments/rawfiles/rawfiles.cpp 2011-02-12 05:11:09 UTC (rev 2599)
@@ -63,10 +63,10 @@
/******************************************************************************
- * RawFiles::getRawEntry - Returns the correct verse when char * cast
- * is requested
+ * RawFiles::getRawEntry - Retrieve the unprocessed entry contents at
+ * the current key position of this module
*
- * RET: string buffer with verse
+ * RET: entry contents
*/
SWBuf &RawFiles::getRawEntryBuf() {
@@ -102,7 +102,7 @@
/******************************************************************************
- * RawFiles::setEntry(char *)- Update the modules current key entry with
+ * RawFiles::setEntry(char *)- Update the module's current key entry with
* provided text
*/
@@ -183,22 +183,22 @@
* RET: filename
*/
-char *RawFiles::getNextFilename() {
- static char incfile[255];
- __u32 number;
+const char *RawFiles::getNextFilename() {
+ SWBuf incfile;
+ __u32 number = 0;
FileDesc *datafile;
- sprintf(incfile, "%s/incfile", path);
+ incfile.setFormatted("%s/incfile", path);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::RDONLY);
-
- if (datafile->read(&number, 4) != 4) number = 0;
- number = swordtoarch32(number);
-
+ if (datafile->getFd() != -1) {
+ if (datafile->read(&number, 4) != 4) number = 0;
+ number = swordtoarch32(number);
+ }
number++;
FileMgr::getSystemFileMgr()->close(datafile);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
- sprintf(incfile, "%.7d", number-1);
+ incfile.setFormatted("%.7d", number-1);
number = archtosword32(number);
datafile->write(&number, 4);
@@ -208,7 +208,7 @@
}
-char RawFiles::createModule (const char *path) {
+char RawFiles::createModule(const char *path) {
char *incfile = new char [ strlen (path) + 16 ];
__u32 zero = 0;
More information about the sword-cvs
mailing list