Files
geant4/source/visualization/HepRep/src/filepath.cc
T
2016-06-09 10:41:53 +02:00

78 lines
2.0 KiB
C++

#include "zipios++/zipios-config.h"
#include <stdexcept>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include "zipios++/filepath.h"
//MD: Linux 2.95 does not have S_ISSOCK under c++ and geant4
#ifndef S_ISSOCK
#define S_ISSOCK(mode) 0
#endif
namespace zipios {
using namespace std ;
const char FilePath::_separator = '/' ;
FilePath::FilePath( const string &path, bool check_exists )
: _checked( false ),
_path( path ) {
pruneTrailingSeparator() ;
if ( check_exists )
exists() ;
}
void FilePath::check() const {
_checked = true ;
_exists = false ;
_is_reg = false ;
_is_dir = false ;
_is_char = false ;
_is_block = false ;
_is_socket = false ;
_is_fifo = false ;
struct stat buf ;
if ( stat( _path.c_str(), &buf ) != -1 ) {
_exists = true ;
_is_reg = S_ISREG ( buf.st_mode ) ;
_is_dir = S_ISDIR ( buf.st_mode ) ;
_is_char = S_ISCHR ( buf.st_mode ) ;
_is_block = S_ISBLK ( buf.st_mode ) ;
_is_socket = S_ISSOCK( buf.st_mode ) ;
_is_fifo = S_ISFIFO( buf.st_mode ) ;
}
}
} // namespace
/** \file
Implementation of FilePath.
*/
/*
Zipios++ - a small C++ library that provides easy access to .zip files.
Copyright (C) 2000 Thomas Søndergaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/