summaryrefslogtreecommitdiff
path: root/indra/llcommon/llfile.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2014-04-08 11:41:12 -0400
committerOz Linden <oz@lindenlab.com>2014-04-08 11:41:12 -0400
commit375c05ac43ed56c8ad9670dfdfc801085075a2a2 (patch)
tree2dcee4ef5757823430d5e234e23eedb1a3354d19 /indra/llcommon/llfile.cpp
parenta60875e549aa90f1cef450aabaf23570cf20a22e (diff)
parent7e966f28da79d2d24f93a2615c8807421300700c (diff)
merge changes for 3.7.5-release
Diffstat (limited to 'indra/llcommon/llfile.cpp')
-rwxr-xr-xindra/llcommon/llfile.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index c3a0f0bfe0..761d7f430c 100755
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -265,6 +265,37 @@ int LLFile::rename(const std::string& filename, const std::string& newname)
return warnif(STRINGIZE("rename to '" << newname << "' from"), filename, rc);
}
+bool LLFile::copy(const std::string from, const std::string to)
+{
+ bool copied = false;
+ LLFILE* in = LLFile::fopen(from, "rb"); /* Flawfinder: ignore */
+ if (in)
+ {
+ LLFILE* out = LLFile::fopen(to, "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