diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index ff25f1fde5e10312fd873eb2b6e2d997407c1dec..3711f520bf61134e042dcf2febc403d1aa9721fe 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -454,6 +454,37 @@ bool LLFile::copy(const std::string& from, const std::string& to) return copied; } +bool LLFile::copy(const boost::filesystem::path& from, const boost::filesystem::path& to) +{ + bool copied = false; + LLFILE* in = LLFile::fopen(from, TEXT("rb")); /* Flawfinder: ignore */ + if (in) + { + LLFILE* out = LLFile::fopen(to, TEXT("wb")); /* Flawfinder: ignore */ + if (out) + { + char buf[16384]; /* Flawfinder: ignore */ + size_t readbytes; + bool write_ok = true; + while (write_ok && (readbytes = fread(buf, 1, 16384, in))) /* Flawfinder: ignore */ + { + if (fwrite(buf, 1, readbytes, out) != readbytes) + { + LL_WARNS("LLFile") << "Short write" << LL_ENDL; + write_ok = false; + } + } + if (write_ok) + { + copied = true; + } + fclose(out); + } + fclose(in); + } + return copied; +} + int LLFile::stat(const std::string& filename, llstat* filestatus) { #if LL_WINDOWS diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h index 7bc56247314fa689606bd73fb16945f5f3816880..7c24cbf1c2f97609a1aba30220476d0913ab0c10 100644 --- a/indra/llcommon/llfile.h +++ b/indra/llcommon/llfile.h @@ -64,6 +64,7 @@ typedef struct stat llstat; #define MODE_T const wchar_t* #else #define MODE_T const char* +#define TEXT(quote) #endif class LL_COMMON_API LLFile @@ -87,6 +88,7 @@ class LL_COMMON_API LLFile static int rename(const std::string& filename,const std::string& newname, int supress_error = 0); static int rename(const boost::filesystem::path& filename, const boost::filesystem::path& newname, int supress_error = 0); static bool copy(const std::string& from, const std::string& to); + static bool copy(const boost::filesystem::path& from, const boost::filesystem::path& to); static int stat(const std::string& filename, llstat* file_status); static int stat(const boost::filesystem::path& filename, llstat* file_status); diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index 4bc3785a0dd6c2ced33becdcc0989b37389aafe1..039e7b2d8fc3e997875a1637f7d48d2935c13fd6 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -36,10 +36,6 @@ #include <boost/filesystem.hpp> -#ifndef TEXT -#define TEXT(quote) -#endif - LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_type, S32 mode) : mFileID(file_id), mFileType(file_type),