FreeCAD

Форк
0
/
filepath.cpp 
82 строки · 2.2 Кб
1

2
#include "zipios-config.h"
3

4
#include <stdexcept>
5
#include <string>
6
#include <sys/types.h>
7
#include <sys/stat.h>
8

9
#include "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 ) {
21
  pruneTrailingSeparator() ;
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
#if defined (__GNUC__)
38
  struct stat buf ;
39
  if ( stat( _path.c_str(), &buf ) != -1 ) {
40
#else
41
  struct _stat buf ;
42
  if ( _stat( _path.c_str(), &buf ) != -1 ) {
43
#endif
44
    _exists    = true ;
45
#if defined(BOOST_WINNT)
46
    _is_reg    = _S_IFREG & buf.st_mode ;
47
    _is_dir    = _S_IFDIR & buf.st_mode ;
48
    _is_char   = _S_IFCHR & buf.st_mode ;
49
#else
50
    _is_reg    = S_ISREG ( buf.st_mode ) ;
51
    _is_dir    = S_ISDIR ( buf.st_mode ) ;
52
    _is_char   = S_ISCHR ( buf.st_mode ) ;
53
    _is_block  = S_ISBLK ( buf.st_mode ) ;
54
    _is_socket = S_ISSOCK( buf.st_mode ) ;
55
    _is_fifo   = S_ISFIFO( buf.st_mode ) ;
56
#endif
57
  } 
58
}
59

60
} // namespace
61

62
/** \file
63
    Implementation of FilePath.
64
*/
65

66
/*
67
  Zipios++ - a small C++ library that provides easy access to .zip files.
68
  Copyright (C) 2000  Thomas Søndergaard
69
  
70
  This library is free software; you can redistribute it and/or
71
  modify it under the terms of the GNU Lesser General Public
72
  License as published by the Free Software Foundation; either
73
  version 2 of the License, or (at your option) any later version.
74
  
75
  This library is distributed in the hope that it will be useful,
76
  but WITHOUT ANY WARRANTY; without even the implied warranty of
77
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
78
  Lesser General Public License for more details.
79
  
80
  You should have received a copy of the GNU Lesser General Public
81
  License along with this library; if not, write to the Free Software
82
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
83
*/
84

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.