[sword-svn] r3814 - trunk/src/modules/common
scribe at crosswire.org
scribe at crosswire.org
Sat Oct 17 14:09:17 EDT 2020
Author: scribe
Date: 2020-10-17 14:09:17 -0400 (Sat, 17 Oct 2020)
New Revision: 3814
Modified:
trunk/src/modules/common/zipcomprs.cpp
Log:
Remove FileMgr file handle pool utilization from untar
Modified: trunk/src/modules/common/zipcomprs.cpp
===================================================================
--- trunk/src/modules/common/zipcomprs.cpp 2020-10-17 11:52:15 UTC (rev 3813)
+++ trunk/src/modules/common/zipcomprs.cpp 2020-10-17 18:09:17 UTC (rev 3814)
@@ -99,7 +99,7 @@
int err;
int getheader = 1;
int remaining = 0;
- sword::FileDesc *outfile = NULL;
+ int outFD = 0;
sword::SWBuf fname;
time_t tartime;
@@ -140,19 +140,12 @@
case AREGTYPE:
remaining = getoct(buffer.header.size,12);
if (remaining) {
- outfile = sword::FileMgr::getSystemFileMgr()->open(fname, sword::FileMgr::WRONLY);
- if (!outfile || outfile->getFd() < 0) {
- // try creating directory
- if (strrchr(fname.c_str(), '/')) {
- sword::FileMgr::createParent(fname);
- outfile = sword::FileMgr::getSystemFileMgr()->open(fname, sword::FileMgr::CREAT|sword::FileMgr::WRONLY);
- }
- }
+ outFD = sword::FileMgr::createPathAndFile(fname);
}
else {
- if (outfile) {
- sword::FileMgr::getSystemFileMgr()->close(outfile);
- outfile = NULL;
+ if (outFD > 0) {
+ sword::FileMgr::closeFile(outFD);
+ outFD = 0;
}
}
/*
@@ -167,21 +160,21 @@
else {
unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining;
- if (outfile != NULL) {
- if (outfile->write(&buffer,sizeof(char)*bytes) != (int) bytes) {
+ if (outFD > 0) {
+ if (sword::FileMgr::write(outFD, &buffer,sizeof(char)*bytes) != (int) bytes) {
sword::SWLog::getSystemLog()->logError("error writing %s skipping...", fname.c_str());
- sword::FileMgr::getSystemFileMgr()->close(outfile);
+ sword::FileMgr::closeFile(outFD);
sword::FileMgr::removeFile(fname);
}
}
remaining -= bytes;
if (remaining == 0) {
getheader = 1;
- if (outfile != NULL) {
+ if (outFD > 0) {
// All this logic is simply the set the file timestamp
// ugh
- sword::FileMgr::getSystemFileMgr()->close(outfile);
+ sword::FileMgr::closeFile(outFD);
#ifdef WIN32
HANDLE hFile;
FILETIME ftm,ftLocal;
@@ -209,7 +202,7 @@
settime.actime = settime.modtime = tartime;
utime(fname.c_str(), &settime);
#endif
- outfile = NULL;
+ outFD = 0;
}
}
}
More information about the sword-cvs
mailing list