aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llxfer_file.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llmessage/llxfer_file.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llmessage/llxfer_file.cpp')
-rw-r--r--linden/indra/llmessage/llxfer_file.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/linden/indra/llmessage/llxfer_file.cpp b/linden/indra/llmessage/llxfer_file.cpp
index 840d84c..da12d54 100644
--- a/linden/indra/llmessage/llxfer_file.cpp
+++ b/linden/indra/llmessage/llxfer_file.cpp
@@ -47,17 +47,17 @@
47const U32 LL_MAX_XFER_FILE_BUFFER = 65536; 47const U32 LL_MAX_XFER_FILE_BUFFER = 65536;
48 48
49// local function to copy a file 49// local function to copy a file
50S32 copy_file(const char* from, const char* to); 50S32 copy_file(const std::string& from, const std::string& to);
51 51
52/////////////////////////////////////////////////////////// 52///////////////////////////////////////////////////////////
53 53
54LLXfer_File::LLXfer_File (S32 chunk_size) 54LLXfer_File::LLXfer_File (S32 chunk_size)
55: LLXfer(chunk_size) 55: LLXfer(chunk_size)
56{ 56{
57 init(LLString::null, FALSE, chunk_size); 57 init(LLStringUtil::null, FALSE, chunk_size);
58} 58}
59 59
60LLXfer_File::LLXfer_File (const LLString& local_filename, BOOL delete_local_on_completion, S32 chunk_size) 60LLXfer_File::LLXfer_File (const std::string& local_filename, BOOL delete_local_on_completion, S32 chunk_size)
61: LLXfer(chunk_size) 61: LLXfer(chunk_size)
62{ 62{
63 init(local_filename, delete_local_on_completion, chunk_size); 63 init(local_filename, delete_local_on_completion, chunk_size);
@@ -72,24 +72,24 @@ LLXfer_File::~LLXfer_File ()
72 72
73/////////////////////////////////////////////////////////// 73///////////////////////////////////////////////////////////
74 74
75void LLXfer_File::init (const LLString& local_filename, BOOL delete_local_on_completion, S32 chunk_size) 75void LLXfer_File::init (const std::string& local_filename, BOOL delete_local_on_completion, S32 chunk_size)
76{ 76{
77 77
78 mFp = NULL; 78 mFp = NULL;
79 mLocalFilename[0] = 0; 79 mLocalFilename.clear();
80 mRemoteFilename[0] = 0; 80 mRemoteFilename.clear();
81 mRemotePath = LL_PATH_NONE; 81 mRemotePath = LL_PATH_NONE;
82 mTempFilename[0] = 0; 82 mTempFilename.clear();
83 mDeleteLocalOnCompletion = FALSE; 83 mDeleteLocalOnCompletion = FALSE;
84 mDeleteRemoteOnCompletion = FALSE; 84 mDeleteRemoteOnCompletion = FALSE;
85 85
86 if (!local_filename.empty()) 86 if (!local_filename.empty())
87 { 87 {
88 strncpy(mLocalFilename, local_filename.c_str(), LL_MAX_PATH-1); 88 mLocalFilename = local_filename.substr(0,LL_MAX_PATH-1);
89 mLocalFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy.
90 89
91 // You can only automatically delete .tmp file as a safeguard against nasty messages. 90 // You can only automatically delete .tmp file as a safeguard against nasty messages.
92 mDeleteLocalOnCompletion = (delete_local_on_completion && (strstr(mLocalFilename,".tmp") == &mLocalFilename[strlen(mLocalFilename)-4])); /* Flawfinder : ignore */ 91 std::string exten = mLocalFilename.substr(mLocalFilename.length()-4, 4);
92 mDeleteLocalOnCompletion = (delete_local_on_completion && exten == ".tmp");
93 } 93 }
94} 94}
95 95
@@ -121,8 +121,8 @@ void LLXfer_File::free ()
121/////////////////////////////////////////////////////////// 121///////////////////////////////////////////////////////////
122 122
123S32 LLXfer_File::initializeRequest(U64 xfer_id, 123S32 LLXfer_File::initializeRequest(U64 xfer_id,
124 const LLString& local_filename, 124 const std::string& local_filename,
125 const LLString& remote_filename, 125 const std::string& remote_filename,
126 ELLPath remote_path, 126 ELLPath remote_path,
127 const LLHost& remote_host, 127 const LLHost& remote_host,
128 BOOL delete_remote_on_completion, 128 BOOL delete_remote_on_completion,
@@ -132,15 +132,13 @@ S32 LLXfer_File::initializeRequest(U64 xfer_id,
132 S32 retval = 0; // presume success 132 S32 retval = 0; // presume success
133 133
134 mID = xfer_id; 134 mID = xfer_id;
135 strncpy(mLocalFilename, local_filename.c_str(), LL_MAX_PATH-1); 135 mLocalFilename = local_filename;
136 mLocalFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy. 136 mRemoteFilename = remote_filename;
137 strncpy(mRemoteFilename,remote_filename.c_str(), LL_MAX_PATH-1);
138 mRemoteFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy.
139 mRemotePath = remote_path; 137 mRemotePath = remote_path;
140 mRemoteHost = remote_host; 138 mRemoteHost = remote_host;
141 mDeleteRemoteOnCompletion = delete_remote_on_completion; 139 mDeleteRemoteOnCompletion = delete_remote_on_completion;
142 140
143 snprintf(mTempFilename, sizeof(mTempFilename), "%s",gDirUtilp->getTempFilename().c_str()); /* Flawfinder: ignore */ 141 mTempFilename = gDirUtilp->getTempFilename();
144 142
145 mCallback = callback; 143 mCallback = callback;
146 mCallbackDataHandle = user_data; 144 mCallbackDataHandle = user_data;
@@ -343,7 +341,7 @@ S32 LLXfer_File::processEOF()
343 if(copy_file(mTempFilename, mLocalFilename) == 0) 341 if(copy_file(mTempFilename, mLocalFilename) == 0)
344 { 342 {
345 llinfos << "Rename across mounts; copying+unlinking the file instead." << llendl; 343 llinfos << "Rename across mounts; copying+unlinking the file instead." << llendl;
346 unlink(mTempFilename); 344 unlink(mTempFilename.c_str());
347 } 345 }
348 else 346 else
349 { 347 {
@@ -384,14 +382,14 @@ S32 LLXfer_File::processEOF()
384 382
385/////////////////////////////////////////////////////////// 383///////////////////////////////////////////////////////////
386 384
387BOOL LLXfer_File::matchesLocalFilename(const LLString& filename) 385BOOL LLXfer_File::matchesLocalFilename(const std::string& filename)
388{ 386{
389 return (filename == mLocalFilename); 387 return (filename == mLocalFilename);
390} 388}
391 389
392/////////////////////////////////////////////////////////// 390///////////////////////////////////////////////////////////
393 391
394BOOL LLXfer_File::matchesRemoteFilename(const LLString& filename, ELLPath remote_path) 392BOOL LLXfer_File::matchesRemoteFilename(const std::string& filename, ELLPath remote_path)
395{ 393{
396 return ((filename == mRemoteFilename) && (remote_path == mRemotePath)); 394 return ((filename == mRemoteFilename) && (remote_path == mRemotePath));
397} 395}
@@ -399,9 +397,9 @@ BOOL LLXfer_File::matchesRemoteFilename(const LLString& filename, ELLPath remote
399 397
400/////////////////////////////////////////////////////////// 398///////////////////////////////////////////////////////////
401 399
402const char * LLXfer_File::getName() 400std::string LLXfer_File::getFileName()
403{ 401{
404 return (mLocalFilename); 402 return mLocalFilename;
405} 403}
406 404
407/////////////////////////////////////////////////////////// 405///////////////////////////////////////////////////////////
@@ -421,7 +419,7 @@ U32 LLXfer_File::getXferTypeTag()
421// function. It does not really spam enough information, but is useful 419// function. It does not really spam enough information, but is useful
422// for this cpp file, because this should never be called in a 420// for this cpp file, because this should never be called in a
423// production environment. 421// production environment.
424S32 copy_file(const char* from, const char* to) 422S32 copy_file(const std::string& from, const std::string& to)
425{ 423{
426 S32 rv = 0; 424 S32 rv = 0;
427 LLFILE* in = LLFile::fopen(from, "rb"); /*Flawfinder: ignore*/ 425 LLFILE* in = LLFile::fopen(from, "rb"); /*Flawfinder: ignore*/