00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the conexus library. * 00006 * * 00007 * The conexus library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The conexus library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef CONEXUS_NSPRFILE_H 00020 #define CONEXUS_NSPRFILE_H 00021 00022 #include <conexus/enums.h> 00023 #include <conexus-nspr/filedescriptor.h> 00024 00025 namespace Conexus 00026 { 00027 00028 namespace NSPR 00029 { 00030 00041 class File : public FileDescriptor 00042 { 00043 protected: 00044 00045 File ( const std::string& filename, 00046 long unsigned mode ); 00047 00048 public: 00049 00050 typedef ConexusPointer<File> pointer; 00051 00052 CONEXUS_ENDPOINT_GENERIC_CREATE(); 00053 00054 static File::pointer create ( const std::string& filename = std::string(), 00055 long unsigned mode = 0 ); 00056 00057 virtual ~File(); 00058 00062 virtual void open ( const std::string name, 00063 long unsigned mode = FILE_UNCHANGED ) 00064 throw ( open_exception ); 00065 00070 virtual void open() throw ( open_exception ); 00071 00073 std::string filename(); 00074 00075 long unsigned mode(); 00076 00077 bool eof(); 00078 00079 bool throw_eof(); 00080 00081 void set_throw_eof ( bool teof = true ); 00082 00083 bool is_file() const; 00084 00085 bool is_directory() const; 00086 00087 bool is_other_file_type() const; 00088 00089 size_t size() const; 00090 00103 void set_filename ( std::string d, long unsigned mode = FILE_UNCHANGED ) throw ( open_exception ); 00104 00105 sigc::signal<void> signal_filename_changed(); 00106 00107 protected: 00108 std::string m_filename; 00109 long unsigned m_mode; 00110 bool m_eof; 00111 bool m_throw_eof; 00112 00113 sigc::signal<void> m_signal_filename_changed; 00114 00121 virtual Data read_data ( long int timeout, size_t s = 0 ) throw ( read_exception ); 00122 00123 }; 00124 00125 } 00126 00127 } 00128 00129 #endif