Zipios++
filepath.cpp
Go to the documentation of this file.
1 
2 #include "zipios++/zipios-config.h"
3 
4 #include <stdexcept>
5 #include <string>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 
9 #include "zipios++/filepath.h"
10 
11 namespace zipios {
12 
13 using namespace std ;
14 
15 const char FilePath::_separator = '/' ;
16 
17 
18 FilePath::FilePath( const string &path, bool check_exists )
19  : _checked( false ),
20  _path( path ) {
22  if ( check_exists )
23  exists() ;
24 }
25 
26 
27 void FilePath::check() const {
28  _checked = true ;
29  _exists = false ;
30  _is_reg = false ;
31  _is_dir = false ;
32  _is_char = false ;
33  _is_block = false ;
34  _is_socket = false ;
35  _is_fifo = false ;
36 
37  struct stat buf ;
38  if ( stat( _path.c_str(), &buf ) != -1 ) {
39  _exists = true ;
40  #if defined(BOOST_WINNT)
41  _is_reg = _S_IFREG & buf.st_mode ;
42  _is_dir = _S_IFDIR & buf.st_mode ;
43  _is_char = _S_IFCHR & buf.st_mode ;
44  #else
45  _is_reg = S_ISREG ( buf.st_mode ) ;
46  _is_dir = S_ISDIR ( buf.st_mode ) ;
47  _is_char = S_ISCHR ( buf.st_mode ) ;
48  _is_block = S_ISBLK ( buf.st_mode ) ;
49  _is_socket = S_ISSOCK( buf.st_mode ) ;
50  _is_fifo = S_ISFIFO( buf.st_mode ) ;
51  #endif
52  }
53 }
54 
55 } // namespace
56 
61 /*
62  Zipios++ - a small C++ library that provides easy access to .zip files.
63  Copyright (C) 2000 Thomas Søndergaard
64 
65  This library is free software; you can redistribute it and/or
66  modify it under the terms of the GNU Lesser General Public
67  License as published by the Free Software Foundation; either
68  version 2 of the License, or (at your option) any later version.
69 
70  This library is distributed in the hope that it will be useful,
71  but WITHOUT ANY WARRANTY; without even the implied warranty of
72  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
73  Lesser General Public License for more details.
74 
75  You should have received a copy of the GNU Lesser General Public
76  License along with this library; if not, write to the Free Software
77  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
78 */