aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/lllivefile.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/lllivefile.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcommon/lllivefile.cpp')
-rw-r--r--linden/indra/llcommon/lllivefile.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/linden/indra/llcommon/lllivefile.cpp b/linden/indra/llcommon/lllivefile.cpp
new file mode 100644
index 0000000..33e2014
--- /dev/null
+++ b/linden/indra/llcommon/lllivefile.cpp
@@ -0,0 +1,93 @@
1/**
2 * @file lllivefile.cpp
3 *
4 * Copyright (c) 2006-2007, Linden Research, Inc.
5 *
6 * The source code in this file ("Source Code") is provided by Linden Lab
7 * to you under the terms of the GNU General Public License, version 2.0
8 * ("GPL"), unless you have obtained a separate licensing agreement
9 * ("Other License"), formally executed by you and Linden Lab. Terms of
10 * the GPL can be found in doc/GPL-license.txt in this distribution, or
11 * online at http://secondlife.com/developers/opensource/gplv2
12 *
13 * There are special exceptions to the terms and conditions of the GPL as
14 * it is applied to this Source Code. View the full text of the exception
15 * in the file doc/FLOSS-exception.txt in this software distribution, or
16 * online at http://secondlife.com/developers/opensource/flossexception
17 *
18 * By copying, modifying or distributing this software, you acknowledge
19 * that you have read and understood your obligations described above,
20 * and agree to abide by those obligations.
21 *
22 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
23 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
24 * COMPLETENESS OR PERFORMANCE.
25 */
26
27#include "linden_common.h"
28
29#include "lllivefile.h"
30
31
32LLLiveFile::LLLiveFile(const std::string &filename, const F32 refresh_period) :
33mForceCheck(true),
34mRefreshPeriod(refresh_period),
35mFilename(filename),
36mLastModTime(0),
37mLastExists(false)
38{
39}
40
41
42LLLiveFile::~LLLiveFile()
43{
44}
45
46
47bool LLLiveFile::checkAndReload()
48{
49 if (!mForceCheck && mRefreshTimer.getElapsedTimeF32() < mRefreshPeriod)
50 {
51 // Skip the check if not enough time has elapsed and we're not
52 // forcing a check of the file
53 return false;
54 }
55 mForceCheck = false;
56 mRefreshTimer.reset();
57
58 // Stat the file to see if it exists and when it was last modified.
59 llstat stat_data;
60 int res = LLFile::stat(mFilename.c_str(), &stat_data);
61
62 if (res)
63 {
64 // Couldn't stat the file, that means it doesn't exist or is
65 // broken somehow. Clear flags and return.
66 if (mLastExists)
67 {
68 loadFile(); // Load the file, even though it's missing to allow it to clear state.
69 mLastExists = false;
70 return true;
71 }
72 return false;
73 }
74
75 // The file exists, decide if we want to load it.
76 if (mLastExists)
77 {
78 // The file existed last time, don't read it if it hasn't changed since
79 // last time.
80 if (stat_data.st_mtime <= mLastModTime)
81 {
82 return false;
83 }
84 }
85
86 // We want to read the file. Update status info for the file.
87 mLastExists = true;
88 mLastModTime = stat_data.st_mtime;
89
90 loadFile();
91 return true;
92}
93