summaryrefslogtreecommitdiff
path: root/indra/llvfs
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llvfs')
-rw-r--r--indra/llvfs/lllfsthread.cpp29
-rw-r--r--indra/llvfs/llvfs.cpp8
2 files changed, 22 insertions, 15 deletions
diff --git a/indra/llvfs/lllfsthread.cpp b/indra/llvfs/lllfsthread.cpp
index a55b5402ed..704e1ab142 100644
--- a/indra/llvfs/lllfsthread.cpp
+++ b/indra/llvfs/lllfsthread.cpp
@@ -73,6 +73,10 @@ LLLFSThread::LLLFSThread(bool threaded) :
LLQueuedThread("LFS", threaded),
mPriorityCounter(PRIORITY_LOWBITS)
{
+ if(!mLocalAPRFilePoolp)
+ {
+ mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
+ }
}
LLLFSThread::~LLLFSThread()
@@ -184,8 +188,9 @@ bool LLLFSThread::Request::processRequest()
if (mOperation == FILE_READ)
{
llassert(mOffset >= 0);
- apr_file_t* filep = ll_apr_file_open(mFileName, LL_APR_RB, mThread->mAPRPoolp);
- if (!filep)
+ LLAPRFile infile ;
+ infile.open(mThread->getLocalAPRFilePool(), mFileName, LL_APR_RB);
+ if (!infile.getFileHandle())
{
llwarns << "LLLFS: Unable to read file: " << mFileName << llendl;
mBytesRead = 0; // fail
@@ -193,13 +198,13 @@ bool LLLFSThread::Request::processRequest()
}
S32 off;
if (mOffset < 0)
- off = ll_apr_file_seek(filep, APR_END, 0);
+ off = infile.seek(APR_END, 0);
else
- off = ll_apr_file_seek(filep, APR_SET, mOffset);
+ off = infile.seek(APR_SET, mOffset);
llassert_always(off >= 0);
- mBytesRead = ll_apr_file_read(filep, mBuffer, mBytes );
- apr_file_close(filep);
+ mBytesRead = infile.read(mBuffer, mBytes );
complete = true;
+ infile.close() ;
// llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl;
}
else if (mOperation == FILE_WRITE)
@@ -207,8 +212,9 @@ bool LLLFSThread::Request::processRequest()
apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY;
if (mOffset < 0)
flags |= APR_APPEND;
- apr_file_t* filep = ll_apr_file_open(mFileName, flags, mThread->mAPRPoolp);
- if (!filep)
+ LLAPRFile outfile ;
+ outfile.open(mThread->getLocalAPRFilePool(), mFileName, flags);
+ if (!outfile.getFileHandle())
{
llwarns << "LLLFS: Unable to write file: " << mFileName << llendl;
mBytesRead = 0; // fail
@@ -216,18 +222,17 @@ bool LLLFSThread::Request::processRequest()
}
if (mOffset >= 0)
{
- S32 seek = ll_apr_file_seek(filep, APR_SET, mOffset);
+ S32 seek = outfile.seek(APR_SET, mOffset);
if (seek < 0)
{
- apr_file_close(filep);
llwarns << "LLLFS: Unable to write file (seek failed): " << mFileName << llendl;
mBytesRead = 0; // fail
return true;
}
}
- mBytesRead = ll_apr_file_write(filep, mBuffer, mBytes );
+ mBytesRead = outfile.write(mBuffer, mBytes );
complete = true;
- apr_file_close(filep);
+
// llinfos << "LLLFSThread::WRITE:" << mFileName << " Bytes: " << mBytesRead << "/" << mBytes << " Offset:" << mOffset << llendl;
}
else
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index 30d20bb35a..8c0ea5fd14 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -2070,9 +2070,11 @@ void LLVFS::dumpFiles()
std::string extension = get_extension(type);
std::string filename = id.asString() + extension;
llinfos << " Writing " << filename << llendl;
- apr_file_t* file = ll_apr_file_open(filename, LL_APR_WB);
- ll_apr_file_write(file, buffer, size);
- apr_file_close(file);
+
+ LLAPRFile outfile ;
+ outfile.open(filename, LL_APR_WB);
+ outfile.write(buffer, size);
+ outfile.close();
delete[] buffer;
files_extracted++;
}