From 2ea5ac0c43e3e28d2b1774f5367d099271a1da32 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 1 Jul 2024 13:34:50 +0200 Subject: #1111 Remove xmlrpc-epi --- indra/llcommon/llfile.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indra/llcommon/llfile.cpp') diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index ddf239f306..9045324bf2 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -248,6 +248,24 @@ int LLFile::close(LLFILE * file) return ret_value; } +std::string LLFile::getContents(const std::string& filename) +{ + LLFILE* fp = fopen(filename, "rb"); /* Flawfinder: ignore */ + if (fp) + { + fseek(fp, 0, SEEK_END); + U32 length = ftell(fp); + fseek(fp, 0, SEEK_SET); + + std::vector buffer(length); + size_t nread = fread(buffer.data(), 1, length, fp); + fclose(fp); + + return std::string(buffer.data(), nread); + } + + return LLStringUtil::null; +} int LLFile::remove(const std::string& filename, int supress_error) { -- cgit v1.2.3 From d6190bbf13547800c56828d7670944f1a06af7dd Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Mon, 19 Aug 2024 08:39:35 +0200 Subject: Refactor LLFileSystem for and fix an old issue in LLFile (#2332) --- indra/llcommon/llfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llfile.cpp') diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index 9045324bf2..ed94ef21ef 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -293,7 +293,7 @@ int LLFile::rename(const std::string& filename, const std::string& newname, int return warnif(STRINGIZE("rename to '" << newname << "' from"), filename, rc, supress_error); } -bool LLFile::copy(const std::string from, const std::string to) +bool LLFile::copy(const std::string& from, const std::string& to) { bool copied = false; LLFILE* in = LLFile::fopen(from, "rb"); /* Flawfinder: ignore */ @@ -424,7 +424,7 @@ LLFILE * LLFile::_Fiopen(const std::string& filename, if (valid[n] == 0) return (0); // no valid mode - else if (norepflag && mode & (ios_base::out || ios_base::app) + else if (norepflag && mode & (ios_base::out | ios_base::app) && (fp = LLFile::fopen(filename, "r")) != 0) /* Flawfinder: ignore */ { // file must not exist, close and fail fclose(fp); -- cgit v1.2.3