Patch AIXML to work now for import
Not bothering with export at the moment AIXML"Stream" wasn't even using its stream in its constructor... Someone clearly hadn't been using ACTUAL C++ for longer than C++'s existence like was claimed ...but then, that's literally impossible, so what could we expect... And dear lord please stop throwing in constructors... There are so many better ways to do this... This use of throwing is why people dislike goto It's hard to follow flow control that would be better done another way... One day I'll fix it so it is, until then meh. Rips out AIFile, since nothing is actually using it anymore and GPL code needs purged.
This commit is contained in:
@@ -25,7 +25,6 @@ include_directories(
|
||||
|
||||
set(llcommon_SOURCE_FILES
|
||||
aialert.cpp
|
||||
aifile.cpp
|
||||
aiframetimer.cpp
|
||||
aisyncclient.cpp
|
||||
aithreadid.cpp
|
||||
@@ -116,7 +115,6 @@ set(llcommon_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
aialert.h
|
||||
aifile.h
|
||||
aiframetimer.h
|
||||
airecursive.h
|
||||
aisyncclient.h
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/**
|
||||
* @file aifile.cpp
|
||||
* @brief POSIX file operations that throw on error.
|
||||
*
|
||||
* Copyright (c) 2013, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 03/11/2013
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "aifile.h"
|
||||
#include "aialert.h"
|
||||
|
||||
#if LL_WINDOWS
|
||||
#include <windows.h>
|
||||
#include <stdlib.h> // Windows errno
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
AIFile::AIFile(std::string const& filename, char const* accessmode)
|
||||
{
|
||||
mFp = AIFile::fopen(filename, accessmode);
|
||||
}
|
||||
|
||||
AIFile::~AIFile()
|
||||
{
|
||||
AIFile::close(mFp);
|
||||
}
|
||||
|
||||
// Like THROW_MALERTE but appends "LLFile::strerr(errn) << " (" << errn << ')'" as argument to replace [ERROR].
|
||||
#define THROW_ERROR(...) \
|
||||
do { \
|
||||
int errn = errno; \
|
||||
std::ostringstream error; \
|
||||
error << LLFile::strerr(errn) << " (" << errn << ')'; \
|
||||
THROW_MALERT_CLASS(AIAlert::ErrorCode, errn, __VA_ARGS__ ("[ERROR]", error.str())); \
|
||||
} while(0)
|
||||
|
||||
//static
|
||||
void AIFile::mkdir(std::string const& dirname, int perms)
|
||||
{
|
||||
int rc = LLFile::mkdir_nowarn(dirname, perms);
|
||||
if (rc < 0 && errno != EEXIST)
|
||||
{
|
||||
THROW_ERROR("AIFile_mkdir_Failed_to_create_DIRNAME", AIArgs("[DIRNAME]", dirname));
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void AIFile::rmdir(std::string const& dirname)
|
||||
{
|
||||
int rc = LLFile::rmdir_nowarn(dirname);
|
||||
if (rc < 0 && errno != ENOENT)
|
||||
{
|
||||
THROW_ERROR("AIFile_rmdir_Failed_to_remove_DIRNAME", AIArgs("[DIRNAME]", dirname));
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
LLFILE* AIFile::fopen(std::string const& filename, const char* mode)
|
||||
{
|
||||
LLFILE* fp = LLFile::fopen(filename, mode);
|
||||
if (!fp)
|
||||
{
|
||||
THROW_ERROR("AIFile_fopen_Failed_to_open_FILENAME", AIArgs("[FILENAME]", filename));
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
//static
|
||||
void AIFile::close(LLFILE* file)
|
||||
{
|
||||
if (LLFile::close(file) < 0)
|
||||
{
|
||||
THROW_ERROR("AIFile_close_Failed_to_close_file", AIArgs);
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void AIFile::remove(std::string const& filename)
|
||||
{
|
||||
int rc = LLFile::remove_nowarn(filename);
|
||||
if (rc < 0 && errno != ENOENT)
|
||||
{
|
||||
THROW_ERROR("AIFile_remove_Failed_to_remove_FILENAME", AIArgs("[FILENAME]", filename));
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void AIFile::rename(std::string const& filename, std::string const& newname)
|
||||
{
|
||||
if (LLFile::rename_nowarn(filename, newname) < 0)
|
||||
{
|
||||
THROW_ERROR("AIFile_rename_Failed_to_rename_FILE_to_NEWFILE", AIArgs("[FILE]", filename)("[NEWFILE]", newname));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* @file aifile.h
|
||||
* @brief Declaration of AIFile.
|
||||
*
|
||||
* Copyright (c) 2013, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 02/11/2013
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#ifndef AIFILE_H
|
||||
#define AIFILE_H
|
||||
|
||||
#include "llfile.h"
|
||||
|
||||
// As LLFile, but throws AIAlert instead of printing a warning.
|
||||
class LL_COMMON_API AIFile
|
||||
{
|
||||
private:
|
||||
LLFILE* mFp;
|
||||
|
||||
public:
|
||||
// Scoped file (exception safe). Throws AIAlertCode with errno on failure.
|
||||
AIFile(std::string const& filename, char const* accessmode);
|
||||
~AIFile();
|
||||
|
||||
operator LLFILE* () const { return mFp; }
|
||||
|
||||
// All these functions take UTF8 path/filenames.
|
||||
static LLFILE* fopen(std::string const& filename, char const* accessmode);
|
||||
static void close(LLFILE* file);
|
||||
|
||||
static void mkdir(std::string const& dirname, int perms = 0700); // Does NOT throw when dirname already exists.
|
||||
static void rmdir(std::string const& dirname); // Does NOT throw when dirname does not exist.
|
||||
static void remove(std::string const& filename); // Does NOT throw when filename does not exist.
|
||||
static void rename(std::string const& filename, std::string const& newname);
|
||||
};
|
||||
|
||||
#endif // AIFILE_H
|
||||
@@ -13,7 +13,7 @@ include_directories(
|
||||
)
|
||||
|
||||
set(llxml_SOURCE_FILES
|
||||
#aixml.cpp
|
||||
aixml.cpp
|
||||
llcontrol.cpp
|
||||
llxmlnode.cpp
|
||||
llxmlparser.cpp
|
||||
@@ -23,7 +23,7 @@ set(llxml_SOURCE_FILES
|
||||
set(llxml_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
#aixml.h
|
||||
aixml.h
|
||||
llcontrol.h
|
||||
llcontrolgroupreader.h
|
||||
llxmlnode.h
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "aixml.h"
|
||||
#include "llmd5.h"
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include "aifile.h"
|
||||
|
||||
//=============================================================================
|
||||
// Overview
|
||||
@@ -311,11 +310,10 @@ void AIXMLElement::child(LLDate const& element)
|
||||
//-----------------------------------------------------------------------------
|
||||
// AIXMLStream
|
||||
|
||||
AIXMLStream::AIXMLStream(LLFILE* fp, bool standalone) : mOfs(fp)
|
||||
AIXMLStream::AIXMLStream(const std::string& filename, bool standalone) : mOfs(filename)
|
||||
{
|
||||
char const* sp = standalone ? " standalone=\"yes\"" : "";
|
||||
int rc = fprintf(fp, "<?xml version=\"1.0\" encoding=\"utf-8\"%s ?>\n", sp);
|
||||
if (rc < 0 || ferror(fp))
|
||||
mOfs << "<?xml version=\"1.0\" encoding=\"utf-8\"" << (standalone ? " standalone=\"yes\"" : LLStringUtil::null) << "?>\n";
|
||||
if (!mOfs)
|
||||
{
|
||||
// I don't think that errno is set to anything else but EBADF here,
|
||||
// so there is not really any informative message to add here.
|
||||
@@ -342,7 +340,6 @@ AIXMLParser::AIXMLParser(std::string const& filename, char const* file_desc, std
|
||||
AIArgs args;
|
||||
if (!mXmlTree.parseFile(filename, TRUE))
|
||||
{
|
||||
AIFile dummy(filename, "rb"); // Check if the file can be opened at all (throws with a more descriptive error if not).
|
||||
error = "AIXMLParser_Cannot_parse_FILEDESC_FILENAME";
|
||||
}
|
||||
else
|
||||
|
||||
@@ -151,7 +151,7 @@ void AIXMLElement::child(FWD_ITERATOR i1, FWD_ITERATOR const& i2)
|
||||
class AIXMLStream {
|
||||
protected:
|
||||
llofstream mOfs;
|
||||
AIXMLStream(LLFILE* fp, bool standalone);
|
||||
AIXMLStream(const std::string& filename, bool standalone);
|
||||
~AIXMLStream();
|
||||
};
|
||||
|
||||
@@ -159,7 +159,7 @@ class AIXMLStream {
|
||||
class AIXMLRootElement : public AIXMLStream, public AIXMLElement
|
||||
{
|
||||
public:
|
||||
AIXMLRootElement(LLFILE* fp, char const* name, bool standalone = true) : AIXMLStream(fp, standalone), AIXMLElement(mOfs, name, 0) { }
|
||||
AIXMLRootElement(const std::string& filename, char const* name, bool standalone = true) : AIXMLStream(filename, standalone), AIXMLElement(mOfs, name, 0) { }
|
||||
};
|
||||
|
||||
class AIXMLElementParser
|
||||
|
||||
@@ -78,7 +78,7 @@ include_directories(
|
||||
set(viewer_SOURCE_FILES
|
||||
NACLantispam.cpp
|
||||
aihttpview.cpp
|
||||
#aixmllindengenepool.cpp
|
||||
aixmllindengenepool.cpp
|
||||
alfloaterregiontracker.cpp
|
||||
aoremotectrl.cpp
|
||||
ascentfloatercontactgroups.cpp
|
||||
@@ -613,7 +613,7 @@ set(viewer_HEADER_FILES
|
||||
|
||||
NACLantispam.h
|
||||
aihttpview.h
|
||||
#aixmllindengenepool.h
|
||||
aixmllindengenepool.h
|
||||
alfloaterregiontracker.h
|
||||
aoremotectrl.h
|
||||
ascentfloatercontactgroups.h
|
||||
|
||||
@@ -68,7 +68,7 @@ AIXMLLindenGenepool::MetaData::MetaData(AIXMLElementParser const& parser)
|
||||
parser.attribute(DEFAULT_LLDATE_NAME, mDate);
|
||||
}
|
||||
|
||||
AIXMLLindenGenepool::AIXMLLindenGenepool(LLFILE* fp) : AIXMLRootElement(fp, "linden_genepool")
|
||||
AIXMLLindenGenepool::AIXMLLindenGenepool(const std::string& filename) : AIXMLRootElement(filename, "linden_genepool")
|
||||
{
|
||||
attribute("version", "1.0");
|
||||
attribute("metaversion", "1.0");
|
||||
|
||||
@@ -53,7 +53,7 @@ class AIXMLLindenGenepool : public AIXMLRootElement
|
||||
MetaData(AIXMLElementParser const& parser);
|
||||
};
|
||||
|
||||
AIXMLLindenGenepool(LLFILE* fp);
|
||||
AIXMLLindenGenepool(const std::string& filename);
|
||||
};
|
||||
|
||||
class AIVisualParamIDValuePair
|
||||
|
||||
@@ -55,8 +55,7 @@
|
||||
|
||||
#include "statemachine/aifilepicker.h"
|
||||
#include "hippogridmanager.h"
|
||||
//#include "aixmllindengenepool.h"
|
||||
#include "aifile.h"
|
||||
#include "aixmllindengenepool.h"
|
||||
|
||||
using namespace LLAvatarAppearanceDefines;
|
||||
|
||||
@@ -314,7 +313,6 @@ void LLFloaterCustomize::onBtnImport()
|
||||
|
||||
void LLFloaterCustomize::onBtnImport_continued(AIFilePicker* filepicker)
|
||||
{
|
||||
#if 0
|
||||
if (!filepicker->hasFilename())
|
||||
{
|
||||
// User canceled import.
|
||||
@@ -457,7 +455,6 @@ void LLFloaterCustomize::onBtnImport_continued(AIFilePicker* filepicker)
|
||||
{
|
||||
AIAlert::add("AIXMLImportWearableTypeMismatch", args("[TYPE]", label)("[ARCHETYPENAME]", wearable_types));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// reX: new function
|
||||
@@ -514,9 +511,7 @@ void LLFloaterCustomize::onBtnExport_continued(LLViewerWearable* edit_wearable,
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
AIFile outfile(filename, "wb");
|
||||
|
||||
AIXMLLindenGenepool linden_genepool(outfile);
|
||||
AIXMLLindenGenepool linden_genepool(filename);
|
||||
linden_genepool.child(edit_wearable->getArchetype());
|
||||
|
||||
success = true;
|
||||
|
||||
@@ -113,8 +113,7 @@
|
||||
#include "llskinningutil.h"
|
||||
|
||||
#include "llfloaterexploreanimations.h"
|
||||
//#include "aixmllindengenepool.h"
|
||||
#include "aifile.h"
|
||||
#include "aixmllindengenepool.h"
|
||||
|
||||
#include "llavatarname.h"
|
||||
#include "../lscript/lscript_byteformat.h"
|
||||
@@ -9420,11 +9419,9 @@ void LLVOAvatar::dumpArchetypeXML(const std::string& prefix, bool group_by_weara
|
||||
|
||||
void LLVOAvatar::dumpArchetypeXML_cont(std::string const& fullpath, bool group_by_wearables)
|
||||
{
|
||||
#if 0
|
||||
try
|
||||
{
|
||||
AIFile outfile(fullpath, "wb");
|
||||
AIXMLLindenGenepool linden_genepool(outfile);
|
||||
AIXMLLindenGenepool linden_genepool(fullpath);
|
||||
|
||||
if (group_by_wearables)
|
||||
{
|
||||
@@ -9496,7 +9493,6 @@ void LLVOAvatar::dumpArchetypeXML_cont(std::string const& fullpath, bool group_b
|
||||
{
|
||||
AIAlert::add_modal("AIXMLdumpArchetypeXMLError", AIArgs("[FILE]", fullpath), error);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user