fix a couple of things for the vfs explorer
This commit is contained in:
@@ -55,32 +55,25 @@ const S32 BLOCK_LENGTH_INVALID = -1; // mLength for invalid LLVFSFileBlocks
|
|||||||
LLVFS *gVFS = NULL;
|
LLVFS *gVFS = NULL;
|
||||||
|
|
||||||
// internal class definitions
|
// internal class definitions
|
||||||
class LLVFSBlock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LLVFSBlock()
|
|
||||||
{
|
|
||||||
mLocation = 0;
|
|
||||||
mLength = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LLVFSBlock(U32 loc, S32 size)
|
|
||||||
{
|
|
||||||
mLocation = loc;
|
|
||||||
mLength = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool locationSortPredicate(
|
|
||||||
const LLVFSBlock* lhs,
|
|
||||||
const LLVFSBlock* rhs)
|
|
||||||
{
|
|
||||||
return lhs->mLocation < rhs->mLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
LLVFSBlock::LLVFSBlock()
|
||||||
U32 mLocation;
|
{
|
||||||
S32 mLength; // allocated block size
|
mLocation = 0;
|
||||||
};
|
mLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLVFSBlock::LLVFSBlock(U32 loc, S32 size)
|
||||||
|
{
|
||||||
|
mLocation = loc;
|
||||||
|
mLength = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LLVFSBlock::locationSortPredicate(
|
||||||
|
const LLVFSBlock* lhs,
|
||||||
|
const LLVFSBlock* rhs)
|
||||||
|
{
|
||||||
|
return lhs->mLocation < rhs->mLocation;
|
||||||
|
}
|
||||||
|
|
||||||
LLVFSFileSpecifier::LLVFSFileSpecifier()
|
LLVFSFileSpecifier::LLVFSFileSpecifier()
|
||||||
: mFileID(),
|
: mFileID(),
|
||||||
@@ -108,117 +101,106 @@ bool LLVFSFileSpecifier::operator==(const LLVFSFileSpecifier &rhs) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class LLVFSFileBlock : public LLVFSBlock, public LLVFSFileSpecifier
|
|
||||||
|
LLVFSFileBlock::LLVFSFileBlock() : LLVFSBlock(), LLVFSFileSpecifier()
|
||||||
{
|
{
|
||||||
public:
|
init();
|
||||||
LLVFSFileBlock() : LLVFSBlock(), LLVFSFileSpecifier()
|
}
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc = 0, S32 size = 0)
|
|
||||||
: LLVFSBlock(loc, size), LLVFSFileSpecifier( file_id, file_type )
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void init()
|
LLVFSFileBlock::LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc, S32 size) :
|
||||||
{
|
LLVFSBlock(loc, size), LLVFSFileSpecifier( file_id, file_type )
|
||||||
mSize = 0;
|
{
|
||||||
mIndexLocation = -1;
|
init();
|
||||||
mAccessTime = (U32)time(NULL);
|
}
|
||||||
|
|
||||||
for (S32 i = 0; i < (S32)VFSLOCK_COUNT; i++)
|
void LLVFSFileBlock::init()
|
||||||
{
|
{
|
||||||
mLocks[(EVFSLock)i] = 0;
|
mSize = 0;
|
||||||
}
|
mIndexLocation = -1;
|
||||||
}
|
mAccessTime = (U32)time(NULL);
|
||||||
|
|
||||||
#ifdef LL_LITTLE_ENDIAN
|
for (S32 i = 0; i < (S32)VFSLOCK_COUNT; i++)
|
||||||
inline void swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */}
|
{
|
||||||
|
mLocks[(EVFSLock)i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#ifdef LL_LITTLE_ENDIAN
|
||||||
|
void LLVFSFileBlock::swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */}
|
||||||
inline U32 swizzle32(U32 x)
|
|
||||||
{
|
|
||||||
return(((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) |((x << 24) & 0xFF000000));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline U16 swizzle16(U16 x)
|
|
||||||
{
|
|
||||||
return( ((x >> 8) & 0x000000FF) | ((x << 8) & 0x0000FF00) );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void swizzleCopy(void *dst, void *src, int size)
|
|
||||||
{
|
|
||||||
if(size == 4)
|
|
||||||
{
|
|
||||||
((U32*)dst)[0] = swizzle32(((U32*)src)[0]);
|
|
||||||
}
|
|
||||||
else if(size == 2)
|
|
||||||
{
|
|
||||||
((U16*)dst)[0] = swizzle16(((U16*)src)[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Perhaps this should assert...
|
|
||||||
memcpy(dst, src, size); /* Flawfinder: ignore */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void serialize(U8 *buffer)
|
#else
|
||||||
|
|
||||||
|
U32 LLVFSFileBlock::swizzle32(U32 x)
|
||||||
|
{
|
||||||
|
return(((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) |((x << 24) & 0xFF000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
U16 LLVFSFileBlock::swizzle16(U16 x)
|
||||||
|
{
|
||||||
|
return( ((x >> 8) & 0x000000FF) | ((x << 8) & 0x0000FF00) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLVFSFileBlock::swizzleCopy(void *dst, void *src, int size)
|
||||||
|
{
|
||||||
|
if(size == 4)
|
||||||
{
|
{
|
||||||
swizzleCopy(buffer, &mLocation, 4);
|
((U32*)dst)[0] = swizzle32(((U32*)src)[0]);
|
||||||
buffer += 4;
|
|
||||||
swizzleCopy(buffer, &mLength, 4);
|
|
||||||
buffer +=4;
|
|
||||||
swizzleCopy(buffer, &mAccessTime, 4);
|
|
||||||
buffer +=4;
|
|
||||||
memcpy(buffer, &mFileID.mData, 16); /* Flawfinder: ignore */
|
|
||||||
buffer += 16;
|
|
||||||
S16 temp_type = mFileType;
|
|
||||||
swizzleCopy(buffer, &temp_type, 2);
|
|
||||||
buffer += 2;
|
|
||||||
swizzleCopy(buffer, &mSize, 4);
|
|
||||||
}
|
}
|
||||||
|
else if(size == 2)
|
||||||
void deserialize(U8 *buffer, const S32 index_loc)
|
|
||||||
{
|
{
|
||||||
mIndexLocation = index_loc;
|
((U16*)dst)[0] = swizzle16(((U16*)src)[0]);
|
||||||
|
|
||||||
swizzleCopy(&mLocation, buffer, 4);
|
|
||||||
buffer += 4;
|
|
||||||
swizzleCopy(&mLength, buffer, 4);
|
|
||||||
buffer += 4;
|
|
||||||
swizzleCopy(&mAccessTime, buffer, 4);
|
|
||||||
buffer += 4;
|
|
||||||
memcpy(&mFileID.mData, buffer, 16);
|
|
||||||
buffer += 16;
|
|
||||||
S16 temp_type;
|
|
||||||
swizzleCopy(&temp_type, buffer, 2);
|
|
||||||
mFileType = (LLAssetType::EType)temp_type;
|
|
||||||
buffer += 2;
|
|
||||||
swizzleCopy(&mSize, buffer, 4);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
static BOOL insertLRU(LLVFSFileBlock* const& first,
|
|
||||||
LLVFSFileBlock* const& second)
|
|
||||||
{
|
{
|
||||||
return (first->mAccessTime == second->mAccessTime)
|
// Perhaps this should assert...
|
||||||
? *first < *second
|
memcpy(dst, src, size); /* Flawfinder: ignore */
|
||||||
: first->mAccessTime < second->mAccessTime;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public:
|
|
||||||
S32 mSize;
|
#endif
|
||||||
S32 mIndexLocation; // location of index entry
|
|
||||||
U32 mAccessTime;
|
void LLVFSFileBlock::serialize(U8 *buffer)
|
||||||
BOOL mLocks[VFSLOCK_COUNT]; // number of outstanding locks of each type
|
{
|
||||||
|
swizzleCopy(buffer, &mLocation, 4);
|
||||||
static const S32 SERIAL_SIZE;
|
buffer += 4;
|
||||||
};
|
swizzleCopy(buffer, &mLength, 4);
|
||||||
|
buffer +=4;
|
||||||
|
swizzleCopy(buffer, &mAccessTime, 4);
|
||||||
|
buffer +=4;
|
||||||
|
memcpy(buffer, &mFileID.mData, 16); /* Flawfinder: ignore */
|
||||||
|
buffer += 16;
|
||||||
|
S16 temp_type = mFileType;
|
||||||
|
swizzleCopy(buffer, &temp_type, 2);
|
||||||
|
buffer += 2;
|
||||||
|
swizzleCopy(buffer, &mSize, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLVFSFileBlock::deserialize(U8 *buffer, const S32 index_loc)
|
||||||
|
{
|
||||||
|
mIndexLocation = index_loc;
|
||||||
|
|
||||||
|
swizzleCopy(&mLocation, buffer, 4);
|
||||||
|
buffer += 4;
|
||||||
|
swizzleCopy(&mLength, buffer, 4);
|
||||||
|
buffer += 4;
|
||||||
|
swizzleCopy(&mAccessTime, buffer, 4);
|
||||||
|
buffer += 4;
|
||||||
|
memcpy(&mFileID.mData, buffer, 16);
|
||||||
|
buffer += 16;
|
||||||
|
S16 temp_type;
|
||||||
|
swizzleCopy(&temp_type, buffer, 2);
|
||||||
|
mFileType = (LLAssetType::EType)temp_type;
|
||||||
|
buffer += 2;
|
||||||
|
swizzleCopy(&mSize, buffer, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL LLVFSFileBlock::insertLRU(LLVFSFileBlock* const& first,
|
||||||
|
LLVFSFileBlock* const& second)
|
||||||
|
{
|
||||||
|
return (first->mAccessTime == second->mAccessTime)
|
||||||
|
? *first < *second
|
||||||
|
: first->mAccessTime < second->mAccessTime;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper structure for doing lru w/ stl... is there a simpler way?
|
// Helper structure for doing lru w/ stl... is there a simpler way?
|
||||||
struct LLVFSFileBlock_less
|
struct LLVFSFileBlock_less
|
||||||
|
|||||||
@@ -59,9 +59,24 @@ enum EVFSLock
|
|||||||
VFSLOCK_COUNT = 3
|
VFSLOCK_COUNT = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// internal classes
|
//<edit>
|
||||||
class LLVFSBlock;
|
//the VFS explorer requires that the class definition of these be available outside of llvfs
|
||||||
class LLVFSFileBlock;
|
class LLVFSBlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LLVFSBlock();
|
||||||
|
|
||||||
|
LLVFSBlock(U32 loc, S32 size);
|
||||||
|
|
||||||
|
static bool locationSortPredicate(
|
||||||
|
const LLVFSBlock* lhs,
|
||||||
|
const LLVFSBlock* rhs);
|
||||||
|
|
||||||
|
public:
|
||||||
|
U32 mLocation;
|
||||||
|
S32 mLength; // allocated block size
|
||||||
|
};
|
||||||
|
|
||||||
class LLVFSFileSpecifier
|
class LLVFSFileSpecifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -75,6 +90,32 @@ public:
|
|||||||
LLAssetType::EType mFileType;
|
LLAssetType::EType mFileType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LLVFSFileBlock : public LLVFSBlock, public LLVFSFileSpecifier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LLVFSFileBlock();
|
||||||
|
LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc = 0, S32 size = 0);
|
||||||
|
void init();
|
||||||
|
#ifdef LL_LITTLE_ENDIAN
|
||||||
|
inline void swizzleCopy(void *dst, void *src, int size);
|
||||||
|
#else
|
||||||
|
inline U32 swizzle32(U32 x);
|
||||||
|
inline U16 swizzle16(U16 x);
|
||||||
|
inline void swizzleCopy(void *dst, void *src, int size);
|
||||||
|
#endif
|
||||||
|
void serialize(U8 *buffer);
|
||||||
|
void deserialize(U8 *buffer, const S32 index_loc);
|
||||||
|
static BOOL insertLRU(LLVFSFileBlock* const& first,
|
||||||
|
LLVFSFileBlock* const& second);
|
||||||
|
S32 mSize;
|
||||||
|
S32 mIndexLocation; // location of index entry
|
||||||
|
U32 mAccessTime;
|
||||||
|
BOOL mLocks[VFSLOCK_COUNT]; // number of outstanding locks of each type
|
||||||
|
|
||||||
|
static const S32 SERIAL_SIZE;
|
||||||
|
};
|
||||||
|
//<edit>
|
||||||
|
|
||||||
class LLVFS
|
class LLVFS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -473,13 +473,13 @@ void DOFloaterHex::readVFile()
|
|||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
|
||||||
floater->mEditor->setValue(new_data);
|
mEditor->setValue(new_data);
|
||||||
floater->mEditor->setVisible(TRUE);
|
mEditor->setVisible(TRUE);
|
||||||
|
|
||||||
floater->childSetText("status_text", std::string("Editing VFile"));
|
childSetText("status_text", std::string("Editing VFile"));
|
||||||
|
|
||||||
floater->childSetEnabled("upload_btn", false);
|
childSetEnabled("upload_btn", false);
|
||||||
floater->childSetEnabled("save_btn", false);
|
childSetEnabled("save_btn", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// </edit>
|
// </edit>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class DOFloaterHex
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DOFloaterHex(LLUUID item_id, BOOL vfs=false, LLAssetType::EType asset_type = LLAssetType::AT_NONE);
|
DOFloaterHex(LLUUID item_id, BOOL vfs=false, LLAssetType::EType asset_type = LLAssetType::AT_NONE);
|
||||||
static void show(LLUUID item_id);
|
static void show(LLUUID item_id, BOOL vfs=false, LLAssetType::EType asset_type = LLAssetType::AT_NONE);
|
||||||
BOOL postBuild(void);
|
BOOL postBuild(void);
|
||||||
void close(bool app_quitting);
|
void close(bool app_quitting);
|
||||||
static void imageCallback(BOOL success,
|
static void imageCallback(BOOL success,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "lllocalinventory.h"
|
#include "lllocalinventory.h"
|
||||||
#include "llviewerwindow.h"
|
#include "llviewerwindow.h"
|
||||||
#include "llassetconverter.h"
|
#include "llassetconverter.h"
|
||||||
#include "dohexeditor.h"
|
#include "dofloaterhex.h"
|
||||||
|
|
||||||
LLFloaterVFSExplorer* LLFloaterVFSExplorer::sInstance;
|
LLFloaterVFSExplorer* LLFloaterVFSExplorer::sInstance;
|
||||||
std::map<LLVFSFileSpecifier, LLVFSFileBlock*> LLFloaterVFSExplorer::sVFSFileMap;
|
std::map<LLVFSFileSpecifier, LLVFSFileBlock*> LLFloaterVFSExplorer::sVFSFileMap;
|
||||||
@@ -42,6 +42,7 @@ BOOL LLFloaterVFSExplorer::postBuild()
|
|||||||
childSetAction("remove_btn", onClickRemove, this);
|
childSetAction("remove_btn", onClickRemove, this);
|
||||||
childSetAction("reload_all_btn", onClickReload, this);
|
childSetAction("reload_all_btn", onClickReload, this);
|
||||||
childSetAction("copy_uuid_btn", onClickCopyUUID, this);
|
childSetAction("copy_uuid_btn", onClickCopyUUID, this);
|
||||||
|
childSetAction("edit_data_btn", onClickEditData, this);
|
||||||
refresh();
|
refresh();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -140,6 +141,7 @@ void LLFloaterVFSExplorer::setEditEnabled(bool enabled)
|
|||||||
childSetEnabled("name_edit", false);
|
childSetEnabled("name_edit", false);
|
||||||
childSetEnabled("id_edit", false);
|
childSetEnabled("id_edit", false);
|
||||||
childSetEnabled("type_combo", false);
|
childSetEnabled("type_combo", false);
|
||||||
|
childSetEnabled("edit_data_btn", enabled);
|
||||||
childSetEnabled("remove_btn", enabled);
|
childSetEnabled("remove_btn", enabled);
|
||||||
childSetEnabled("copy_uuid_btn", enabled);
|
childSetEnabled("copy_uuid_btn", enabled);
|
||||||
}
|
}
|
||||||
@@ -175,13 +177,14 @@ void LLFloaterVFSExplorer::onClickReload(void* user_data)
|
|||||||
// static
|
// static
|
||||||
void LLFloaterVFSExplorer::onClickEditData(void* user_data)
|
void LLFloaterVFSExplorer::onClickEditData(void* user_data)
|
||||||
{
|
{
|
||||||
|
LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data;
|
||||||
LLVFSFileSpecifier file;
|
LLVFSFileSpecifier file;
|
||||||
std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator end = sVFSFileMap.end();
|
std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator end = sVFSFileMap.end();
|
||||||
for(std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator iter = sVFSFileMap.begin(); iter != end; ++iter)
|
for(std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator iter = sVFSFileMap.begin(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
if((*iter).first.mFileID == mEditID)
|
if((*iter).first.mFileID == floaterp->mEditID)
|
||||||
file = (*iter).first;
|
file = (*iter).first;
|
||||||
}
|
}
|
||||||
DOHexEditor::showVFS(file.mFileID, file.mFileType);
|
DOFloaterHex::show(file.mFileID, true, file.mFileType);
|
||||||
}
|
}
|
||||||
// </edit>
|
// </edit>
|
||||||
|
|||||||
@@ -85,4 +85,5 @@
|
|||||||
</combo_box>
|
</combo_box>
|
||||||
<button name="copy_uuid_btn" follows="left|bottom" width="75" bottom="7" left="10" height="20" label="Copy UUID"/>
|
<button name="copy_uuid_btn" follows="left|bottom" width="75" bottom="7" left="10" height="20" label="Copy UUID"/>
|
||||||
<button name="remove_btn" follows="left|bottom" width="75" bottom_delta="0" left_delta="75" height="20" label="Remove"/>
|
<button name="remove_btn" follows="left|bottom" width="75" bottom_delta="0" left_delta="75" height="20" label="Remove"/>
|
||||||
|
<button name="edit_data_btn" follows="left|bottom" width="75" bottom_delta="0" left_delta="75" height="20" label="View Data"/>
|
||||||
</floater>
|
</floater>
|
||||||
|
|||||||
Reference in New Issue
Block a user