// Copyright (c) 2005-2007 Hartmut Kaiser (hartmut.kaiser@gmail.com) // Copyright (c) 2005-2007 Andre Merzky // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE file or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include /////////////////////////////////////////////////////////////////////////////// void usage (int val = -1) { std::cout << "Usage: file_cat " << std::endl; exit (val); } /////////////////////////////////////////////////////////////////////////////// int main (int argc, char* argv[]) { if (argc != 2 ) { usage (); } try { saga::file file (argv[1], saga::file::Read); while ( true ) { int const n = 10; char data[n]; for ( int i = 0; i <= n; ++i ) { data[i] = '\0'; } if ( file.read (saga::buffer (data)) ) { std::cout << data << std::flush; } else { break; } } } catch (std::exception const& e) { std::cerr << "saga exception caught: " << e.what () << std::endl; } catch (...) { std::cerr << "unexpected exception caught" << std::endl; } return 0; }