fix a couple of things for the vfs explorer

This commit is contained in:
Hazim Gazov
2010-06-26 17:27:48 +00:00
parent a05e491ed7
commit 1145f8aa2e
6 changed files with 163 additions and 136 deletions

View File

@@ -55,33 +55,26 @@ const S32 BLOCK_LENGTH_INVALID = -1; // mLength for invalid LLVFSFileBlocks
LLVFS *gVFS = NULL; LLVFS *gVFS = NULL;
// internal class definitions // internal class definitions
class LLVFSBlock
{ LLVFSBlock::LLVFSBlock()
public:
LLVFSBlock()
{ {
mLocation = 0; mLocation = 0;
mLength = 0; mLength = 0;
} }
LLVFSBlock(U32 loc, S32 size) LLVFSBlock::LLVFSBlock(U32 loc, S32 size)
{ {
mLocation = loc; mLocation = loc;
mLength = size; mLength = size;
} }
static bool locationSortPredicate( bool LLVFSBlock::locationSortPredicate(
const LLVFSBlock* lhs, const LLVFSBlock* lhs,
const LLVFSBlock* rhs) const LLVFSBlock* rhs)
{ {
return lhs->mLocation < rhs->mLocation; return lhs->mLocation < rhs->mLocation;
} }
public:
U32 mLocation;
S32 mLength; // allocated block size
};
LLVFSFileSpecifier::LLVFSFileSpecifier() LLVFSFileSpecifier::LLVFSFileSpecifier()
: mFileID(), : mFileID(),
mFileType( LLAssetType::AT_NONE ) mFileType( LLAssetType::AT_NONE )
@@ -108,21 +101,19 @@ bool LLVFSFileSpecifier::operator==(const LLVFSFileSpecifier &rhs) const
} }
class LLVFSFileBlock : public LLVFSBlock, public LLVFSFileSpecifier
{ LLVFSFileBlock::LLVFSFileBlock() : LLVFSBlock(), LLVFSFileSpecifier()
public:
LLVFSFileBlock() : LLVFSBlock(), LLVFSFileSpecifier()
{ {
init(); init();
} }
LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc = 0, S32 size = 0) LLVFSFileBlock::LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc, S32 size) :
: LLVFSBlock(loc, size), LLVFSFileSpecifier( file_id, file_type ) LLVFSBlock(loc, size), LLVFSFileSpecifier( file_id, file_type )
{ {
init(); init();
} }
void init() void LLVFSFileBlock::init()
{ {
mSize = 0; mSize = 0;
mIndexLocation = -1; mIndexLocation = -1;
@@ -135,21 +126,21 @@ public:
} }
#ifdef LL_LITTLE_ENDIAN #ifdef LL_LITTLE_ENDIAN
inline void swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */} void LLVFSFileBlock::swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */}
#else #else
inline U32 swizzle32(U32 x) U32 LLVFSFileBlock::swizzle32(U32 x)
{ {
return(((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) |((x << 24) & 0xFF000000)); return(((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) |((x << 24) & 0xFF000000));
} }
inline U16 swizzle16(U16 x) U16 LLVFSFileBlock::swizzle16(U16 x)
{ {
return( ((x >> 8) & 0x000000FF) | ((x << 8) & 0x0000FF00) ); return( ((x >> 8) & 0x000000FF) | ((x << 8) & 0x0000FF00) );
} }
inline void swizzleCopy(void *dst, void *src, int size) void LLVFSFileBlock::swizzleCopy(void *dst, void *src, int size)
{ {
if(size == 4) if(size == 4)
{ {
@@ -168,7 +159,7 @@ public:
#endif #endif
void serialize(U8 *buffer) void LLVFSFileBlock::serialize(U8 *buffer)
{ {
swizzleCopy(buffer, &mLocation, 4); swizzleCopy(buffer, &mLocation, 4);
buffer += 4; buffer += 4;
@@ -184,7 +175,7 @@ public:
swizzleCopy(buffer, &mSize, 4); swizzleCopy(buffer, &mSize, 4);
} }
void deserialize(U8 *buffer, const S32 index_loc) void LLVFSFileBlock::deserialize(U8 *buffer, const S32 index_loc)
{ {
mIndexLocation = index_loc; mIndexLocation = index_loc;
@@ -203,7 +194,7 @@ public:
swizzleCopy(&mSize, buffer, 4); swizzleCopy(&mSize, buffer, 4);
} }
static BOOL insertLRU(LLVFSFileBlock* const& first, BOOL LLVFSFileBlock::insertLRU(LLVFSFileBlock* const& first,
LLVFSFileBlock* const& second) LLVFSFileBlock* const& second)
{ {
return (first->mAccessTime == second->mAccessTime) return (first->mAccessTime == second->mAccessTime)
@@ -211,15 +202,6 @@ public:
: first->mAccessTime < second->mAccessTime; : first->mAccessTime < second->mAccessTime;
} }
public:
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;
};
// 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
{ {

View File

@@ -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:

View File

@@ -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>

View File

@@ -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,

View File

@@ -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>

View File

@@ -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>