Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
77d25204
Commit
77d25204
authored
10 years ago
by
Oz Linden
Browse files
Options
Downloads
Patches
Plain Diff
clarity and logging cleanup
parent
ab30a44d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llcommon/lllivefile.cpp
+46
-39
46 additions, 39 deletions
indra/llcommon/lllivefile.cpp
with
46 additions
and
39 deletions
indra/llcommon/lllivefile.cpp
+
46
−
39
View file @
77d25204
...
@@ -51,6 +51,8 @@ class LLLiveFile::Impl
...
@@ -51,6 +51,8 @@ class LLLiveFile::Impl
bool
mLastExists
;
bool
mLastExists
;
LLEventTimer
*
mEventTimer
;
LLEventTimer
*
mEventTimer
;
private:
LOG_CLASS
(
LLLiveFile
);
};
};
LLLiveFile
::
Impl
::
Impl
(
const
std
::
string
&
filename
,
const
F32
refresh_period
)
LLLiveFile
::
Impl
::
Impl
(
const
std
::
string
&
filename
,
const
F32
refresh_period
)
...
@@ -83,46 +85,51 @@ LLLiveFile::~LLLiveFile()
...
@@ -83,46 +85,51 @@ LLLiveFile::~LLLiveFile()
bool
LLLiveFile
::
Impl
::
check
()
bool
LLLiveFile
::
Impl
::
check
()
{
{
if
(
!
mForceCheck
&&
mRefreshTimer
.
getElapsedTimeF32
()
<
mRefreshPeriod
)
bool
detected_change
=
false
;
// Skip the check if not enough time has elapsed and we're not
// forcing a check of the file
if
(
mForceCheck
||
mRefreshTimer
.
getElapsedTimeF32
()
>=
mRefreshPeriod
)
{
{
// Skip the check if not enough time has elapsed and we're not
mForceCheck
=
false
;
// force only forces one check
// forcing a check of the file
mRefreshTimer
.
reset
();
// don't check again until mRefreshPeriod has passed
return
false
;
}
// Stat the file to see if it exists and when it was last modified.
mForceCheck
=
false
;
llstat
stat_data
;
mRefreshTimer
.
reset
();
if
(
LLFile
::
stat
(
mFilename
,
&
stat_data
))
{
// Stat the file to see if it exists and when it was last modified.
// Couldn't stat the file, that means it doesn't exist or is
llstat
stat_data
;
// broken somehow.
int
res
=
LLFile
::
stat
(
mFilename
,
&
stat_data
);
if
(
mLastExists
)
{
if
(
res
)
mLastExists
=
false
;
{
detected_change
=
true
;
// no longer existing is a change!
// Couldn't stat the file, that means it doesn't exist or is
LL_DEBUGS
()
<<
"detected deleted file '"
<<
mFilename
<<
"'"
<<
LL_ENDL
;
// broken somehow. Clear flags and return.
}
if
(
mLastExists
)
}
{
else
mLastExists
=
false
;
{
return
true
;
// no longer existing is a change!
// The file exists
}
if
(
!
mLastExists
)
return
false
;
{
}
// last check, it did not exist - that counts as a change
LL_DEBUGS
()
<<
"detected created file '"
<<
mFilename
<<
"'"
<<
LL_ENDL
;
// The file exists, decide if we want to load it.
detected_change
=
true
;
if
(
mLastExists
)
}
{
else
if
(
stat_data
.
st_mtime
>
mLastModTime
)
// The file existed last time, don't read it if it hasn't changed since
{
// last time.
// file modification time is newer than last check
if
(
stat_data
.
st_mtime
<=
mLastModTime
)
LL_DEBUGS
()
<<
"detected updated file '"
<<
mFilename
<<
"'"
<<
LL_ENDL
;
{
detected_change
=
true
;
return
false
;
}
}
mLastExists
=
true
;
}
mLastStatTime
=
stat_data
.
st_mtime
;
}
// We want to read the file. Update status info for the file.
}
mLastExists
=
true
;
if
(
detected_change
)
mLastStatTime
=
stat_data
.
st_mtime
;
{
return
true
;
LL_INFOS
()
<<
"detected file change '"
<<
mFilename
<<
"'"
<<
LL_ENDL
;
}
return
detected_change
;
}
}
void
LLLiveFile
::
Impl
::
changed
()
void
LLLiveFile
::
Impl
::
changed
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment