[Liblas-commits] laszip: proper EOF handling with throw EOF
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Jun 13 16:31:16 EDT 2011
details: http://hg.liblas.orglaszip/rev/453a268b6375
changeset: 246:453a268b6375
user: isenburg
date: Mon Jun 13 13:34:28 2011 -0700
description:
proper EOF handling with throw EOF
diffstat:
src/bytestreamin_file.hpp | 4 +-
src/bytestreamin_istream.hpp | 3 +-
src/lasreadpoint.cpp | 49 +++++++++++++++++++++++++------------------
3 files changed, 31 insertions(+), 25 deletions(-)
diffs (101 lines):
diff -r 6760e1b7675b -r 453a268b6375 src/bytestreamin_file.hpp
--- a/src/bytestreamin_file.hpp Mon Jun 13 10:50:05 2011 -0700
+++ b/src/bytestreamin_file.hpp Mon Jun 13 13:34:28 2011 -0700
@@ -113,8 +113,7 @@
int byte = getc(file);
if (byte == EOF)
{
-// fprintf(stderr, "reading EOF\n");
- byte = 0;
+ throw EOF;
}
return (unsigned int)byte;
}
@@ -136,6 +135,7 @@
inline bool ByteStreamInFile::seek(const long position)
{
+// return !(_fseeki64(file, (I64)position, SEEK_SET));
return !(fseek(file, position, SEEK_SET));
}
diff -r 6760e1b7675b -r 453a268b6375 src/bytestreamin_istream.hpp
--- a/src/bytestreamin_istream.hpp Mon Jun 13 10:50:05 2011 -0700
+++ b/src/bytestreamin_istream.hpp Mon Jun 13 13:34:28 2011 -0700
@@ -123,8 +123,7 @@
int byte = stream.get();
if (stream.eof())
{
-// fprintf(stderr, "reading EOF\n");
- byte = 0;
+ throw EOF;
}
return (unsigned int)byte;
}
diff -r 6760e1b7675b -r 453a268b6375 src/lasreadpoint.cpp
--- a/src/lasreadpoint.cpp Mon Jun 13 10:50:05 2011 -0700
+++ b/src/lasreadpoint.cpp Mon Jun 13 13:34:28 2011 -0700
@@ -299,35 +299,42 @@
{
U32 i;
- if (chunk_count == chunk_size)
+ try
{
- current_chunk++;
- if (chunk_totals)
+ if (chunk_count == chunk_size)
{
- chunk_size = chunk_totals[current_chunk+1]-chunk_totals[current_chunk];
+ current_chunk++;
+ if (chunk_totals)
+ {
+ chunk_size = chunk_totals[current_chunk+1]-chunk_totals[current_chunk];
+ }
+ dec->done();
+ init(instream);
+ chunk_count = 0;
}
- dec->done();
- init(instream);
- chunk_count = 0;
- }
- chunk_count++;
+ chunk_count++;
- if (readers)
- {
- for (i = 0; i < num_readers; i++)
+ if (readers)
{
- readers[i]->read(point[i]);
+ for (i = 0; i < num_readers; i++)
+ {
+ readers[i]->read(point[i]);
+ }
+ }
+ else
+ {
+ for (i = 0; i < num_readers; i++)
+ {
+ readers_raw[i]->read(point[i]);
+ ((LASreadItemCompressed*)(readers_compressed[i]))->init(point[i]);
+ }
+ readers = readers_compressed;
+ dec->init(instream);
}
}
- else
+ catch (...)
{
- for (i = 0; i < num_readers; i++)
- {
- readers_raw[i]->read(point[i]);
- ((LASreadItemCompressed*)(readers_compressed[i]))->init(point[i]);
- }
- readers = readers_compressed;
- dec->init(instream);
+ return FALSE;
}
return TRUE;
}
More information about the Liblas-commits
mailing list