[Liblas-commits] hg: use common stream creation facility

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Jan 21 12:44:02 EST 2011


details:   http://hg.liblas.orghg/rev/e4decee2196b
changeset: 2807:e4decee2196b
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Jan 21 11:43:55 2011 -0600
description:
use common stream creation facility

diffstat:

 src/c_api.cpp |  25 +++----------------------
 1 files changed, 3 insertions(+), 22 deletions(-)

diffs (42 lines):

diff -r b1dbaf051135 -r e4decee2196b src/c_api.cpp
--- a/src/c_api.cpp	Fri Jan 21 09:53:35 2011 -0600
+++ b/src/c_api.cpp	Fri Jan 21 11:43:55 2011 -0600
@@ -1550,23 +1550,8 @@
         else {
             m = std::ios::out | std::ios::binary | std::ios::ate;
         }
-                
-        if (compare_no_case(filename,"STOUT",5) == 0)
-        {
-            ostrm = &std::cout;
-        }
-        else 
-        {
-            ostrm = new std::ofstream(filename, m);
-        }
-
-        
-        if (!ostrm->good())
-        {
-            delete ostrm;
-            throw std::runtime_error("Writing stream was not able to be created");
-        }
-        
+
+        ostrm = liblas::Create(filename, m);
         liblas::Header* header = ((liblas::Header*) hHeader);
         liblas::Writer* writer = new liblas::Writer(*ostrm, *header);
 
@@ -1672,11 +1657,7 @@
             return;            
         }
     
-        if (static_cast<std::ofstream&>(*ostrm))
-            static_cast<std::ofstream&>(*ostrm).close();
-        
-        if (ostrm != NULL)
-            delete ostrm;
+        liblas::Cleanup(ostrm);
         
         writers.erase(writer);
         


More information about the Liblas-commits mailing list