Main Page   Class Hierarchy   Compound List   File List   Compound Members  

filepath.cpp

Go to the documentation of this file.
00001 
00002 #include "zipios++/zipios-config.h"
00003 
00004 #include <stdexcept>
00005 #include <string>
00006 #include <sys/types.h>
00007 #include <sys/stat.h>
00008 
00009 #include "zipios++/filepath.h"
00010 
00011 namespace zipios {
00012 
00013 using namespace std ;
00014 
00015 const char FilePath::_separator = '/' ;
00016 
00017 
00018 FilePath::FilePath( const string &path, bool check_exists )
00019   : _checked( false ),
00020     _path( path ) {
00021   pruneTrailingSeparator() ;
00022   if ( check_exists ) 
00023     exists() ;
00024 }
00025 
00026 
00027 void FilePath::check() const {
00028   _checked     = true  ;  
00029   _exists      = false ;
00030   _is_reg      = false ;
00031   _is_dir      = false ;
00032   _is_char     = false ; 
00033   _is_block    = false ;
00034   _is_socket   = false ;
00035   _is_fifo     = false ;
00036   
00037   struct stat buf ;
00038   if ( stat( _path.c_str(), &buf ) != -1 ) {
00039     _exists    = true ;
00040     _is_reg    = S_ISREG ( buf.st_mode ) ;
00041     _is_dir    = S_ISDIR ( buf.st_mode ) ;
00042     _is_char   = S_ISCHR ( buf.st_mode ) ;
00043     _is_block  = S_ISBLK ( buf.st_mode ) ;
00044     _is_socket = S_ISSOCK( buf.st_mode ) ;
00045     _is_fifo   = S_ISFIFO( buf.st_mode ) ;
00046   } 
00047 }
00048 
00049 } // namespace
00050 
00055 /*
00056   Zipios++ - a small C++ library that provides easy access to .zip files.
00057   Copyright (C) 2000  Thomas Søndergaard
00058   
00059   This library is free software; you can redistribute it and/or
00060   modify it under the terms of the GNU Lesser General Public
00061   License as published by the Free Software Foundation; either
00062   version 2 of the License, or (at your option) any later version.
00063   
00064   This library is distributed in the hope that it will be useful,
00065   but WITHOUT ANY WARRANTY; without even the implied warranty of
00066   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00067   Lesser General Public License for more details.
00068   
00069   You should have received a copy of the GNU Lesser General Public
00070   License along with this library; if not, write to the Free Software
00071   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00072 */

Generated at Tue Aug 14 20:39:26 2001 for Zipios++ by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000