Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
e1ea901c
Commit
e1ea901c
authored
Aug 05, 2014
by
Thomas Jahns
🤸
Browse files
Change iegCopyRecord to not propagate errors.
Fail early instead.
parent
cefadde1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/stream_ieg.c
View file @
e1ea901c
...
...
@@ -3,6 +3,7 @@
#endif
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<float.h>
#include
<math.h>
...
...
@@ -524,35 +525,29 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
}
int
iegCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
)
void
iegCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
)
{
int
fileID1
,
fileID2
;
int
tsID
,
recID
,
vrecID
;
long
recsize
;
off_t
recpos
;
int
status
=
0
;
char
*
buffer
;
int
fileID1
=
streamptr1
->
fileID
;
int
fileID2
=
streamptr2
->
fileID
;
fileID1
=
streamptr1
->
fileID
;
fileID2
=
streamptr2
->
fileID
;
int
tsID
=
streamptr1
->
curTsID
;
int
vrecID
=
streamptr1
->
tsteps
[
tsID
].
curRecID
;
int
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
off_t
recpos
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
position
;
size_t
recsize
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
size
;
tsID
=
streamptr1
->
curTsID
;
vrecID
=
streamptr1
->
tsteps
[
tsID
].
curRecID
;
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
recpos
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
position
;
recsize
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
size
;
if
(
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
)
!=
0
)
Error
(
"Cannot seek input file for IEG record copy!"
);
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
);
char
*
buffer
=
xmalloc
(
recsize
);
buffer
=
(
char
*
)
malloc
(
recsize
);
if
(
fileRead
(
fileID1
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to read record from IEG file for copying!"
);
fileRead
(
fileID1
,
buffer
,
recsize
);
fileWrite
(
fileID2
,
buffer
,
recsize
);
if
(
fileWrite
(
fileID2
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to write record to IEG file when copying!"
);
free
(
buffer
);
return
(
status
);
}
...
...
src/stream_ieg.h
View file @
e1ea901c
...
...
@@ -10,7 +10,7 @@ int iegInqTimestep(stream_t *streamptr, int tsID);
int
iegInqRecord
(
stream_t
*
streamptr
,
int
*
varID
,
int
*
levelID
);
void
iegDefRecord
(
stream_t
*
streamptr
);
int
iegCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
);
void
iegCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
);
void
iegReadRecord
(
stream_t
*
streamptr
,
double
*
data
,
int
*
nmiss
);
void
iegWriteRecord
(
stream_t
*
streamptr
,
const
double
*
data
);
...
...
src/stream_record.c
View file @
e1ea901c
...
...
@@ -458,11 +458,8 @@ void streamCopyRecord(int streamID2, int streamID1)
#endif
#if defined (HAVE_LIBIEG)
case
FILETYPE_IEG
:
{
/* FIXME: return value not inspected */
status
=
iegCopyRecord
(
streamptr2
,
streamptr1
);
break
;
}
iegCopyRecord
(
streamptr2
,
streamptr1
);
break
;
#endif
#if defined (HAVE_LIBNETCDF)
case
FILETYPE_NC
:
...
...
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