LLAPRFile cleaned up

This commit is contained in:
Shyotl
2011-09-20 21:39:27 -05:00
parent 0ace809572
commit d917bf6b06
19 changed files with 126 additions and 215 deletions

View File

@@ -225,8 +225,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
//-------------------------------------------------------------------- //--------------------------------------------------------------------
std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName); std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName);
LLAPRFile infile ; LLAPRFile infile(path, LL_APR_R);
infile.open(path, LL_APR_R);
apr_file_t *fp = infile.getFileHandle(); apr_file_t *fp = infile.getFileHandle();
if (!fp) if (!fp)
return E_ST_NO_XLT_FILE; return E_ST_NO_XLT_FILE;

View File

@@ -357,8 +357,7 @@ BOOL LLKeyframeMotionParam::loadMotions()
// open the file // open the file
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
S32 fileSize = 0; S32 fileSize = 0;
LLAPRFile infile ; LLAPRFile infile(path, LL_APR_R, &fileSize);
infile.open(path, LL_APR_R, LLAPRFile::global, &fileSize);
apr_file_t* fp = infile.getFileHandle() ; apr_file_t* fp = infile.getFileHandle() ;
if (!fp || fileSize == 0) if (!fp || fileSize == 0)
{ {

View File

@@ -210,8 +210,7 @@ LLFSMState* LLStateDiagram::getState(U32 state_id)
BOOL LLStateDiagram::saveDotFile(const std::string& filename) BOOL LLStateDiagram::saveDotFile(const std::string& filename)
{ {
LLAPRFile outfile ; LLAPRFile outfile(filename, LL_APR_W);
outfile.open(filename, LL_APR_W);
apr_file_t* dot_file = outfile.getFileHandle() ; apr_file_t* dot_file = outfile.getFileHandle() ;
if (!dot_file) if (!dot_file)

View File

@@ -102,12 +102,12 @@ LLAPRFile::LLAPRFile()
{ {
} }
LLAPRFile::LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type) LLAPRFile::LLAPRFile(const std::string& filename, apr_int32_t flags, S32* sizep, access_t access_type)
: mFile(NULL), : mFile(NULL),
mVolatileFilePoolp(NULL), mVolatileFilePoolp(NULL),
mRegularFilePoolp(NULL) mRegularFilePoolp(NULL)
{ {
open(filename, flags, access_type); open(filename, flags, access_type, sizep);
} }
LLAPRFile::~LLAPRFile() LLAPRFile::~LLAPRFile()
@@ -147,7 +147,8 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc
apr_status_t status; apr_status_t status;
{ {
apr_pool_t* apr_file_open_pool; apr_pool_t* apr_file_open_pool;
if (access_type == local) // This is a temporary variable for a pool that is passed directly to apr_file_open below.
if (access_type == short_lived)
{ {
// Use a "volatile" thread-local pool. // Use a "volatile" thread-local pool.
mVolatileFilePoolp = &AIThreadLocalData::tldata().mVolatileAPRPool; mVolatileFilePoolp = &AIThreadLocalData::tldata().mVolatileAPRPool;
@@ -193,7 +194,7 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc
apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool) apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool)
{ {
return open(filename, flags, use_global_pool ? LLAPRFile::global : LLAPRFile::local); return open(filename, flags, use_global_pool ? LLAPRFile::long_lived : LLAPRFile::short_lived);
} }
// File I/O // File I/O
S32 LLAPRFile::read(void *buf, S32 nbytes) S32 LLAPRFile::read(void *buf, S32 nbytes)

View File

@@ -145,15 +145,15 @@ private:
public: public:
enum access_t { enum access_t {
global, // Use a global pool for long-lived file accesses. This should really only happen from the main thread. long_lived, // Use a global pool for long-lived file accesses.
local // Use a thread-local volatile pool for short file accesses. short_lived // Use a volatile pool for short-lived file accesses.
}; };
LLAPRFile() ; LLAPRFile() ;
LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type = LLAPRFile::global); LLAPRFile(const std::string& filename, apr_int32_t flags, S32* sizep = NULL, access_t access_type = short_lived);
~LLAPRFile() ; ~LLAPRFile() ;
apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type = LLAPRFile::global, S32* sizep = NULL); apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type = short_lived, S32* sizep = NULL);
apr_status_t open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool); //use global pool. apr_status_t open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool); //use global pool.
apr_status_t close() ; apr_status_t close() ;

View File

@@ -1580,8 +1580,7 @@ BOOL LLImageFormatted::load(const std::string &filename)
resetLastError(); resetLastError();
S32 file_size = 0; S32 file_size = 0;
LLAPRFile infile ; LLAPRFile infile(filename, LL_APR_RB, &file_size);
infile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size);
apr_file_t* apr_file = infile.getFileHandle(); apr_file_t* apr_file = infile.getFileHandle();
if (!apr_file) if (!apr_file)
{ {
@@ -1616,8 +1615,7 @@ BOOL LLImageFormatted::save(const std::string &filename)
{ {
resetLastError(); resetLastError();
LLAPRFile outfile ; LLAPRFile outfile(filename, LL_APR_WB);
outfile.open(filename, LL_APR_WB, LLAPRFile::global);
if (!outfile.getFileHandle()) if (!outfile.getFileHandle())
{ {
setLastError("Unable to open file for writing", filename); setLastError("Unable to open file for writing", filename);

View File

@@ -473,8 +473,7 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
resetLastError(); resetLastError();
S32 file_size = 0; S32 file_size = 0;
LLAPRFile infile ; LLAPRFile infile(filename, LL_APR_RB, &file_size);
infile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size);
apr_file_t* apr_file = infile.getFileHandle() ; apr_file_t* apr_file = infile.getFileHandle() ;
if (!apr_file) if (!apr_file)
{ {

View File

@@ -184,8 +184,7 @@ bool LLLFSThread::Request::processRequest()
if (mOperation == FILE_READ) if (mOperation == FILE_READ)
{ {
llassert(mOffset >= 0); llassert(mOffset >= 0);
LLAPRFile infile ; // auto-closes LLAPRFile infile(mFileName, LL_APR_RB);
infile.open(mFileName, LL_APR_RB, LLAPRFile::local);
if (!infile.getFileHandle()) if (!infile.getFileHandle())
{ {
llwarns << "LLLFS: Unable to read file: " << mFileName << llendl; llwarns << "LLLFS: Unable to read file: " << mFileName << llendl;
@@ -207,8 +206,7 @@ bool LLLFSThread::Request::processRequest()
apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY;
if (mOffset < 0) if (mOffset < 0)
flags |= APR_APPEND; flags |= APR_APPEND;
LLAPRFile outfile ; LLAPRFile outfile(mFileName, flags);
outfile.open(mFileName, flags, LLAPRFile::local);
if (!outfile.getFileHandle()) if (!outfile.getFileHandle())
{ {
llwarns << "LLLFS: Unable to write file: " << mFileName << llendl; llwarns << "LLLFS: Unable to write file: " << mFileName << llendl;

View File

@@ -2098,8 +2098,7 @@ void LLVFS::dumpFiles()
std::string filename = id.asString() + extension; std::string filename = id.asString() + extension;
llinfos << " Writing " << filename << llendl; llinfos << " Writing " << filename << llendl;
LLAPRFile outfile; LLAPRFile outfile(filename, LL_APR_WB);
outfile.open(filename, LL_APR_WB, LLAPRFile::local);
outfile.write(&buffer[0], size); outfile.write(&buffer[0], size);
outfile.close(); outfile.close();

View File

@@ -2677,8 +2677,7 @@ void LLAppViewer::handleViewerCrash()
else crash_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,ERROR_MARKER_FILE_NAME); else crash_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,ERROR_MARKER_FILE_NAME);
llinfos << "Creating crash marker file " << crash_file_name << llendl; llinfos << "Creating crash marker file " << crash_file_name << llendl;
LLAPRFile crash_file ; LLAPRFile crash_file(crash_file_name, LL_APR_W);
crash_file.open(crash_file_name, LL_APR_W, LLAPRFile::local);
if (crash_file.getFileHandle()) if (crash_file.getFileHandle())
{ {
LL_INFOS("MarkerFile") << "Created crash marker file " << crash_file_name << LL_ENDL; LL_INFOS("MarkerFile") << "Created crash marker file " << crash_file_name << LL_ENDL;
@@ -2749,8 +2748,7 @@ bool LLAppViewer::anotherInstanceRunning()
if (LLAPRFile::isExist(marker_file, LL_APR_RB)) if (LLAPRFile::isExist(marker_file, LL_APR_RB))
{ {
// File exists, try opening with write permissions // File exists, try opening with write permissions
LLAPRFile outfile ; LLAPRFile outfile(marker_file, LL_APR_WB);
outfile.open(marker_file, LL_APR_WB, LLAPRFile::global);
apr_file_t* fMarker = outfile.getFileHandle() ; apr_file_t* fMarker = outfile.getFileHandle() ;
if (!fMarker) if (!fMarker)
{ {
@@ -2827,7 +2825,7 @@ void LLAppViewer::initMarkerFile()
// Create the marker file for this execution & lock it // Create the marker file for this execution & lock it
apr_status_t s; apr_status_t s;
s = mMarkerFile.open(mMarkerFileName, LL_APR_W, LLAPRFile::global); s = mMarkerFile.open(mMarkerFileName, LL_APR_W, LLAPRFile::long_lived);
if (s == APR_SUCCESS && mMarkerFile.getFileHandle()) if (s == APR_SUCCESS && mMarkerFile.getFileHandle())
{ {
@@ -4027,8 +4025,7 @@ void LLAppViewer::sendLogoutRequest()
gLogoutInProgress = TRUE; gLogoutInProgress = TRUE;
mLogoutMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LOGOUT_MARKER_FILE_NAME); mLogoutMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LOGOUT_MARKER_FILE_NAME);
LLAPRFile outfile ; LLAPRFile outfile(mLogoutMarkerFileName, LL_APR_W);
outfile.open(mLogoutMarkerFileName, LL_APR_W, LLAPRFile::global);
mLogoutMarkerFile = outfile.getFileHandle() ; mLogoutMarkerFile = outfile.getFileHandle() ;
if (mLogoutMarkerFile) if (mLogoutMarkerFile)
{ {

View File

@@ -8,177 +8,105 @@
#include "llvorbisencode.h" #include "llvorbisencode.h"
#include "llwearable.h" #include "llwearable.h"
#include "llbvhloader.h" #include "llbvhloader.h"
#include <boost/bind.hpp>
struct
{
std::string extension;
LLAssetType::EType type;
boost::function<bool(const std::string&, const std::string&)> conv_fn;
}conversion_list[] =
{
{ "bmp", LLAssetType::AT_TEXTURE, boost::bind(&LLViewerTextureList::createUploadFile,_1,_2,IMG_CODEC_BMP) },
{ "tga", LLAssetType::AT_TEXTURE, boost::bind(&LLViewerTextureList::createUploadFile,_1,_2,IMG_CODEC_TGA) },
{ "jpg", LLAssetType::AT_TEXTURE, boost::bind(&LLViewerTextureList::createUploadFile,_1,_2,IMG_CODEC_JPEG)},
{ "jpeg", LLAssetType::AT_TEXTURE, boost::bind(&LLViewerTextureList::createUploadFile,_1,_2,IMG_CODEC_JPEG)},
{ "png", LLAssetType::AT_TEXTURE, boost::bind(&LLViewerTextureList::createUploadFile,_1,_2,IMG_CODEC_PNG) },
{ "jp2", LLAssetType::AT_TEXTURE, &LLAssetConverter::copyFile },
{ "j2k", LLAssetType::AT_TEXTURE, &LLAssetConverter::copyFile },
{ "j2c", LLAssetType::AT_TEXTURE, &LLAssetConverter::copyFile },
{ "wav", LLAssetType::AT_SOUND, &encode_vorbis_file },
{ "ogg", LLAssetType::AT_SOUND, &LLAssetConverter::copyFile },
{ "bvh", LLAssetType::AT_ANIMATION, &LLAssetConverter::copyBVH },
{ "animatn", LLAssetType::AT_ANIMATION, &LLAssetConverter::copyFile },
{ "gesture", LLAssetType::AT_GESTURE, &LLAssetConverter::copyFile },
{ "notecard", LLAssetType::AT_NOTECARD, &LLAssetConverter::copyFile },
{ "lsl", LLAssetType::AT_LSL_TEXT, &LLAssetConverter::copyFile },
//tmp ?
};
// static // static
extern std::string STATUS[]; extern std::string STATUS[];
LLAssetType::EType LLAssetConverter::convert(std::string src_filename, std::string filename) LLAssetType::EType LLAssetConverter::convert(const std::string &src_filename, const std::string &filename)
{ {
std::string exten = gDirUtilp->getExtension(src_filename); std::string exten = gDirUtilp->getExtension(src_filename);
LLAssetType::EType asset_type = LLAssetType::AT_NONE; for(U32 i = 0;i < sizeof(conversion_list) / sizeof(conversion_list[0]); ++i)
if (exten.empty())
return LLAssetType::AT_NONE;
else if(exten == "bmp")
{ {
asset_type = LLAssetType::AT_TEXTURE; if(conversion_list[i].extension == exten)
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_BMP ))
{ {
return LLAssetType::AT_NONE; return conversion_list[i].conv_fn(src_filename, filename) ?
conversion_list[i].type : LLAssetType::AT_NONE;
} }
} }
else if( exten == "tga") EWearableType wear_type = LLWearable::typeNameToType(exten);
if(wear_type != WT_NONE && copyFile(src_filename, filename))
{ {
asset_type = LLAssetType::AT_TEXTURE; return LLWearable::typeToAssetType(wear_type);
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_TGA ))
{
return LLAssetType::AT_NONE;
}
} }
else if( exten == "jpg" || exten == "jpeg")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_JPEG ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "png")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_PNG ))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "wav")
{
asset_type = LLAssetType::AT_SOUND;
if(encode_vorbis_file(src_filename, filename) != LLVORBISENC_NOERR)
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "ogg")
{
asset_type = LLAssetType::AT_SOUND;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
//else if(exten == "tmp") FIXME
else if (exten == "bvh")
{
asset_type = LLAssetType::AT_ANIMATION; llwarns << "Unhandled extension" << llendl;
S32 file_size; return LLAssetType::AT_NONE;
LLAPRFile fp;
fp.open(src_filename, LL_APR_RB, LLAPRFile::global, &file_size);
if(!fp.getFileHandle()) return LLAssetType::AT_NONE;
char* file_buffer = new char[file_size + 1];
ELoadStatus load_status = E_ST_OK;
S32 line_number = 0;
LLBVHLoader* loaderp = new LLBVHLoader(file_buffer, load_status, line_number);
if(load_status == E_ST_NO_XLT_FILE)
{
llwarns << "NOTE: No translation table found." << llendl;
}
else
{
llwarns << "ERROR: [line: " << line_number << "] " << STATUS[load_status].c_str() << llendl;
}
S32 buffer_size = loaderp->getOutputSize();
U8* buffer = new U8[buffer_size];
LLDataPackerBinaryBuffer dp(buffer, buffer_size);
loaderp->serialize(dp);
LLAPRFile apr_file(filename, LL_APR_WB, LLAPRFile::global);
apr_file.write(buffer, buffer_size);
delete[] file_buffer;
delete[] buffer;
fp.close();
apr_file.close();
}
else if (exten == "animatn")
{
asset_type = LLAssetType::AT_ANIMATION;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "jp2" || exten == "j2k" || exten == "j2c")
{
asset_type = LLAssetType::AT_TEXTURE;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "gesture")
{
asset_type = LLAssetType::AT_GESTURE;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "notecard")
{
asset_type = LLAssetType::AT_NOTECARD;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "lsl")
{
asset_type = LLAssetType::AT_LSL_TEXT;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
else
{
EWearableType wear_type = LLWearable::typeNameToType(exten);
if(wear_type != WT_NONE)
{
asset_type = LLWearable::typeToAssetType(wear_type);
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
else
{
llwarns << "Unhandled extension" << llendl;
return LLAssetType::AT_NONE;
}
}
return asset_type;
} }
BOOL LLAssetConverter::copyFile(std::string src_filename, std::string dst_filename) bool LLAssetConverter::copyFile(const std::string &src_filename, const std::string &dst_filename)
{ {
S32 src_size; S32 src_size;
LLAPRFile src_fp;
src_fp.open(src_filename, LL_APR_RB, LLAPRFile::global, &src_size); LLAPRFile src_fp(src_filename, LL_APR_RB, &src_size);
if(!src_fp.getFileHandle()) return FALSE; if(!src_fp.getFileHandle()) return false;
LLAPRFile dst_fp;
dst_fp.open(dst_filename, LL_APR_WB, LLAPRFile::global); LLAPRFile dst_fp(dst_filename, LL_APR_WB);
if(!dst_fp.getFileHandle()) return FALSE; if(!dst_fp.getFileHandle()) return false;
char* buffer = new char[src_size + 1];
src_fp.read(buffer, src_size); std::vector<char> buffer(src_size + 1);
dst_fp.write(buffer, src_size);
src_fp.close(); src_fp.read(&buffer[0], src_size);
dst_fp.close(); dst_fp.write(&buffer[0], src_size);
delete[] buffer;
return TRUE; return true;
}
bool LLAssetConverter::copyBVH(const std::string &src_filename, const std::string &dst_filename)
{
S32 file_size;
LLAPRFile fp(src_filename, LL_APR_RB, &file_size);
if(!fp.getFileHandle()) return false;
std::vector<char> buffer(file_size + 1);
ELoadStatus load_status = E_ST_OK;
S32 line_number = 0;
LLBVHLoader* loaderp = new LLBVHLoader(&buffer[0], load_status, line_number);
if(load_status == E_ST_NO_XLT_FILE)
{
llwarns << "NOTE: No translation table found." << llendl;
}
else if(load_status != E_ST_OK)
{
llwarns << "ERROR: [line: " << line_number << "] " << STATUS[load_status].c_str() << llendl;
}
buffer.resize(loaderp->getOutputSize());
LLDataPackerBinaryBuffer dp((U8*)&buffer[0], buffer.size());
loaderp->serialize(dp);
delete loaderp;
LLAPRFile apr_file(dst_filename, LL_APR_RB, &file_size);
if(!apr_file.getFileHandle()) return false;
apr_file.write(&buffer[0], buffer.size());
return true;
} }
// </edit> // </edit>

View File

@@ -8,8 +8,9 @@
class LLAssetConverter class LLAssetConverter
{ {
public: public:
static LLAssetType::EType convert(std::string src_filename, std::string filename); static LLAssetType::EType convert(const std::string &src_filename, const std::string &filename);
static BOOL copyFile(std::string src_filename, std::string dest_filename); static bool copyFile(const std::string &src_filename, const std::string &dest_filename);
static bool copyBVH(const std::string &src_filename, const std::string &dst_filename);
}; };
#endif #endif
// </edit> // </edit>

View File

@@ -325,8 +325,7 @@ BOOL LLFloaterAnimPreview::postBuild()
// now load bvh file // now load bvh file
S32 file_size; S32 file_size;
LLAPRFile infile ; LLAPRFile infile(mFilenameAndPath, LL_APR_RB, &file_size);
infile.open(mFilenameAndPath, LL_APR_RB, LLAPRFile::global, &file_size);
if (!infile.getFileHandle()) if (!infile.getFileHandle())
{ {
@@ -422,8 +421,7 @@ BOOL LLFloaterAnimPreview::postBuild()
else if(exten == "animatn") else if(exten == "animatn")
{ {
S32 file_size; S32 file_size;
LLAPRFile raw_animatn; LLAPRFile raw_animatn(mFilenameAndPath, LL_APR_RB, &file_size);
raw_animatn.open(mFilenameAndPath, LL_APR_RB, LLAPRFile::global, &file_size);
if (!raw_animatn.getFileHandle()) if (!raw_animatn.getFileHandle())
{ {

View File

@@ -103,8 +103,7 @@ void LLFloaterVFS::reloadEntry(entry file)
gVFS->removeFile(file.mID, file.mType); gVFS->removeFile(file.mID, file.mType);
std::string file_name = file.mFilename; std::string file_name = file.mFilename;
S32 file_size; S32 file_size;
LLAPRFile fp; LLAPRFile fp(file_name, LL_APR_RB, &file_size);
fp.open(file_name, LL_APR_RB, LLAPRFile::global, &file_size);
if(fp.getFileHandle()) if(fp.getFileHandle())
{ {
LLVFile file(gVFS, asset_id, asset_type, LLVFile::WRITE); LLVFile file(gVFS, asset_id, asset_type, LLVFile::WRITE);
@@ -256,8 +255,7 @@ void LLFloaterVFS::onClickAdd_continued(void* user_data, AIFilePicker* filepicke
LLUUID asset_id; LLUUID asset_id;
asset_id.generate(); asset_id.generate();
S32 file_size; S32 file_size;
LLAPRFile fp; LLAPRFile fp(temp_filename, LL_APR_RB, &file_size);
fp.open(temp_filename, LL_APR_RB, LLAPRFile::global, &file_size);
if(fp.getFileHandle()) if(fp.getFileHandle())
{ {
if(asset_type == LLAssetType::AT_TEXTURE) if(asset_type == LLAssetType::AT_TEXTURE)

View File

@@ -994,7 +994,9 @@ LLAPRFile* LLTextureCache::openHeaderEntriesFile(bool readonly, S32 offset)
{ {
llassert_always(mHeaderAPRFile == NULL); llassert_always(mHeaderAPRFile == NULL);
apr_int32_t flags = readonly ? APR_READ|APR_BINARY : APR_READ|APR_WRITE|APR_BINARY; apr_int32_t flags = readonly ? APR_READ|APR_BINARY : APR_READ|APR_WRITE|APR_BINARY;
mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, LLAPRFile::local); // All code calling openHeaderEntriesFile, immediately calls closeHeaderEntriesFile,
// so this file is very short-lived.
mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags);
if(offset > 0) if(offset > 0)
{ {
mHeaderAPRFile->seek(APR_SET, offset); mHeaderAPRFile->seek(APR_SET, offset);

View File

@@ -901,8 +901,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
uuid = tid.makeAssetID(gAgent.getSecureSessionID()); uuid = tid.makeAssetID(gAgent.getSecureSessionID());
// copy this file into the vfs for upload // copy this file into the vfs for upload
S32 file_size; S32 file_size;
LLAPRFile infile ; LLAPRFile infile(filename, LL_APR_RB, &file_size);
infile.open(filename, LL_APR_RB, LLAPRFile::local, &file_size);
if (infile.getFileHandle()) if (infile.getFileHandle())
{ {
LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE);

View File

@@ -1252,8 +1252,7 @@ void LLObjectBackup::uploadNextAsset()
uuid = tid.makeAssetID(gAgent.getSecureSessionID()); uuid = tid.makeAssetID(gAgent.getSecureSessionID());
S32 file_size; S32 file_size;
LLAPRFile outfile; LLAPRFile outfile(filename, LL_APR_RB, &file_size);
outfile.open(filename, LL_APR_RB, LLAPRFile::local, &file_size);
if (outfile.getFileHandle()) if (outfile.getFileHandle())
{ {
const S32 buf_size = 65536; const S32 buf_size = 65536;

View File

@@ -9939,8 +9939,7 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id )
void LLVOAvatar::dumpArchetypeXML( void* ) void LLVOAvatar::dumpArchetypeXML( void* )
{ {
LLVOAvatar* avatar = gAgent.getAvatarObject(); LLVOAvatar* avatar = gAgent.getAvatarObject();
LLAPRFile outfile ; LLAPRFile outfile(gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER, "new archetype.xml"), LL_APR_WB);
outfile.open(gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"new archetype.xml"), LL_APR_WB, LLAPRFile::global);
apr_file_t* file = outfile.getFileHandle() ; apr_file_t* file = outfile.getFileHandle() ;
if( !file ) if( !file )
{ {

View File

@@ -287,8 +287,6 @@ LLVOCache::~LLVOCache()
void LLVOCache::setDirNames(ELLPath location) void LLVOCache::setDirNames(ELLPath location)
{ {
std::string delem = gDirUtilp->getDirDelimiter();
mHeaderFileName = gDirUtilp->getExpandedFilename(location, object_cache_dirname, header_filename); mHeaderFileName = gDirUtilp->getExpandedFilename(location, object_cache_dirname, header_filename);
mObjectCacheDirName = gDirUtilp->getExpandedFilename(location, object_cache_dirname); mObjectCacheDirName = gDirUtilp->getExpandedFilename(location, object_cache_dirname);
} }
@@ -460,7 +458,7 @@ void LLVOCache::readCacheHeader()
bool success = true ; bool success = true ;
if (LLAPRFile::isExist(mHeaderFileName)) if (LLAPRFile::isExist(mHeaderFileName))
{ {
LLAPRFile apr_file(mHeaderFileName, APR_READ|APR_BINARY, LLAPRFile::local); LLAPRFile apr_file(mHeaderFileName, APR_READ|APR_BINARY);
//read the meta element //read the meta element
success = check_read(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ; success = check_read(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ;
@@ -545,7 +543,7 @@ void LLVOCache::writeCacheHeader()
bool success = true ; bool success = true ;
{ {
LLAPRFile apr_file(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY, LLAPRFile::local); LLAPRFile apr_file(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY);
//write the meta element //write the meta element
success = check_write(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ; success = check_write(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ;
@@ -583,7 +581,7 @@ void LLVOCache::writeCacheHeader()
BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry) BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry)
{ {
LLAPRFile apr_file(mHeaderFileName, APR_WRITE|APR_BINARY, LLAPRFile::local); LLAPRFile apr_file(mHeaderFileName, APR_WRITE|APR_BINARY);
apr_file.seek(APR_SET, entry->mIndex * sizeof(HeaderEntryInfo) + sizeof(HeaderMetaInfo)) ; apr_file.seek(APR_SET, entry->mIndex * sizeof(HeaderEntryInfo) + sizeof(HeaderMetaInfo)) ;
return check_write(&apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ; return check_write(&apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ;
@@ -609,7 +607,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
{ {
std::string filename; std::string filename;
getObjectCacheFilename(handle, filename); getObjectCacheFilename(handle, filename);
LLAPRFile apr_file(filename, APR_READ|APR_BINARY, LLAPRFile::local); LLAPRFile apr_file(filename, APR_READ|APR_BINARY);
LLUUID cache_id ; LLUUID cache_id ;
success = check_read(&apr_file, cache_id.mData, UUID_BYTES) ; success = check_read(&apr_file, cache_id.mData, UUID_BYTES) ;
@@ -728,7 +726,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
{ {
std::string filename; std::string filename;
getObjectCacheFilename(handle, filename); getObjectCacheFilename(handle, filename);
LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY, LLAPRFile::local); LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY);
success = check_write(&apr_file, (void*)id.mData, UUID_BYTES) ; success = check_write(&apr_file, (void*)id.mData, UUID_BYTES) ;