diff options
| author | simon <none@none> | 2014-04-07 14:29:18 -0700 |
|---|---|---|
| committer | simon <none@none> | 2014-04-07 14:29:18 -0700 |
| commit | c9620e24d32a08ee79486d5ecc4085731432a0a6 (patch) | |
| tree | 397b622fc8c6a7f598409fe95d8e998bde965225 /indra/llcommon/llfile.cpp | |
| parent | 565c41fdc2e2f8f9841cb41b446671563ea8d5e1 (diff) | |
| parent | 991636d57bd4a67e42a5425fe53bf66bf9cf8d07 (diff) | |
Merge downstream code
Diffstat (limited to 'indra/llcommon/llfile.cpp')
| -rwxr-xr-x | indra/llcommon/llfile.cpp | 31 |
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 |
