summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llappearance/lltexlayer.cpp1
-rw-r--r--indra/llaudio/llaudiodecodemgr.cpp14
-rw-r--r--indra/llaudio/llaudioengine.cpp4
-rw-r--r--indra/llcharacter/llkeyframemotion.cpp6
-rw-r--r--indra/llfilesystem/CMakeLists.txt3
-rw-r--r--indra/llfilesystem/lldiskcache.cpp773
-rw-r--r--indra/llfilesystem/lldiskcache.h130
-rw-r--r--indra/llfilesystem/llfilesystem.cpp79
-rw-r--r--indra/llfilesystem/llfilesystem.h19
-rw-r--r--indra/llmessage/llassetstorage.cpp28
-rw-r--r--indra/llmessage/llcorehttputil.cpp4
-rw-r--r--indra/llmessage/lltransfersourceasset.cpp6
-rw-r--r--indra/llmessage/lltransfersourceasset.h2
-rw-r--r--indra/llmessage/lltransfertargetvfile.cpp8
-rw-r--r--indra/llmessage/lltransfertargetvfile.h4
-rw-r--r--indra/llmessage/llxfer_vfile.cpp22
-rw-r--r--indra/llmessage/llxfer_vfile.h4
-rw-r--r--indra/llui/llviewereventrecorder.h1
-rw-r--r--indra/newview/llappviewer.cpp6
-rw-r--r--indra/newview/llcompilequeue.cpp2
-rw-r--r--indra/newview/llfloaterauction.cpp6
-rw-r--r--indra/newview/llfloaterbvhpreview.cpp4
-rw-r--r--indra/newview/llfloatermodelpreview.cpp2
-rw-r--r--indra/newview/llfloaterregioninfo.cpp4
-rw-r--r--indra/newview/llfloaterreporter.cpp4
-rw-r--r--indra/newview/llfloatertos.cpp2
-rw-r--r--indra/newview/llgesturemgr.cpp4
-rw-r--r--indra/newview/lllandmarklist.cpp4
-rw-r--r--indra/newview/llmeshrepository.cpp22
-rw-r--r--indra/newview/lloutfitgallery.cpp2
-rw-r--r--indra/newview/llpostcard.cpp2
-rw-r--r--indra/newview/llpreviewgesture.cpp6
-rw-r--r--indra/newview/llpreviewnotecard.cpp10
-rw-r--r--indra/newview/llpreviewscript.cpp6
-rw-r--r--indra/newview/llsettingsvo.cpp4
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp4
-rw-r--r--indra/newview/llviewerassetstorage.cpp12
-rw-r--r--indra/newview/llviewerassetstorage.h2
-rw-r--r--indra/newview/llviewerassetupload.cpp8
-rw-r--r--indra/newview/llviewermenufile.cpp1
-rw-r--r--indra/newview/llviewermessage.cpp4
-rw-r--r--indra/newview/llviewerstats.cpp1
-rw-r--r--indra/newview/llviewertexlayer.cpp1
-rw-r--r--indra/newview/llviewertexture.cpp1
-rw-r--r--indra/newview/llviewertexture.h2
-rw-r--r--indra/newview/llviewertexturelist.cpp2
46 files changed, 1068 insertions, 168 deletions
diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp
index 7360c1acd7..1348fb0763 100644
--- a/indra/llappearance/lltexlayer.cpp
+++ b/indra/llappearance/lltexlayer.cpp
@@ -33,7 +33,6 @@
#include "llimagej2c.h"
#include "llimagetga.h"
#include "lldir.h"
-#include "lldiskcache.h"
#include "lltexlayerparams.h"
#include "lltexturemanagerbridge.h"
#include "lllocaltextureobject.h"
diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index fcffea42a4..ff0aa6e76e 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -29,7 +29,7 @@
#include "llaudioengine.h"
#include "lllfsthread.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llstring.h"
#include "lldir.h"
#include "llendianswizzle.h"
@@ -93,14 +93,14 @@ protected:
std::string mOutFilename;
LLLFSThread::handle_t mFileHandle;
- LLDiskCache *mInFilep;
+ LLFileSystem *mInFilep;
OggVorbis_File mVF;
S32 mCurrentSection;
};
size_t cache_read(void *ptr, size_t size, size_t nmemb, void *datasource)
{
- LLDiskCache *file = (LLDiskCache *)datasource;
+ LLFileSystem *file = (LLFileSystem *)datasource;
if (file->read((U8*)ptr, (S32)(size * nmemb))) /*Flawfinder: ignore*/
{
@@ -115,7 +115,7 @@ size_t cache_read(void *ptr, size_t size, size_t nmemb, void *datasource)
S32 cache_seek(void *datasource, ogg_int64_t offset, S32 whence)
{
- LLDiskCache *file = (LLDiskCache *)datasource;
+ LLFileSystem *file = (LLFileSystem *)datasource;
// cache has 31-bit files
if (offset > S32_MAX)
@@ -151,14 +151,14 @@ S32 cache_seek(void *datasource, ogg_int64_t offset, S32 whence)
S32 cache_close (void *datasource)
{
- LLDiskCache *file = (LLDiskCache *)datasource;
+ LLFileSystem *file = (LLFileSystem *)datasource;
delete file;
return 0;
}
long cache_tell (void *datasource)
{
- LLDiskCache *file = (LLDiskCache *)datasource;
+ LLFileSystem *file = (LLFileSystem *)datasource;
return file->tell();
}
@@ -198,7 +198,7 @@ BOOL LLVorbisDecodeState::initDecode()
LL_DEBUGS("AudioEngine") << "Initing decode from vfile: " << mUUID << LL_ENDL;
- mInFilep = new LLDiskCache(mUUID, LLAssetType::AT_SOUND);
+ mInFilep = new LLFileSystem(mUUID, LLAssetType::AT_SOUND);
if (!mInFilep || !mInFilep->getSize())
{
LL_WARNS("AudioEngine") << "unable to open vorbis source vfile for reading" << LL_ENDL;
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index 9dd752f492..d35f249973 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -35,7 +35,7 @@
#include "sound_ids.h" // temporary hack for min/max distances
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "lldir.h"
#include "llaudiodecodemgr.h"
#include "llassetstorage.h"
@@ -1015,7 +1015,7 @@ bool LLAudioEngine::hasDecodedFile(const LLUUID &uuid)
bool LLAudioEngine::hasLocalFile(const LLUUID &uuid)
{
// See if it's in the cache.
- bool have_local = LLDiskCache::getExists(uuid, LLAssetType::AT_SOUND);
+ bool have_local = LLFileSystem::getExists(uuid, LLAssetType::AT_SOUND);
LL_DEBUGS("AudioEngine") << "sound uuid " << uuid << " exists in cache" << LL_ENDL;
return have_local;
}
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index d1ac336fc1..fe9de30f0a 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -39,9 +39,9 @@
#include "llendianswizzle.h"
#include "llkeyframemotion.h"
#include "llquantize.h"
-#include "lldiskcache.h"
#include "m3math.h"
#include "message.h"
+#include "llfilesystem.h"
//-----------------------------------------------------------------------------
// Static Definitions
@@ -559,7 +559,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact
S32 anim_file_size;
BOOL success = FALSE;
- LLDiskCache* anim_file = new LLDiskCache(mID, LLAssetType::AT_ANIMATION);
+ LLFileSystem* anim_file = new LLFileSystem(mID, LLAssetType::AT_ANIMATION);
if (!anim_file || !anim_file->getSize())
{
delete anim_file;
@@ -2324,7 +2324,7 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid,
// asset already loaded
return;
}
- LLDiskCache file(asset_uuid, type, LLDiskCache::READ);
+ LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 size = file.getSize();
U8* buffer = new U8[size];
diff --git a/indra/llfilesystem/CMakeLists.txt b/indra/llfilesystem/CMakeLists.txt
index 306b483097..d1dece5bba 100644
--- a/indra/llfilesystem/CMakeLists.txt
+++ b/indra/llfilesystem/CMakeLists.txt
@@ -18,16 +18,17 @@ set(llfilesystem_SOURCE_FILES
lldiriterator.cpp
lllfsthread.cpp
lldiskcache.cpp
+ llfilesystem.cpp
)
set(llfilesystem_HEADER_FILES
CMakeLists.txt
-
lldir.h
lldirguard.h
lldiriterator.h
lllfsthread.h
lldiskcache.h
+ llfilesystem.h
)
if (DARWIN)
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp
new file mode 100644
index 0000000000..72982db069
--- /dev/null
+++ b/indra/llfilesystem/lldiskcache.cpp
@@ -0,0 +1,773 @@
+/**
+ * @file lldiskcache.cpp
+ * @brief The SQLite based disk cache implementation.
+ * @Note Eventually, this component might split into an interface
+ * file and multiple implemtations but for now, this is the
+ * only one so I think it's okay to combine everything.
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2020, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#if (defined(LL_WINDOWS) || defined(LL_LINUX) || defined(LL_DARWIN))
+#include "linden_common.h"
+#endif
+
+#include "lldiskcache.h"
+
+#include <string>
+#include <sstream>
+#include <random>
+#include <algorithm>
+#include <fstream>
+
+///////////////////////////////////////////////////////////////////////////////
+//
+llDiskCache::llDiskCache() :
+ mDataStorePath("")
+{
+}
+
+llDiskCache::~llDiskCache()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Opens the database - typically done when the application starts
+// and is complementary to close() which is called when the application
+// is finisahed and exits.
+// Pass in the folder and filename of the SQLite database you want to
+// use or create (file doesn't have to exist but the folder must)
+// Returns true or false and writes a message to console on error
+bool llDiskCache::open(const std::string db_folder, const std::string db_filename)
+{
+ mDataStorePath = db_folder;
+ std::string db_pathname = makeFullPath(db_filename);
+
+ // simple flags for the moment - these will likely be extended
+ // later on to support the SQLite mutex model for reading/writing
+ // simultaneously - perhaps when we look at supporting textures too
+ int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
+
+ if (sqlite3_open_v2(
+ db_pathname.c_str(),
+ &mDb,
+ flags,
+ nullptr // Name of VFS module to use
+ ) != SQLITE_OK)
+ {
+ printError(__FUNCDNAME__ , "open_v2", true);
+ close();
+ return false;
+ }
+
+ // I elected to store the code that generates the statement
+ // in sepsrate functions throughout - this seemed like a cleaner
+ // approach than having hundreds of stmt << "REPLACE AS" lines
+ // interspersed in the logic code. They are all prefixed with
+ // 'sqlCompose' and followed by a short description.
+ const std::string stmt = sqlComposeCreateTable();
+ if (! sqliteExec(stmt, __FUNCDNAME__ ))
+ {
+ // Not sure if we need close here - if open fails, then we
+ // perhaps don't need to close it - TODO: look in SQLite docs
+ close();
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Determines if an entry exists.
+// Pass in the id and a variable that will indicate existance
+// Returns true/false if function succeeded and the boolean
+// you pass in will be set to true/false if entry exists or not
+bool llDiskCache::exists(const std::string id, bool& exists)
+{
+ if (!mDb)
+ {
+ printError(__FUNCDNAME__ , "mDb is invalid", false);
+ return false;
+ }
+
+ if (id.empty())
+ {
+ printError(__FUNCDNAME__ , "id is empty", false);
+ return false;
+ }
+
+ // As well as the separate function to compose the SQL statement,
+ // worth pointing out that the code to 'prepare' and 'step' the
+ // SQLite "prepared statement" has been factored out into its own
+ // function and used in several other functions.
+ const std::string stmt = sqlComposeExists(id);
+ sqlite3_stmt* prepared_statement = sqlitePrepareStep(__FUNCDNAME__ , stmt, SQLITE_ROW);
+ if (! prepared_statement)
+ {
+ return false;
+ }
+
+ int result_column_index = 0;
+ int result_count = sqlite3_column_int(prepared_statement, result_column_index);
+ if (sqlite3_finalize(prepared_statement) != SQLITE_OK)
+ {
+ printError(__FUNCDNAME__ , "sqlite3_finalize()", true);
+ return false;
+ }
+
+ // given the uniqueness of the ID, this can only ever be
+ // either 1 or 0 so this might be a bit confusing
+ exists = result_count > 0 ? true : false;
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Given an id (likely a UUID + decoration but can be any string), a
+// pointer to a blob of binary data along with its length, write the
+// entry to the cache
+// Returns true/false for success/failure
+bool llDiskCache::put(const std::string id,
+ char* binary_data,
+ int binary_data_size)
+{
+ if (!mDb)
+ {
+ printError(__FUNCDNAME__ , "mDb is invalid", false);
+ return false;
+ }
+
+ if (id.empty())
+ {
+ printError(__FUNCDNAME__ , "id is empty", false);
+ return false;
+ }
+
+ // < 0 is obvious but we assert the data must be at least 1 byte long
+ if (binary_data_size <= 0)
+ {
+ printError(__FUNCDNAME__ , "size of binary file to write is invalid", false);
+ return false;
+ }
+
+ // we generate a unique filename for the actual data itself
+ // which is stored on disk directly and not in the database.
+ // TODO: consider making the filename more like the ID passed in
+ // although the problem with that is we would have to parse the id
+ // to remove invalid filename chars, consider length etc. As it
+ // stands, we can write a simple SQL statement to return the filename
+ // given the ID.
+ const std::string filename = makeUniqueFilename();
+ const std::string filepath = makeFullPath(filename);
+ std::ofstream file(filepath, std::ios::out | std::ios::binary);
+ if (! file.is_open())
+ {
+ std::ostringstream error;
+ error << "Unable to open " << filepath << " for writing";
+ printError(__FUNCDNAME__ , error.str(), false);
+ return false;
+ }
+
+ file.write((char*)binary_data, binary_data_size);
+ file.close();
+
+ // I think is a catchall "wasn't able to write the file to disk"
+ // conditional but should revisit when we hook this up to viewer
+ // code to make sure - we never want to write bad/no data to the
+ // disk and not indicate something has gone wrong
+ if (file.bad())
+ {
+ std::ostringstream error;
+ error << "Unable to write " << binary_data_size;
+ error << " bytes to " << filepath;
+ printError(__FUNCDNAME__ , error.str(), false);
+
+ return false;
+ }
+
+ // this is where the filename/size is written to the database along
+ // with the current date/time for the created/last access times
+ const std::string stmt = sqlComposePut(id, filename, binary_data_size);
+ if (! sqlitePrepareStep(__FUNCDNAME__ , stmt, SQLITE_DONE))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Given an id (likely a UUID + decoration but can be any string), the
+// address of a pointer that will be used to allocate memory and a
+// varialble that will contain the length of the data, get an item from
+// the cache. Note that the memory buffer returned belongs to the calling
+// function and it is its responsiblity to clean it up when it's no
+// longer needed.
+// Returns true/false for success/failure
+const bool llDiskCache::get(const std::string id,
+ char** mem_buffer,
+ int& mem_buffer_size)
+{
+ // Check if the entry exists first to avoid dealing with a bunch
+ // of conditions that look like failure but aren't in the main code.
+ // Note exists() is a public method and also tests for mDB and id
+ // being valid so we can safely put this about the same tests
+ // in this function
+ bool get_exists = false;
+ if (! exists(id, get_exists))
+ {
+ return false;
+ }
+ if (! get_exists)
+ {
+ return false;
+ }
+
+ if (!mDb)
+ {
+ printError(__FUNCDNAME__ , "mDb is invalid", false);
+ return false;
+ }
+
+ if (id.empty())
+ {
+ printError(__FUNCDNAME__ , "id is empty", false);
+ return false;
+ }
+
+ const std::string stmt_select = sqlComposeGetSelect(id);
+ sqlite3_stmt* prepared_statement = sqlitePrepareStep(__FUNCDNAME__ , stmt_select, SQLITE_ROW);
+ if (! prepared_statement)
+ {
+ return false;
+ }
+
+ int result_column_index = 0;
+ const unsigned char* text = sqlite3_column_text(prepared_statement, result_column_index);
+ if (text == nullptr)
+ {
+ printError(__FUNCDNAME__ , "filename is nullptr", true);
+ return false;
+ }
+ const std::string filename = std::string(reinterpret_cast<const char*>(text));
+ const std::string filepath = makeFullPath(filename);
+
+ result_column_index = 1;
+ int filesize_db = sqlite3_column_int(prepared_statement, result_column_index);
+ if (filesize_db <= 0)
+ {
+ printError(__FUNCDNAME__ , "filesize is invalid", true);
+ return false;
+ }
+
+ if (sqlite3_finalize(prepared_statement) != SQLITE_OK)
+ {
+ printError(__FUNCDNAME__ , "sqlite3_finalize()", true);
+ return false;
+ }
+
+ // Now we have the fiename, we can read the file from disk
+ std::ifstream file(filepath, std::ios::in | std::ios::binary | std::ios::ate);
+ if (! file.is_open())
+ {
+ std::ostringstream error;
+ error << "Unable to open " << filepath << " for reading";
+ printError(__FUNCDNAME__ , error.str(), false);
+ return false;
+ }
+
+ // we get the expected filesize from the database but we can also
+ // get it (easily) when we read the file from the disk. We compare
+ // the two and return false if they don't match
+ std::streampos filesize_file = file.tellg();
+ if (filesize_db != filesize_file)
+ {
+ std::ostringstream error;
+ error << "File size from DB (" << filesize_db << ")";
+ error << " and ";
+ error << "file size from file (" << filesize_file << ")";
+ error << " in file " << filepath << " are different";
+ printError(__FUNCDNAME__ , error.str(), false);
+
+ return false;
+ }
+
+ // doest matter if we choose DB or file version - they must be
+ // identical if we get this far - just used for clarity
+ int filesize = filesize_db;
+
+ // allocate a block of memory that we pass back for the calling
+ // function to use then delete when it's no longer needed
+ *mem_buffer = new char[filesize];
+ mem_buffer_size = filesize;
+
+ file.seekg(0, std::ios::beg);
+ file.read(*mem_buffer, filesize);
+ file.close();
+
+ if (file.bad())
+ {
+ std::ostringstream error;
+ error << "Unable to read " << filesize;
+ error << " bytes from " << filepath;
+ printError(__FUNCDNAME__ , error.str(), false);
+
+ return false;
+ }
+
+ // here we update the count of times the file is accessed so
+ // we can keep track of how many times it's been requested.
+ // This will be useful for metrics and perhaps determining
+ // if a file should not be purged even though its age
+ // might suggest that it should.
+ // In addition, this is where the time of last access is updated
+ // in the database and that us used to determine what is purged
+ // in an LRU fashion when the purge function is called.
+ const std::string stmt_update = sqlComposeGetUpdate(id);
+ if (! sqliteExec(stmt_update, __FUNCDNAME__ ))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Purges the database of older entries using an LRU approach.
+// Pass in the number of entries to retain.
+// This is called now after open to "clean up" the cache when the
+// application starts.
+// TODO: IMPORTANT: compose a list of files that will be deleted
+// and delete them from disk too - not just from the DB
+bool llDiskCache::purge(int num_entries)
+{
+ if (num_entries < 0)
+ {
+ printError(__FUNCDNAME__ , "number of entries to purge is invalid", false);
+ return false;
+ }
+
+ // find the rows affected and get the filenames for them
+//swww
+
+ // delete oldest entries leaving the correct number in place
+ const std::string stmt = sqlComposePurge(num_entries);
+ if (! sqliteExec(stmt, __FUNCDNAME__ ))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Call at application shutdown
+void llDiskCache::close()
+{
+ sqlite3_close(mDb);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Determine the version of SQLite in use
+// TODO: make this a static so we can get to it from the Viewer About
+// box without instantiating the whole thing.
+const std::string llDiskCache::dbVersion()
+{
+ std::ostringstream version;
+
+ version << sqlite3_libversion();
+
+ return version.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Given an id, return the matching filename
+const std::string llDiskCache::getFilenameById(const std::string id)
+{
+ // TODO:
+ return std::string();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Given an id, return the number of times that entry has been
+// accessed from the cache
+const int llDiskCache::getAccessCountById(const std::string id)
+{
+ // TODO:
+ return -1;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Return the number of entries currently in the cache as well as
+// the maximum possible entries.
+void llDiskCache::getNumEntries(int& num_entries, int& max_entries)
+{
+ num_entries = -1;
+ max_entries = -1;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Wraps the sqlite3_exec(..) used in many places
+bool llDiskCache::sqliteExec(const std::string stmt,
+ const std::string funcname)
+{
+ if (sqlite3_exec(
+ mDb,
+ stmt.c_str(),
+ nullptr, // Callback function (unused)
+ nullptr, // 1st argument to callback (unused)
+ nullptr // Error msg written here (unused)
+ ) != SQLITE_OK)
+ {
+ printError(funcname, "sqlite3_exec", true);
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Wraps the sqlite3_prepare_v2 and sqlite3_step calls used in many places
+sqlite3_stmt* llDiskCache::sqlitePrepareStep(const std::string funcname,
+ const std::string stmt,
+ int sqlite_success_condition)
+{
+ sqlite3_stmt* prepared_statement;
+
+ if (sqlite3_prepare_v2(
+ mDb,
+ stmt.c_str(),
+ -1, // Maximum length of zSql in bytes.
+ &prepared_statement,
+ 0 // OUT: Pointer to unused portion of zSql
+ ) != SQLITE_OK)
+ {
+ printError(funcname, "sqlite3_prepare_v2", true);
+ return nullptr;
+ }
+
+ if (sqlite3_step(prepared_statement) != sqlite_success_condition)
+ {
+ printError(funcname, "sqlite3_step", true);
+ sqlite3_finalize(prepared_statement);
+ return nullptr;
+ }
+ return prepared_statement;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// When an "error" occurss - e.g. database cannot be found, file cannot be
+// written, invalid argument passed into a function etc. a message is
+// written to stderr that should end up in the viewer log
+// TODO: Set the verbosity using the usual Viewer mechanism
+void llDiskCache::printError(const std::string funcname,
+ const std::string desc,
+ bool is_sqlite_err)
+{
+ std::ostringstream err_msg;
+
+ err_msg << "llDiskCache error in ";
+ err_msg << __FUNCDNAME__ << "(...) ";
+ err_msg << desc;
+
+ if (is_sqlite_err)
+ {
+ err_msg << " - ";
+ err_msg << std::string(sqlite3_errmsg(mDb));
+ }
+
+ // TODO: set via viewer verbosity level
+ const int verbosity = 1;
+ if (verbosity > 0)
+ {
+ std::cerr << err_msg.str() << std::endl;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// wrapper for SQLite code to begin an SQL transaction - not used yet but
+// it will be eventually
+bool llDiskCache::beginTransaction()
+{
+ const std::string stmt("BEGIN TRANSACTION");
+ if (! sqliteExec(stmt, __FUNCDNAME__ ))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// wrapper for SQLite code to end an SQL transaction - not used yet but
+// it will be eventually
+bool llDiskCache::endTransaction()
+{
+ const std::string stmt("COMMIT");
+ if (! sqliteExec(stmt, __FUNCDNAME__ ))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Build a unique filename that will be used to store the actual file
+// on disk (as opposed to the meta data in the database)
+// TODO: I think this needs more work once we move it to the viewer
+// and espcially to make it cross platform - see 'std::tmpnam'
+// depreciation comments in compiler output for example
+std::string llDiskCache::makeUniqueFilename()
+{
+ // TODO: replace with boost - this is marked as deprecated?
+ std::string base = std::tmpnam(nullptr);
+
+ // C++11 random number generation!!!
+ static std::random_device dev;
+ static std::mt19937 rng(dev());
+ std::uniform_int_distribution<int> dist(100000, 999999);
+
+ // currently the tmp filename from std::tmpnam() on macOS
+ // is of the form `/tmp/foo/bar.12345 and the following code
+ // strips all the preceding dirs - we likely want a more
+ // robust (and cross platform solution) when we move to the
+ // viewer code
+ std::size_t found = base.rfind(systemSeparator());
+ if (found != std::string::npos && found < base.size() - 2)
+ {
+ base = base.substr(found + 1);
+ }
+ else
+ {
+ base = "";
+ }
+
+ // we mix in a random number for some more entropy..
+ // (i know, i know...)
+ std::ostringstream unique_filename;
+ unique_filename << base;
+ unique_filename << ".";
+ unique_filename << dist(rng);
+
+ return unique_filename.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Return system file/path separator - likely replaced by the version
+// in the viewer
+const std::string llDiskCache::systemSeparator()
+{
+// TODO: replace in viewer with relevant call
+#ifdef _WIN32
+ return "\\";
+#else
+ return "/";
+#endif
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Given a filename, compose a full path based on the path name passed
+// in when the database was opened and the separator in play.
+const std::string llDiskCache::makeFullPath(const std::string filename)
+{
+ std::string pathname = mDataStorePath + systemSeparator() + filename;
+
+ return pathname;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+const std::string llDiskCache::sqlComposeCreateTable()
+{
+ std::ostringstream stmt;
+ stmt << "CREATE TABLE IF NOT EXISTS ";
+ stmt << mTableName;
+ stmt << "(";
+ stmt << mIdFieldName;
+ stmt << " TEXT PRIMARY KEY, ";
+ stmt << mFilenameFieldName;
+ stmt << " TEXT, ";
+ stmt << mFilesizeFieldName;
+ stmt << " INTEGER DEFAULT 0, ";
+ stmt << mInsertionDateTimeFieldName;
+ stmt << " TEXT, ";
+ stmt << mLastAccessDateTimeFieldName;
+ stmt << " TEXT, ";
+ stmt << mAccessCountFieldName;
+ stmt << " INTEGER DEFAULT 0";
+ stmt << ")";
+
+#ifdef SHOW_STATEMENTS
+ std::cout << stmt.str() << std::endl;
+#endif
+
+ return stmt.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+const std::string llDiskCache::sqlComposeExists(const std::string id)
+{
+ std::ostringstream stmt;
+ stmt << "SELECT COUNT(*) FROM ";
+ stmt << mTableName;
+ stmt << " WHERE ";
+ stmt << mIdFieldName;
+ stmt << "='";
+ stmt << id;
+ stmt << "'";
+
+#ifdef SHOW_STATEMENTS
+ std::cout << stmt.str() << std::endl;
+#endif
+
+ return stmt.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// SQL statement to write an entry to the DB
+// Saves id, filename (generated), file size and create/last access date
+const std::string llDiskCache::sqlComposePut(const std::string id,
+ const std::string filename,
+ int binary_data_size)
+{
+ std::ostringstream stmt;
+ stmt << "REPLACE INTO ";
+ stmt << mTableName;
+ stmt << "(";
+ stmt << mIdFieldName;
+ stmt << ",";
+ stmt << mFilenameFieldName;
+ stmt << ",";
+ stmt << mFilesizeFieldName;
+ stmt << ",";
+ stmt << mInsertionDateTimeFieldName;
+ stmt << ",";
+ stmt << mLastAccessDateTimeFieldName;
+ stmt << ") ";
+ stmt << "VALUES(";
+ stmt << "'";
+ stmt << id;
+ stmt << "', ";
+ stmt << "'";
+ stmt << filename;
+ stmt << "', ";
+ stmt << binary_data_size;
+ stmt << ", ";
+ stmt << "strftime('%Y-%m-%d %H:%M:%f', 'now')";
+ stmt << ", ";
+ stmt << "strftime('%Y-%m-%d %H:%M:%f', 'now')";
+ stmt << ")";
+
+#ifdef SHOW_STATEMENTS
+ std::cout << stmt.str() << std::endl;
+#endif
+
+ return stmt.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// SQL statement used in get() to look up the filename and file size
+const std::string llDiskCache::sqlComposeGetSelect(const std::string id)
+{
+ std::ostringstream stmt;
+ stmt << "SELECT ";
+ stmt << mFilenameFieldName;
+ stmt << ", ";
+ stmt << mFilesizeFieldName;
+ stmt << " FROM ";
+ stmt << mTableName;
+ stmt << " WHERE ";
+ stmt << mIdFieldName;
+ stmt << "='";
+ stmt << id;
+ stmt << "'";
+
+#ifdef SHOW_STATEMENTS
+ std::cout << stmt.str() << std::endl;
+#endif
+
+ return stmt.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// SQL statement to update the date/time of last access as well as the
+// count of number of times the file has been accessed.
+// Note: the more accurate representation of date/time is used to
+// ensure ms accuracy vs the standard INTEGER days since epoch approach
+const std::string llDiskCache::sqlComposeGetUpdate(const std::string id)
+{
+ std::ostringstream stmt;
+ stmt << "UPDATE ";
+ stmt << mTableName;
+ stmt << " SET ";
+ stmt << mAccessCountFieldName;
+ stmt << "=";
+ stmt << mAccessCountFieldName;
+ stmt << "+1";
+ stmt << ", ";
+ stmt << mLastAccessDateTimeFieldName;
+ stmt << "=";
+ stmt << "strftime('%Y-%m-%d %H:%M:%f', 'now')";
+ stmt << " WHERE ";
+ stmt << mIdFieldName;
+ stmt << "='";
+ stmt << id;
+ stmt << "'";
+
+#ifdef SHOW_STATEMENTS
+ std::cout << stmt.str() << std::endl;
+#endif
+
+ return stmt.str();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// SQL statement to remove items from the database that are older
+// than the newest num_elements entries
+const std::string llDiskCache::sqlComposePurge(int num_entries)
+{
+ std::ostringstream stmt;
+ stmt << "DELETE FROM ";
+ stmt << mTableName;
+ stmt << " WHERE ";
+ stmt << mLastAccessDateTimeFieldName;
+ stmt << " NOT IN ";
+ stmt << "(";
+ stmt << "SELECT ";
+ stmt << mLastAccessDateTimeFieldName;
+ stmt << " FROM ";
+ stmt << mTableName;
+ stmt << " ORDER BY ";
+ stmt << mLastAccessDateTimeFieldName;
+ stmt << " DESC";
+ stmt << " LIMIT ";
+ stmt << num_entries;
+ stmt << ")";
+
+//#ifdef SHOW_STATEMENTS
+ std::cout << stmt.str() << std::endl;
+//#endif
+
+ return stmt.str();
+}
diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h
new file mode 100644
index 0000000000..39b8f7ef48
--- /dev/null
+++ b/indra/llfilesystem/lldiskcache.h
@@ -0,0 +1,130 @@
+/**
+ * @file lldiskcache.h
+ * @brief Declaration SQLite meta data / file storage API
+ * @brief Declaration of the generic disk cache interface
+ as well the SQLite header/implementation.
+ * @Note Eventually, this component might split into an interface
+ * file and multiple implemtations but for now, this is the
+ * only one so I think it's okay to combine everything.
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2020, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef _LLDISKCACHE
+#define _LLDISKCACHE
+
+#include <iostream>
+#include <string>
+
+#include "sqlite3.h"
+
+// Enable this line to display each SQL statement when it is executed
+// It can lead to a lot of spam but useful for debugging
+//#define SHOW_STATEMENTS
+
+// I toyed with the idea of a variety of approaches and thought have
+// an abstract base class with which to hang different implementations
+// off was a good idea but I think we settled on a single approach
+// so I will likely remove this level of indirection if not other
+// interesting implementation ideas present themselves.
+class llDiskCacheBase
+{
+ public:
+ llDiskCacheBase() {};
+ virtual ~llDiskCacheBase() {};
+ virtual bool open(const std::string db_folder,
+ const std::string db_filename) = 0;
+ virtual bool exists(const std::string id, bool& exists) = 0;
+ virtual bool put(const std::string id,
+ char* binary_data,
+ int binary_data_size) = 0;
+ virtual const bool get(const std::string id,
+ char** mem_buffer,
+ int& mem_buffer_size) = 0;
+ virtual bool purge(int num_entries) = 0;
+ virtual void close() = 0;
+ virtual const std::string dbVersion() = 0;
+ virtual const std::string getFilenameById(const std::string id) = 0;
+ virtual const int getAccessCountById(const std::string id) = 0;
+ virtual void getNumEntries(int& num_entries, int& max_entries) = 0;
+};
+
+// implementation for the SQLite/disk blended case
+// see source file for detailed comments
+class llDiskCache :
+ public llDiskCacheBase
+{
+ public:
+ llDiskCache();
+ virtual ~llDiskCache();
+ virtual bool open(const std::string db_folder,
+ const std::string db_filename) override;
+ virtual bool exists(const std::string id, bool& exists) override;
+ virtual bool put(const std::string id,
+ char* binary_data,
+ int binary_data_size) override;
+ virtual const bool get(const std::string id,
+ char** mem_buffer,
+ int& mem_buffer_size) override;
+ virtual bool purge(int num_entries) override;
+ virtual void close() override;
+ virtual const std::string dbVersion() override;
+ virtual const std::string getFilenameById(const std::string id) override;
+ virtual const int getAccessCountById(const std::string id) override;
+ virtual void getNumEntries(int& num_entries, int& max_entries) override;
+
+ private:
+ sqlite3* mDb;
+ std::string mDataStorePath;
+ const std::string mTableName = "lldiskcache";
+ const std::string mIdFieldName = "id";
+ const std::string mFilenameFieldName = "filename";
+ const std::string mFilesizeFieldName = "filesize";
+ const std::string mInsertionDateTimeFieldName = "insert_datetime";
+ const std::string mLastAccessDateTimeFieldName = "last_access_datetime";
+ const std::string mAccessCountFieldName = "access_count";
+
+ private:
+ void printError(const std::string funcname,
+ const std::string desc,
+ bool is_sqlite_err);
+ bool beginTransaction();
+ bool endTransaction();
+ std::string makeUniqueFilename();
+ const std::string systemSeparator();
+ const std::string makeFullPath(const std::string filename);
+ bool sqliteExec(const std::string stmt,
+ const std::string funcname);
+ sqlite3_stmt* sqlitePrepareStep(const std::string funcname,
+ const std::string stmt,
+ int sqlite_success_condition);
+ const std::string sqlComposeCreateTable();
+ const std::string sqlComposeExists(const std::string id);
+ const std::string sqlComposePut(const std::string id,
+ const std::string filename,
+ int binary_data_size);
+ const std::string sqlComposeGetSelect(const std::string id);
+ const std::string sqlComposeGetUpdate(const std::string id);
+ const std::string sqlComposePurge(int num_entries);
+};
+
+#endif // _LLDISKCACHE
diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp
index af93049e07..f0037c9a22 100644
--- a/indra/llfilesystem/llfilesystem.cpp
+++ b/indra/llfilesystem/llfilesystem.cpp
@@ -1,6 +1,9 @@
/**
- * @file lldiskcache.cpp
- * @brief Implementation of virtual file
+ * @file filesystem.h
+ * @brief Simulate local file system operations.
+ * @Note The initial implementation does actually use standard C++
+ * file operations but eventually, there will be another
+ * layer that caches and manages file meta data too.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -26,25 +29,21 @@
#include "linden_common.h"
-#include "lldiskcache.h"
-
-#include "llerror.h"
-#include "llthread.h"
-#include "lltimer.h"
+#include "lldir.h"
+#include "llfilesystem.h"
#include "llfasttimer.h"
-#include "llmemory.h"
+#include "lldiskcache.h"
#include <fstream>
-#include "lldir.h"
-const S32 LLDiskCache::READ = 0x00000001;
-const S32 LLDiskCache::WRITE = 0x00000002;
-const S32 LLDiskCache::READ_WRITE = 0x00000003; // LLDiskCache::READ & LLDiskCache::WRITE
-const S32 LLDiskCache::APPEND = 0x00000006; // 0x00000004 & LLDiskCache::WRITE
+const S32 LLFileSystem::READ = 0x00000001;
+const S32 LLFileSystem::WRITE = 0x00000002;
+const S32 LLFileSystem::READ_WRITE = 0x00000003; // LLFileSystem::READ & LLFileSystem::WRITE
+const S32 LLFileSystem::APPEND = 0x00000006; // 0x00000004 & LLFileSystem::WRITE
static LLTrace::BlockTimerStatHandle FTM_VFILE_WAIT("VFile Wait");
-LLDiskCache::LLDiskCache(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode)
+LLFileSystem::LLFileSystem(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode)
{
mFileType = file_type;
mFileID = file_id;
@@ -54,7 +53,7 @@ LLDiskCache::LLDiskCache(const LLUUID &file_id, const LLAssetType::EType file_ty
mMode = mode;
}
-LLDiskCache::~LLDiskCache()
+LLFileSystem::~LLFileSystem()
{
}
@@ -124,7 +123,7 @@ const std::string idToFilepath(const std::string id, LLAssetType::EType at)
}
// static
-bool LLDiskCache::getExists(const LLUUID &file_id, const LLAssetType::EType file_type)
+bool LLFileSystem::getExists(const LLUUID &file_id, const LLAssetType::EType file_type)
{
std::string id_str;
file_id.toString(id_str);
@@ -140,7 +139,7 @@ bool LLDiskCache::getExists(const LLUUID &file_id, const LLAssetType::EType file
}
// static
-bool LLDiskCache::removeFile(const LLUUID &file_id, const LLAssetType::EType file_type)
+bool LLFileSystem::removeFile(const LLUUID &file_id, const LLAssetType::EType file_type)
{
std::string id_str;
file_id.toString(id_str);
@@ -152,7 +151,7 @@ bool LLDiskCache::removeFile(const LLUUID &file_id, const LLAssetType::EType fil
}
// static
-bool LLDiskCache::renameFile(const LLUUID &old_file_id, const LLAssetType::EType old_file_type,
+bool LLFileSystem::renameFile(const LLUUID &old_file_id, const LLAssetType::EType old_file_type,
const LLUUID &new_file_id, const LLAssetType::EType new_file_type)
{
std::string old_id_str;
@@ -175,7 +174,7 @@ bool LLDiskCache::renameFile(const LLUUID &old_file_id, const LLAssetType::EType
}
// static
-S32 LLDiskCache::getFileSize(const LLUUID &file_id, const LLAssetType::EType file_type)
+S32 LLFileSystem::getFileSize(const LLUUID &file_id, const LLAssetType::EType file_type)
{
std::string id_str;
file_id.toString(id_str);
@@ -192,7 +191,7 @@ S32 LLDiskCache::getFileSize(const LLUUID &file_id, const LLAssetType::EType fil
return file_size;
}
-BOOL LLDiskCache::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
+BOOL LLFileSystem::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
{
BOOL success = TRUE;
@@ -232,7 +231,7 @@ BOOL LLDiskCache::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
return success;
}
-BOOL LLDiskCache::isReadComplete()
+BOOL LLFileSystem::isReadComplete()
{
if (mReadComplete)
{
@@ -242,17 +241,17 @@ BOOL LLDiskCache::isReadComplete()
return FALSE;
}
-S32 LLDiskCache::getLastBytesRead()
+S32 LLFileSystem::getLastBytesRead()
{
return mBytesRead;
}
-BOOL LLDiskCache::eof()
+BOOL LLFileSystem::eof()
{
return mPosition >= getSize();
}
-BOOL LLDiskCache::write(const U8 *buffer, S32 bytes)
+BOOL LLFileSystem::write(const U8 *buffer, S32 bytes)
{
std::string id_str;
mFileID.toString(id_str);
@@ -287,14 +286,14 @@ BOOL LLDiskCache::write(const U8 *buffer, S32 bytes)
}
//static
-BOOL LLDiskCache::writeFile(const U8 *buffer, S32 bytes, const LLUUID &uuid, LLAssetType::EType type)
+BOOL LLFileSystem::writeFile(const U8 *buffer, S32 bytes, const LLUUID &uuid, LLAssetType::EType type)
{
- LLDiskCache file(uuid, type, LLDiskCache::WRITE);
+ LLFileSystem file(uuid, type, LLFileSystem::WRITE);
file.setMaxSize(bytes);
return file.write(buffer, bytes);
}
-BOOL LLDiskCache::seek(S32 offset, S32 origin)
+BOOL LLFileSystem::seek(S32 offset, S32 origin)
{
if (-1 == origin)
{
@@ -324,32 +323,32 @@ BOOL LLDiskCache::seek(S32 offset, S32 origin)
return TRUE;
}
-S32 LLDiskCache::tell() const
+S32 LLFileSystem::tell() const
{
return mPosition;
}
-S32 LLDiskCache::getSize()
+S32 LLFileSystem::getSize()
{
- return LLDiskCache::getFileSize(mFileID, mFileType);
+ return LLFileSystem::getFileSize(mFileID, mFileType);
}
-S32 LLDiskCache::getMaxSize()
+S32 LLFileSystem::getMaxSize()
{
// offer up a huge size since we don't care what the max is
return INT_MAX;
}
-BOOL LLDiskCache::setMaxSize(S32 size)
+BOOL LLFileSystem::setMaxSize(S32 size)
{
// we don't care what the max size is so we do nothing
// and return true to indicate all was okay
return TRUE;
}
-BOOL LLDiskCache::rename(const LLUUID &new_id, const LLAssetType::EType new_type)
+BOOL LLFileSystem::rename(const LLUUID &new_id, const LLAssetType::EType new_type)
{
- LLDiskCache::renameFile(mFileID, mFileType, new_id, new_type);
+ LLFileSystem::renameFile(mFileID, mFileType, new_id, new_type);
mFileID = new_id;
mFileType = new_type;
@@ -357,31 +356,31 @@ BOOL LLDiskCache::rename(const LLUUID &new_id, const LLAssetType::EType new_type
return TRUE;
}
-BOOL LLDiskCache::remove()
+BOOL LLFileSystem::remove()
{
- LLDiskCache::removeFile(mFileID, mFileType);
+ LLFileSystem::removeFile(mFileID, mFileType);
return TRUE;
}
// static
-void LLDiskCache::initClass()
+void LLFileSystem::initClass()
{
}
// static
-void LLDiskCache::cleanupClass()
+void LLFileSystem::cleanupClass()
{
}
-bool LLDiskCache::isLocked()
+bool LLFileSystem::isLocked()
{
// I don't think we care about this test since there is no locking
// TODO: remove this function and calling sites?
return FALSE;
}
-void LLDiskCache::waitForLock()
+void LLFileSystem::waitForLock()
{
// TODO: remove this function and calling sites?
}
diff --git a/indra/llfilesystem/llfilesystem.h b/indra/llfilesystem/llfilesystem.h
index 7ad06a8689..9cddef74a7 100644
--- a/indra/llfilesystem/llfilesystem.h
+++ b/indra/llfilesystem/llfilesystem.h
@@ -1,6 +1,9 @@
/**
- * @file lldiskcacke.h
- * @brief Definition of virtual file
+ * @file filesystem.h
+ * @brief Simulate local file system operations.
+ * @Note The initial implementation does actually use standard C++
+ * file operations but eventually, there will be another
+ * layer that caches and manages file meta data too.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -24,17 +27,17 @@
* $/LicenseInfo$
*/
-#ifndef LL_LLDISKCACHE_H
-#define LL_LLDISKCACHE_H
+#ifndef LL_FILESYSTEM_H
+#define LL_FILESYSTEM_H
#include "lluuid.h"
#include "llassettype.h"
-class LLDiskCache
+class LLFileSystem
{
public:
- LLDiskCache(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLDiskCache::READ);
- ~LLDiskCache();
+ LLFileSystem(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLFileSystem::READ);
+ ~LLFileSystem();
BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */
BOOL isReadComplete();
@@ -79,4 +82,4 @@ protected:
S32 mBytesRead;
};
-#endif // LL_LLDISKCACHE_H
+#endif // LL_FILESYSTEM_H
diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp
index 31c1edd75e..f38a5e663e 100644
--- a/indra/llmessage/llassetstorage.cpp
+++ b/indra/llmessage/llassetstorage.cpp
@@ -42,7 +42,7 @@
// this library includes
#include "message.h"
#include "llxfermanager.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "lldbstrings.h"
#include "lltransfersourceasset.h"
@@ -438,7 +438,7 @@ void LLAssetStorage::_cleanupRequests(BOOL all, S32 error)
BOOL LLAssetStorage::hasLocalAsset(const LLUUID &uuid, const LLAssetType::EType type)
{
- return LLDiskCache::getExists(uuid, type);
+ return LLFileSystem::getExists(uuid, type);
}
bool LLAssetStorage::findInCacheAndInvokeCallback(const LLUUID& uuid, LLAssetType::EType type,
@@ -450,10 +450,10 @@ bool LLAssetStorage::findInCacheAndInvokeCallback(const LLUUID& uuid, LLAssetTyp
llassert(callback != NULL);
}
- BOOL exists = LLDiskCache::getExists(uuid, type);
+ BOOL exists = LLFileSystem::getExists(uuid, type);
if (exists)
{
- LLDiskCache file(uuid, type);
+ LLFileSystem file(uuid, type);
U32 size = file.getSize();
if (size > 0)
{
@@ -523,8 +523,8 @@ void LLAssetStorage::getAssetData(const LLUUID uuid,
return;
}
- BOOL exists = LLDiskCache::getExists(uuid, type);
- LLDiskCache file(uuid, type);
+ BOOL exists = LLFileSystem::getExists(uuid, type);
+ LLFileSystem file(uuid, type);
U32 size = exists ? file.getSize() : 0;
if (size > 0)
@@ -664,7 +664,7 @@ void LLAssetStorage::downloadCompleteCallback(
if (LL_ERR_NOERR == result)
{
// we might have gotten a zero-size file
- LLDiskCache vfile(callback_id, callback_type);
+ LLFileSystem vfile(callback_id, callback_type);
if (vfile.getSize() <= 0)
{
LL_WARNS("AssetStorage") << "downloadCompleteCallback has non-existent or zero-size asset " << callback_id << LL_ENDL;
@@ -724,8 +724,8 @@ void LLAssetStorage::getEstateAsset(
return;
}
- BOOL exists = LLDiskCache::getExists(asset_id, atype);
- LLDiskCache file(asset_id, atype);
+ BOOL exists = LLFileSystem::getExists(asset_id, atype);
+ LLFileSystem file(asset_id, atype);
U32 size = exists ? file.getSize() : 0;
if (size > 0)
@@ -818,7 +818,7 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback(
if (LL_ERR_NOERR == result)
{
// we might have gotten a zero-size file
- LLDiskCache vfile(req->getUUID(), req->getAType());
+ LLFileSystem vfile(req->getUUID(), req->getAType());
if (vfile.getSize() <= 0)
{
LL_WARNS("AssetStorage") << "downloadCompleteCallback has non-existent or zero-size asset!" << LL_ENDL;
@@ -860,8 +860,8 @@ void LLAssetStorage::getInvItemAsset(
return;
}
- exists = LLDiskCache::getExists(asset_id, atype);
- LLDiskCache file(asset_id, atype);
+ exists = LLFileSystem::getExists(asset_id, atype);
+ LLFileSystem file(asset_id, atype);
size = exists ? file.getSize() : 0;
if(exists && size < 1)
{
@@ -961,7 +961,7 @@ void LLAssetStorage::downloadInvItemCompleteCallback(
if (LL_ERR_NOERR == result)
{
// we might have gotten a zero-size file
- LLDiskCache vfile(req->getUUID(), req->getType());
+ LLFileSystem vfile(req->getUUID(), req->getType());
if (vfile.getSize() <= 0)
{
LL_WARNS("AssetStorage") << "downloadCompleteCallback has non-existent or zero-size asset!" << LL_ENDL;
@@ -1396,7 +1396,7 @@ void LLAssetStorage::legacyGetDataCallback(const LLUUID &uuid,
if ( !status
&& !toxic )
{
- LLDiskCache file(uuid, type);
+ LLFileSystem file(uuid, type);
std::string uuid_str;
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index 376558400c..7031f1aa8c 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -37,7 +37,7 @@
#include "llsdserialize.h"
#include "reader.h" // JSON
#include "writer.h" // JSON
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "message.h" // for getting the port
@@ -784,7 +784,7 @@ LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request
// scoping for our streams so that they go away when we no longer need them.
{
LLCore::BufferArrayStream outs(fileData.get());
- LLDiskCache vfile(assetId, assetType, LLDiskCache::READ);
+ LLFileSystem vfile(assetId, assetType, LLFileSystem::READ);
S32 fileSize = vfile.getSize();
U8* fileBuffer;
diff --git a/indra/llmessage/lltransfersourceasset.cpp b/indra/llmessage/lltransfersourceasset.cpp
index 7b00a95b00..027283232d 100644
--- a/indra/llmessage/lltransfersourceasset.cpp
+++ b/indra/llmessage/lltransfersourceasset.cpp
@@ -32,7 +32,7 @@
#include "message.h"
#include "lldatapacker.h"
#include "lldir.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
LLTransferSourceAsset::LLTransferSourceAsset(const LLUUID &request_id, const F32 priority) :
LLTransferSource(LLTST_ASSET, request_id, priority),
@@ -99,7 +99,7 @@ LLTSCode LLTransferSourceAsset::dataCallback(const S32 packet_id,
return LLTS_SKIP;
}
- LLDiskCache vf(mParams.getAssetID(), mParams.getAssetType(), LLDiskCache::READ);
+ LLFileSystem vf(mParams.getAssetID(), mParams.getAssetType(), LLFileSystem::READ);
if (!vf.getSize())
{
@@ -198,7 +198,7 @@ void LLTransferSourceAsset::responderCallback(const LLUUID& uuid, LLAssetType::E
if (LL_ERR_NOERR == result)
{
// Everything's OK.
- LLDiskCache vf(uuid, type, LLDiskCache::READ);
+ LLFileSystem vf(uuid, type, LLFileSystem::READ);
tsap->mSize = vf.getSize();
status = LLTS_OK;
}
diff --git a/indra/llmessage/lltransfersourceasset.h b/indra/llmessage/lltransfersourceasset.h
index d9055202ec..585e683cb3 100644
--- a/indra/llmessage/lltransfersourceasset.h
+++ b/indra/llmessage/lltransfersourceasset.h
@@ -30,7 +30,7 @@
#include "lltransfermanager.h"
#include "llassetstorage.h"
-class LLDiskCache;
+class LLFileSystem;
class LLTransferSourceParamsAsset : public LLTransferSourceParams
{
diff --git a/indra/llmessage/lltransfertargetvfile.cpp b/indra/llmessage/lltransfertargetvfile.cpp
index f4a5e71d08..471d687d67 100644
--- a/indra/llmessage/lltransfertargetvfile.cpp
+++ b/indra/llmessage/lltransfertargetvfile.cpp
@@ -30,7 +30,7 @@
#include "lldatapacker.h"
#include "llerror.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
//static
void LLTransferTargetVFile::updateQueue(bool shutdown)
@@ -138,7 +138,7 @@ LLTSCode LLTransferTargetVFile::dataCallback(const S32 packet_id, U8 *in_datap,
//LL_INFOS() << "LLTransferTargetFile::dataCallback" << LL_ENDL;
//LL_INFOS() << "Packet: " << packet_id << LL_ENDL;
- LLDiskCache vf(mTempID, mParams.getAssetType(), LLDiskCache::APPEND);
+ LLFileSystem vf(mTempID, mParams.getAssetType(), LLFileSystem::APPEND);
if (mNeedsCreate)
{
vf.setMaxSize(mSize);
@@ -176,7 +176,7 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status)
case LLTS_DONE:
if (!mNeedsCreate)
{
- LLDiskCache file(mTempID, mParams.getAssetType(), LLDiskCache::WRITE);
+ LLFileSystem file(mTempID, mParams.getAssetType(), LLFileSystem::WRITE);
if (!file.rename(mParams.getAssetID(), mParams.getAssetType()))
{
LL_ERRS() << "LLTransferTargetVFile: rename failed" << LL_ENDL;
@@ -195,7 +195,7 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status)
{
// We're aborting this transfer, we don't want to keep this file.
LL_WARNS() << "Aborting vfile transfer for " << mParams.getAssetID() << LL_ENDL;
- LLDiskCache vf(mTempID, mParams.getAssetType(), LLDiskCache::APPEND);
+ LLFileSystem vf(mTempID, mParams.getAssetType(), LLFileSystem::APPEND);
vf.remove();
}
break;
diff --git a/indra/llmessage/lltransfertargetvfile.h b/indra/llmessage/lltransfertargetvfile.h
index 4c1bfe22c5..39a9125f1b 100644
--- a/indra/llmessage/lltransfertargetvfile.h
+++ b/indra/llmessage/lltransfertargetvfile.h
@@ -29,9 +29,9 @@
#include "lltransfermanager.h"
#include "llassetstorage.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
-class LLDiskCache;
+class LLFileSystem;
// Lame, an S32 for now until I figure out the deal with how we want to do
// error codes.
diff --git a/indra/llmessage/llxfer_vfile.cpp b/indra/llmessage/llxfer_vfile.cpp
index 95629d5fea..9de9ed379b 100644
--- a/indra/llmessage/llxfer_vfile.cpp
+++ b/indra/llmessage/llxfer_vfile.cpp
@@ -30,7 +30,7 @@
#include "lluuid.h"
#include "llerror.h"
#include "llmath.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "lldir.h"
// size of chunks read from/written to disk
@@ -79,9 +79,9 @@ void LLXfer_VFile::cleanup ()
if (mTempID.notNull() &&
mDeleteTempFile)
{
- if (LLDiskCache::getExists(mTempID, mType))
+ if (LLFileSystem::getExists(mTempID, mType))
{
- LLDiskCache file(mTempID, mType, LLDiskCache::WRITE);
+ LLFileSystem file(mTempID, mType, LLFileSystem::WRITE);
file.remove();
}
else
@@ -187,9 +187,9 @@ S32 LLXfer_VFile::startSend (U64 xfer_id, const LLHost &remote_host)
delete mVFile;
mVFile = NULL;
- if(LLDiskCache::getExists(mLocalID, mType))
+ if(LLFileSystem::getExists(mLocalID, mType))
{
- mVFile = new LLDiskCache(mLocalID, mType, LLDiskCache::READ);
+ mVFile = new LLFileSystem(mLocalID, mType, LLFileSystem::READ);
if (mVFile->getSize() <= 0)
{
@@ -235,9 +235,9 @@ S32 LLXfer_VFile::reopenFileHandle()
if (mVFile == NULL)
{
- if (LLDiskCache::getExists(mLocalID, mType))
+ if (LLFileSystem::getExists(mLocalID, mType))
{
- mVFile = new LLDiskCache(mLocalID, mType, LLDiskCache::READ);
+ mVFile = new LLFileSystem(mLocalID, mType, LLFileSystem::READ);
}
else
{
@@ -260,7 +260,7 @@ void LLXfer_VFile::setXferSize (S32 xfer_size)
// It would be nice if LLXFers could tell which end of the pipe they were
if (! mVFile)
{
- LLDiskCache file(mTempID, mType, LLDiskCache::APPEND);
+ LLFileSystem file(mTempID, mType, LLFileSystem::APPEND);
file.setMaxSize(xfer_size);
}
}
@@ -315,7 +315,7 @@ S32 LLXfer_VFile::flush()
S32 retval = 0;
if (mBufferLength)
{
- LLDiskCache file(mTempID, mType, LLDiskCache::APPEND);
+ LLFileSystem file(mTempID, mType, LLFileSystem::APPEND);
file.write((U8*)mBuffer, mBufferLength);
@@ -335,9 +335,9 @@ S32 LLXfer_VFile::processEOF()
if (!mCallbackResult)
{
- if (LLDiskCache::getExists(mTempID, mType))
+ if (LLFileSystem::getExists(mTempID, mType))
{
- LLDiskCache file(mTempID, mType, LLDiskCache::WRITE);
+ LLFileSystem file(mTempID, mType, LLFileSystem::WRITE);
if (!file.rename(mLocalID, mType))
{
LL_WARNS("Xfer") << "Cache rename of temp file failed: unable to rename " << mTempID << " to " << mLocalID << LL_ENDL;
diff --git a/indra/llmessage/llxfer_vfile.h b/indra/llmessage/llxfer_vfile.h
index d6ac6ff818..d82bab5f6c 100644
--- a/indra/llmessage/llxfer_vfile.h
+++ b/indra/llmessage/llxfer_vfile.h
@@ -30,7 +30,7 @@
#include "llxfer.h"
#include "llassetstorage.h"
-class LLDiskCache;
+class LLFileSystem;
class LLXfer_VFile : public LLXfer
{
@@ -40,7 +40,7 @@ class LLXfer_VFile : public LLXfer
LLUUID mTempID;
LLAssetType::EType mType;
- LLDiskCache *mVFile;
+ LLFileSystem *mVFile;
std::string mName;
diff --git a/indra/llui/llviewereventrecorder.h b/indra/llui/llviewereventrecorder.h
index fec0f9784f..94e66f5dc4 100644
--- a/indra/llui/llviewereventrecorder.h
+++ b/indra/llui/llviewereventrecorder.h
@@ -32,7 +32,6 @@
#include "lldir.h"
#include "llsd.h"
#include "llfile.h"
-#include "lldiskcache.h"
#include "lldate.h"
#include "llsdserialize.h"
#include "llkeyboard.h"
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6181683b9e..12598d028c 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -114,7 +114,7 @@
#include "llprimitive.h"
#include "llurlaction.h"
#include "llurlentry.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llvolumemgr.h"
#include "llxfermanager.h"
#include "llphysicsextensions.h"
@@ -1876,7 +1876,7 @@ bool LLAppViewer::cleanup()
SUBSYSTEM_CLEANUP(LLFolderViewItem);
LL_INFOS() << "Cleaning up disk cache" << LL_ENDL;
- SUBSYSTEM_CLEANUP(LLDiskCache);
+ SUBSYSTEM_CLEANUP(LLFileSystem);
LL_INFOS() << "Saving Data" << LL_ENDL;
@@ -4160,7 +4160,7 @@ bool LLAppViewer::initCache()
LLVOCache::getInstance()->initCache(LL_PATH_CACHE, gSavedSettings.getU32("CacheNumberOfRegionsForObjects"), getObjectCacheVersion());
- LLDiskCache::initClass();
+ LLFileSystem::initClass();
return true;
}
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index ad2f3b9f9a..5d010a6f1e 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -52,7 +52,7 @@
#include "lldir.h"
#include "llnotificationsutil.h"
#include "llviewerstats.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "lluictrlfactory.h"
#include "lltrans.h"
diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp
index 42bcb86454..1b9814883e 100644
--- a/indra/newview/llfloaterauction.cpp
+++ b/indra/newview/llfloaterauction.cpp
@@ -32,7 +32,7 @@
#include "llimagej2c.h"
#include "llimagetga.h"
#include "llparcel.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llwindow.h"
#include "message.h"
@@ -201,7 +201,7 @@ void LLFloaterAuction::onClickSnapshot(void* data)
LLPointer<LLImageTGA> tga = new LLImageTGA;
tga->encode(raw);
- LLDiskCache::writeFile(tga->getData(), tga->getDataSize(), self->mImageID, LLAssetType::AT_IMAGE_TGA);
+ LLFileSystem::writeFile(tga->getData(), tga->getDataSize(), self->mImageID, LLAssetType::AT_IMAGE_TGA);
raw->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT);
@@ -209,7 +209,7 @@ void LLFloaterAuction::onClickSnapshot(void* data)
LLPointer<LLImageJ2C> j2c = new LLImageJ2C;
j2c->encode(raw, 0.0f);
- LLDiskCache::writeFile(j2c->getData(), j2c->getDataSize(), self->mImageID, LLAssetType::AT_TEXTURE);
+ LLFileSystem::writeFile(j2c->getData(), j2c->getDataSize(), self->mImageID, LLAssetType::AT_TEXTURE);
self->mImage = LLViewerTextureManager::getLocalTexture((LLImageRaw*)raw, FALSE);
gGL.getTexUnit(0)->bind(self->mImage);
diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp
index 303b4836e4..08f3b577b4 100644
--- a/indra/newview/llfloaterbvhpreview.cpp
+++ b/indra/newview/llfloaterbvhpreview.cpp
@@ -32,7 +32,7 @@
#include "lldatapacker.h"
#include "lldir.h"
#include "llnotificationsutil.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llapr.h"
#include "llstring.h"
@@ -997,7 +997,7 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata)
LLDataPackerBinaryBuffer dp(buffer, file_size);
if (motionp->serialize(dp))
{
- LLDiskCache file(motionp->getID(), LLAssetType::AT_ANIMATION, LLDiskCache::APPEND);
+ LLFileSystem file(motionp->getID(), LLAssetType::AT_ANIMATION, LLFileSystem::APPEND);
S32 size = dp.getCurrentSize();
file.setMaxSize(size);
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 057c4d0d5c..0fa5f8e4df 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -77,7 +77,7 @@
#include "llspinctrl.h"
#include "lltoggleablemenu.h"
#include "lltrans.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llcallbacklist.h"
#include "llviewerobjectlist.h"
#include "llanimationstates.h"
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index d2ab15a9b4..0375c15467 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -36,7 +36,7 @@
#include "llglheaders.h"
#include "llregionflags.h"
#include "llstl.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llxfermanager.h"
#include "indra_constants.h"
#include "message.h"
@@ -2239,7 +2239,7 @@ void LLPanelEstateCovenant::onLoadComplete(const LLUUID& asset_uuid,
{
if(0 == status)
{
- LLDiskCache file(asset_uuid, type, LLDiskCache::READ);
+ LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 file_length = file.getSize();
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index 97db905467..3ef80300ef 100644
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -44,7 +44,7 @@
#include "llnotificationsutil.h"
#include "llstring.h"
#include "llsys.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "mean_collision_data.h"
#include "message.h"
#include "v3math.h"
@@ -899,7 +899,7 @@ void LLFloaterReporter::takeScreenshot(bool use_prev_screenshot)
mResourceDatap->mAssetInfo.setDescription("screenshot_descr");
// store in cache
- LLDiskCache::writeFile(upload_data->getData(),
+ LLFileSystem::writeFile(upload_data->getData(),
upload_data->getDataSize(),
mResourceDatap->mAssetInfo.mUuid,
mResourceDatap->mAssetInfo.mType);
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index 96da13915c..1aeb727172 100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -40,7 +40,7 @@
#include "lltextbox.h"
#include "llui.h"
#include "lluictrlfactory.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "message.h"
#include "llstartup.h" // login_alert_done
#include "llcorehttputil.h"
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 82feb891bc..9f2119281d 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -42,7 +42,7 @@
#include "llnotificationsutil.h"
#include "llstl.h"
#include "llstring.h" // todo: remove
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "message.h"
// newview
@@ -1055,7 +1055,7 @@ void LLGestureMgr::onLoadComplete(const LLUUID& asset_uuid,
if (0 == status)
{
- LLDiskCache file(asset_uuid, type, LLDiskCache::READ);
+ LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 size = file.getSize();
std::vector<char> buffer(size+1);
diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp
index 5661b2525b..747212ba55 100644
--- a/indra/newview/lllandmarklist.cpp
+++ b/indra/newview/lllandmarklist.cpp
@@ -33,7 +33,7 @@
#include "llappviewer.h"
#include "llagent.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llviewerstats.h"
// Globals
@@ -122,7 +122,7 @@ void LLLandmarkList::processGetAssetReply(
{
if( status == 0 )
{
- LLDiskCache file(uuid, type);
+ LLFileSystem file(uuid, type);
S32 file_length = file.getSize();
std::vector<char> buffer(file_length + 1);
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 011b187b58..a0d591dc47 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -49,7 +49,7 @@
#include "llsdutil_math.h"
#include "llsdserialize.h"
#include "llthread.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llviewercontrol.h"
#include "llviewerinventory.h"
#include "llviewermenufile.h"
@@ -1335,7 +1335,7 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
//check cache for mesh skin info
- LLDiskCache file(mesh_id, LLAssetType::AT_MESH);
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
U8* buffer = new(std::nothrow) U8[size];
@@ -1431,7 +1431,7 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
//check cache for mesh skin info
- LLDiskCache file(mesh_id, LLAssetType::AT_MESH);
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
U8* buffer = new(std::nothrow) U8[size];
@@ -1528,7 +1528,7 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
//check cache for mesh physics shape info
- LLDiskCache file(mesh_id, LLAssetType::AT_MESH);
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
LLMeshRepository::sCacheBytesRead += size;
@@ -1633,7 +1633,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c
{
//look for mesh in asset in cache
- LLDiskCache file(mesh_params.getSculptID(), LLAssetType::AT_MESH);
+ LLFileSystem file(mesh_params.getSculptID(), LLAssetType::AT_MESH);
S32 size = file.getSize();
@@ -1712,7 +1712,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
{
//check cache for mesh asset
- LLDiskCache file(mesh_id, LLAssetType::AT_MESH);
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
U8* buffer = new(std::nothrow) U8[size];
@@ -3240,7 +3240,7 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b
// only allocate as much space in the cache as is needed for the local cache
data_size = llmin(data_size, bytes);
- LLDiskCache file(mesh_id, LLAssetType::AT_MESH, LLDiskCache::WRITE);
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::WRITE);
if (file.getMaxSize() >= bytes || file.setMaxSize(bytes))
{
LLMeshRepository::sCacheBytesWritten += data_size;
@@ -3312,7 +3312,7 @@ void LLMeshLODHandler::processData(LLCore::BufferArray * /* body */, S32 /* body
if (result == MESH_OK)
{
// good fetch from sim, write to cache
- LLDiskCache file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLDiskCache::WRITE);
+ LLFileSystem file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLFileSystem::WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3376,7 +3376,7 @@ void LLMeshSkinInfoHandler::processData(LLCore::BufferArray * /* body */, S32 /*
&& gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size))
{
// good fetch from sim, write to cache
- LLDiskCache file(mMeshID, LLAssetType::AT_MESH, LLDiskCache::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3424,7 +3424,7 @@ void LLMeshDecompositionHandler::processData(LLCore::BufferArray * /* body */, S
&& gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size))
{
// good fetch from sim, write to cache
- LLDiskCache file(mMeshID, LLAssetType::AT_MESH, LLDiskCache::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3471,7 +3471,7 @@ void LLMeshPhysicsShapeHandler::processData(LLCore::BufferArray * /* body */, S3
&& gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size) == MESH_OK)
{
// good fetch from sim, write to cache for caching
- LLDiskCache file(mMeshID, LLAssetType::AT_MESH, LLDiskCache::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index ac2d449621..90f6d23a61 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -32,7 +32,7 @@
// llcommon
#include "llcommonutils.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llaccordionctrltab.h"
#include "llappearancemgr.h"
diff --git a/indra/newview/llpostcard.cpp b/indra/newview/llpostcard.cpp
index 1fd57ef555..071fc31d27 100644
--- a/indra/newview/llpostcard.cpp
+++ b/indra/newview/llpostcard.cpp
@@ -28,7 +28,7 @@
#include "llpostcard.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llviewerregion.h"
#include "message.h"
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index c7f8f790f4..371153aac3 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -47,7 +47,7 @@
#include "llradiogroup.h"
#include "llresmgr.h"
#include "lltrans.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
#include "llviewerstats.h"
@@ -852,7 +852,7 @@ void LLPreviewGesture::onLoadComplete(const LLUUID& asset_uuid,
{
if (0 == status)
{
- LLDiskCache file(asset_uuid, type, LLDiskCache::READ);
+ LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 size = file.getSize();
std::vector<char> buffer(size+1);
@@ -1137,7 +1137,7 @@ void LLPreviewGesture::saveIfNeeded()
tid.generate();
assetId = tid.makeAssetID(gAgent.getSecureSessionID());
- LLDiskCache file(assetId, LLAssetType::AT_GESTURE, LLDiskCache::APPEND);
+ LLFileSystem file(assetId, LLAssetType::AT_GESTURE, LLFileSystem::APPEND);
S32 size = dp.getCurrentSize();
file.setMaxSize(size);
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index 0b21ff5047..0bccf1d06f 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -46,7 +46,7 @@
#include "llselectmgr.h"
#include "lltrans.h"
#include "llviewertexteditor.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llviewerinventory.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
@@ -337,7 +337,7 @@ void LLPreviewNotecard::onLoadComplete(const LLUUID& asset_uuid,
{
if(0 == status)
{
- LLDiskCache file(asset_uuid, type, LLDiskCache::READ);
+ LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 file_length = file.getSize();
@@ -452,7 +452,7 @@ void LLPreviewNotecard::finishInventoryUpload(LLUUID itemId, LLUUID newAssetId,
// script actually changed the asset.
if (nc->hasEmbeddedInventory())
{
- LLDiskCache::removeFile(newAssetId, LLAssetType::AT_NOTECARD);
+ LLFileSystem::removeFile(newAssetId, LLAssetType::AT_NOTECARD);
}
if (newItemId.isNull())
{
@@ -477,7 +477,7 @@ void LLPreviewNotecard::finishTaskUpload(LLUUID itemId, LLUUID newAssetId, LLUUI
{
if (nc->hasEmbeddedInventory())
{
- LLDiskCache::removeFile(newAssetId, LLAssetType::AT_NOTECARD);
+ LLFileSystem::removeFile(newAssetId, LLAssetType::AT_NOTECARD);
}
nc->setAssetId(newAssetId);
nc->refreshFromInventory();
@@ -556,7 +556,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem, bool sync)
tid.generate();
asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- LLDiskCache file(asset_id, LLAssetType::AT_NOTECARD, LLDiskCache::APPEND);
+ LLFileSystem file(asset_id, LLAssetType::AT_NOTECARD, LLFileSystem::APPEND);
LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID,
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index c2b687cf3b..eae6c28e35 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -51,7 +51,7 @@
#include "llsdserialize.h"
#include "llslider.h"
#include "lltooldraganddrop.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llagent.h"
#include "llmenugl.h"
@@ -1715,7 +1715,7 @@ void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType t
{
if(0 == status)
{
- LLDiskCache file(asset_uuid, type);
+ LLFileSystem file(asset_uuid, type);
S32 file_length = file.getSize();
std::vector<char> buffer(file_length+1);
@@ -2020,7 +2020,7 @@ void LLLiveLSLEditor::onLoadComplete(const LLUUID& asset_id,
void LLLiveLSLEditor::loadScriptText(const LLUUID &uuid, LLAssetType::EType type)
{
- LLDiskCache file(uuid, type);
+ LLFileSystem file(uuid, type);
S32 file_length = file.getSize();
std::vector<char> buffer(file_length + 1);
file.read((U8*)&buffer[0], file_length);
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index 62dc9f24bd..2db0fe6fa4 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -57,7 +57,7 @@
#include "llinventorymodel.h"
#include "llassetstorage.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "lldrawpoolwater.h"
#include <boost/algorithm/string/replace.hpp>
@@ -303,7 +303,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(const LLUUID &asset_id, S32 statu
LLSettingsBase::ptr_t settings;
if (!status)
{
- LLDiskCache file(asset_id, LLAssetType::AT_SETTINGS, LLDiskCache::READ);
+ LLFileSystem file(asset_id, LLAssetType::AT_SETTINGS, LLFileSystem::READ);
S32 size = file.getSize();
std::string buffer(size + 1, '\0');
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 50523e981a..795563e295 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -31,6 +31,7 @@
#include "llagentbenefits.h"
#include "llagentcamera.h"
#include "llagentui.h"
+#include "llfilesystem.h"
#include "llcombobox.h"
#include "llfloaterperms.h"
#include "llfloaterreg.h"
@@ -50,7 +51,6 @@
#include "llviewercontrol.h"
#include "llviewermenufile.h" // upload_new_resource()
#include "llviewerstats.h"
-#include "lldiskcache.h"
#include "llwindow.h"
#include "llworld.h"
#include <boost/filesystem.hpp>
@@ -1005,7 +1005,7 @@ void LLSnapshotLivePreview::saveTexture(BOOL outfit_snapshot, std::string name)
if (formatted->encode(scaled, 0.0f))
{
- LLDiskCache::writeFile(formatted->getData(), formatted->getDataSize(), new_asset_id, LLAssetType::AT_TEXTURE);
+ LLFileSystem::writeFile(formatted->getData(), formatted->getDataSize(), new_asset_id, LLAssetType::AT_TEXTURE);
std::string pos_string;
LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL);
std::string who_took_it;
diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp
index 3b86f3910d..df3ff1a3c7 100644
--- a/indra/newview/llviewerassetstorage.cpp
+++ b/indra/newview/llviewerassetstorage.cpp
@@ -28,7 +28,7 @@
#include "llviewerassetstorage.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "message.h"
#include "llagent.h"
@@ -152,13 +152,13 @@ void LLViewerAssetStorage::storeAssetData(
if (mUpstreamHost.isOk())
{
- if (LLDiskCache::getExists(asset_id, asset_type))
+ if (LLFileSystem::getExists(asset_id, asset_type))
{
// Pack data into this packet if we can fit it.
U8 buffer[MTUBYTES];
buffer[0] = 0;
- LLDiskCache vfile(asset_id, asset_type, LLDiskCache::READ);
+ LLFileSystem vfile(asset_id, asset_type, LLFileSystem::READ);
S32 asset_size = vfile.getSize();
LLAssetRequest *req = new LLAssetRequest(asset_id, asset_type);
@@ -180,7 +180,7 @@ void LLViewerAssetStorage::storeAssetData(
else
{
// LLAssetStorage metric: Successful Request
- S32 size = LLDiskCache::getFileSize(asset_id, asset_type);
+ S32 size = LLFileSystem::getFileSize(asset_id, asset_type);
const char *message = "Added to upload queue";
reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, size, MR_OKAY, __FILE__, __LINE__, message );
@@ -291,7 +291,7 @@ void LLViewerAssetStorage::storeAssetData(
legacy->mUpCallback = callback;
legacy->mUserData = user_data;
- LLDiskCache file(asset_id, asset_type, LLDiskCache::WRITE);
+ LLFileSystem file(asset_id, asset_type, LLFileSystem::WRITE);
file.setMaxSize(size);
@@ -527,7 +527,7 @@ void LLViewerAssetStorage::assetRequestCoro(
// case.
LLUUID temp_id;
temp_id.generate();
- LLDiskCache vf(temp_id, atype, LLDiskCache::WRITE);
+ LLFileSystem vf(temp_id, atype, LLFileSystem::WRITE);
vf.setMaxSize(size);
req->mBytesFetched = size;
if (!vf.write(raw.data(),size))
diff --git a/indra/newview/llviewerassetstorage.h b/indra/newview/llviewerassetstorage.h
index e65bdc1aea..972c89de34 100644
--- a/indra/newview/llviewerassetstorage.h
+++ b/indra/newview/llviewerassetstorage.h
@@ -30,7 +30,7 @@
#include "llassetstorage.h"
#include "llcorehttputil.h"
-class LLDiskCache;
+class LLFileSystem;
class LLViewerAssetRequest;
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index d62962514c..fb3ca69d5d 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -45,7 +45,7 @@
#include "llviewerassetupload.h"
#include "llappviewer.h"
#include "llviewerstats.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llgesturemgr.h"
#include "llpreviewnotecard.h"
#include "llpreviewgesture.h"
@@ -472,7 +472,7 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile()
infile.open(filename, LL_APR_RB, NULL, &file_size);
if (infile.getFileHandle())
{
- LLDiskCache file(getAssetId(), assetType, LLDiskCache::WRITE);
+ LLFileSystem file(getAssetId(), assetType, LLFileSystem::WRITE);
file.setMaxSize(file_size);
@@ -565,7 +565,7 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload()
if (getAssetId().isNull())
generateNewAssetId();
- LLDiskCache file(getAssetId(), getAssetType(), LLDiskCache::APPEND);
+ LLFileSystem file(getAssetId(), getAssetType(), LLFileSystem::APPEND);
S32 size = mContents.length() + 1;
file.setMaxSize(size);
@@ -597,7 +597,7 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result)
if (mStoredToCache)
{
LLAssetType::EType assetType(getAssetType());
- LLDiskCache::renameFile(getAssetId(), assetType, newAssetId, assetType);
+ LLFileSystem::renameFile(getAssetId(), assetType, newAssetId, assetType);
}
if (mTaskUpload)
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 6d4e12528d..b34f4b5016 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -53,7 +53,6 @@
#include "llviewercontrol.h" // gSavedSettings
#include "llviewertexturelist.h"
#include "lluictrlfactory.h"
-#include "lldiskcache.h"
#include "llviewerinventory.h"
#include "llviewermenu.h" // gMenuHolder
#include "llviewerparcelmgr.h"
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 10ee92c130..4ab6fcc580 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -44,7 +44,7 @@
#include "llteleportflags.h"
#include "lltoastnotifypanel.h"
#include "lltransactionflags.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llxfermanager.h"
#include "mean_collision_data.h"
@@ -6816,7 +6816,7 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid,
std::string covenant_text;
if(0 == status)
{
- LLDiskCache file(asset_uuid, type, LLDiskCache::READ);
+ LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 file_length = file.getSize();
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 874982ed60..7ea702b0c9 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -33,7 +33,6 @@
#include "llfloaterreg.h"
#include "llmemory.h"
#include "lltimer.h"
-#include "lldiskcache.h"
#include "llappviewer.h"
diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp
index 199f7f710a..4c2fbcf837 100644
--- a/indra/newview/llviewertexlayer.cpp
+++ b/indra/newview/llviewertexlayer.cpp
@@ -31,7 +31,6 @@
#include "llagent.h"
#include "llimagej2c.h"
#include "llnotificationsutil.h"
-#include "lldiskcache.h"
#include "llviewerregion.h"
#include "llglslshader.h"
#include "llvoavatarself.h"
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index f12ab59e2b..d7377a2983 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -39,7 +39,6 @@
#include "llimagej2c.h"
#include "llimagetga.h"
#include "llstl.h"
-#include "lldiskcache.h"
#include "message.h"
#include "lltimer.h"
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 57a2421065..07997e02a5 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -54,7 +54,7 @@ class LLTexturePipelineTester ;
typedef void (*loaded_callback_func)( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
-class LLDiskCache;
+class LLFileSystem;
class LLMessageSystem;
class LLViewerMediaImpl ;
class LLVOVolume ;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index e0727d51ba..38fccba169 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -41,7 +41,7 @@
#include "llsdserialize.h"
#include "llsys.h"
-#include "lldiskcache.h"
+#include "llfilesystem.h"
#include "llxmltree.h"
#include "message.h"