WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
6ab8c7d4
Commit
6ab8c7d4
authored
Sep 05, 2016
by
Mathias Bavay
Browse files
The append mode of SMET files should now (finally) work properly...
parent
4c7a4908
Changes
1
Hide whitespace changes
Inline
Side-by-side
meteoio/plugins/libsmet.cc
View file @
6ab8c7d4
...
@@ -535,26 +535,25 @@ void SMETWriter::write(const std::vector<std::string>& vec_timestamp, const std:
...
@@ -535,26 +535,25 @@ void SMETWriter::write(const std::vector<std::string>& vec_timestamp, const std:
const
std
::
string
last_timestamp
=
reader
.
getLastTimestamp
();
const
std
::
string
last_timestamp
=
reader
.
getLastTimestamp
();
if
(
last_timestamp
.
empty
()
||
last_timestamp
>=
vec_timestamp
[
0
])
if
(
last_timestamp
.
empty
()
||
last_timestamp
>=
vec_timestamp
[
0
])
reader
.
truncate_file
(
vec_timestamp
[
0
]);
reader
.
truncate_file
(
vec_timestamp
[
0
]);
append_possible
=
true
;
append_possible
=
true
;
}
}
fout
.
open
(
filename
.
c_str
(),
ios
::
binary
|
ofstream
::
app
);
fout
.
open
(
filename
.
c_str
(),
ios
::
binary
|
ofstream
::
app
);
if
(
fout
.
fail
())
throw
SMETException
(
"Error opening file
\"
"
+
filename
+
"
\"
for writing, possible reason: "
+
std
::
string
(
strerror
(
errno
)),
SMET_AT
);
}
else
{
//normal mode
}
else
{
//normal mode
if
(
!
append_possible
)
{
//first write -> overwrite potential previous content
if
(
!
append_possible
)
{
//first write -> overwrite potential previous content
fout
.
open
(
filename
.
c_str
(),
ios
::
binary
);
fout
.
open
(
filename
.
c_str
(),
ios
::
binary
);
append_possible
=
true
;
if
(
fout
.
fail
())
}
else
//after the first write: append
throw
SMETException
(
"Error opening file
\"
"
+
filename
+
"
\"
for writing, possible reason: "
+
std
::
string
(
strerror
(
errno
)),
SMET_AT
);
write_header
(
fout
);
//Write the header info, always in ASCII format
append_possible
=
true
;
//now all other calls to "open" will be in append mode
}
else
{
//after the first write: append
fout
.
open
(
filename
.
c_str
(),
ios
::
binary
|
ofstream
::
app
);
fout
.
open
(
filename
.
c_str
(),
ios
::
binary
|
ofstream
::
app
);
if
(
fout
.
fail
())
throw
SMETException
(
"Error opening file
\"
"
+
filename
+
"
\"
for writing, possible reason: "
+
std
::
string
(
strerror
(
errno
)),
SMET_AT
);
}
}
}
if
(
fout
.
fail
())
{
ostringstream
ss
;
ss
<<
"Error opening file
\"
"
<<
filename
<<
"
\"
for writing, possible reason: "
<<
strerror
(
errno
);
throw
SMETException
(
ss
.
str
(),
SMET_AT
);
}
if
(
!
append_mode
)
write_header
(
fout
);
//Write the header info, always in ASCII format
if
(
vec_timestamp
.
empty
()
||
data
.
empty
()
||
nr_of_fields
==
0
)
{
//the header has been written, nothing to add
if
(
vec_timestamp
.
empty
()
||
data
.
empty
()
||
nr_of_fields
==
0
)
{
//the header has been written, nothing to add
fout
.
close
();
fout
.
close
();
return
;
return
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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