Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Management Services
Seismic
Open ZGY
Commits
a141c4b0
Commit
a141c4b0
authored
Jul 30, 2021
by
Paal Kvamme
Browse files
Add robustness a few places.
parent
620a1952
Pipeline
#55467
passed with stages
in 11 minutes and 46 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
native/src/impl/file_sd.cpp
View file @
a141c4b0
...
...
@@ -1687,6 +1687,10 @@ SeismicStoreFile::xx_close()
std
::
int64_t
SeismicStoreFile
::
xx_eof
()
const
{
if
(
!
_dataset
)
{
throw
OpenZGY
::
Errors
::
ZgyUserError
(
"The file is not open in xx_eof()."
);
//return -1; Might be safer if this is happening in a destructor.
}
return
_dataset
->
info
()
->
totalSize
();
}
...
...
@@ -1703,6 +1707,8 @@ SeismicStoreFile::xx_eof() const
std
::
vector
<
std
::
int64_t
>
SeismicStoreFile
::
xx_segments
(
bool
complete
)
const
{
if
(
!
this
->
_dataset
)
return
std
::
vector
<
std
::
int64_t
>
{};
return
this
->
_dataset
->
info
()
->
allSizes
(
complete
);
}
...
...
@@ -1727,6 +1733,8 @@ SeismicStoreFile::deleteFile(const std::string& filename, bool missing_ok) const
<<
"
\"
"
<<
filename
<<
"
\"
, "
<<
"missing_ok="
<<
std
::
boolalpha
<<
missing_ok
<<
")
\n
"
);
if
(
!
_dataset
)
throw
OpenZGY
::
Errors
::
ZgyUserError
(
"The manager is not open in deleteFile."
);
// Make sure the returned smart pointer doesn't go out of scope.
std
::
shared_ptr
<
seismicdrive
::
SDManager
>
smart_manager
=
_dataset
->
manager
();
seismicdrive
::
SDUtils
utils
(
smart_manager
.
get
());
...
...
@@ -1752,6 +1760,9 @@ SeismicStoreFile::deleteFile(const std::string& filename, bool missing_ok) const
std
::
string
SeismicStoreFile
::
altUrl
(
const
std
::
string
&
filename
)
const
{
if
(
!
_dataset
)
throw
OpenZGY
::
Errors
::
ZgyUserError
(
"The manager is not open in altUrl."
);
// Should I strip off any "?context= first? It doesn't make sense
// to create an alturl from another alturl. Probably doesn't
// matter much either way.
...
...
native/src/impl/logger.cpp
View file @
a141c4b0
...
...
@@ -163,7 +163,7 @@ LoggerBase::standardCallback(int currentlevel, const std::string& prefix_in, con
return
test
;
}
else
{
std
::
string
prefix
(
prefix_in
);
// Avoid capturing just a reference.
std
::
string
prefix
(
prefix_in
);
std
::
string
suffix
(
suffix_in
+
"
\n
"
);
int
id
=
LoggerBaseImpl
::
next_id_
++
;
int
details
=
LoggerBaseImpl
::
getVerboseDetailsFromEnv
();
...
...
@@ -176,19 +176,24 @@ LoggerBase::standardCallback(int currentlevel, const std::string& prefix_in, con
std
::
istringstream
f
(
msg
);
std
::
string
s
;
std
::
lock_guard
<
std
::
mutex
>
lk
(
LoggerBaseImpl
::
mutex_
);
while
(
std
::
getline
(
f
,
s
,
'\n'
))
{
if
(
!
s
.
empty
())
{
if
(
details
&
1
)
{
std
::
stringstream
ss
;
ss
<<
std
::
setprecision
(
3
)
<<
std
::
fixed
<<
LoggerBaseImpl
::
timestamp
()
<<
": "
;
ss
<<
prefix
<<
s
<<
suffix
;
*
os
<<
ss
.
str
();
}
else
{
*
os
<<
(
prefix
+
s
+
suffix
);
if
(
os
->
good
())
{
while
(
std
::
getline
(
f
,
s
,
'\n'
))
{
if
(
!
s
.
empty
())
{
if
(
details
&
1
)
{
std
::
stringstream
ss
;
ss
<<
std
::
setprecision
(
3
)
<<
std
::
fixed
<<
LoggerBaseImpl
::
timestamp
()
<<
": "
;
ss
<<
prefix
<<
s
<<
suffix
;
*
os
<<
ss
.
str
();
}
else
{
*
os
<<
(
prefix
+
s
+
suffix
);
}
}
}
// This will slow down logging to file but is safer if there
// is a crash or if logging is done from a static destructor.
*
os
<<
std
::
flush
;
}
}
return
pri
<=
currentlevel
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment