This file is indexed.

/usr/include/pegtl/internal/file_mapper.hh is in pegtl-dev 1.3.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2014-2015 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/ColinH/PEGTL/

#ifndef PEGTL_INTERNAL_FILE_MAPPER_HH
#define PEGTL_INTERNAL_FILE_MAPPER_HH

#include <unistd.h>
#include <sys/mman.h>

#include "file_opener.hh"
#include "../input_error.hh"

namespace pegtl
{
   namespace internal
   {
      class file_mapper
      {
      public:
         explicit
         file_mapper( const std::string & filename )
               : file_mapper( file_opener( filename ) )
         { }

         explicit
         file_mapper( const file_opener & reader )
               : m_size( reader.size() ),
                 m_data( static_cast< const char * >( ::mmap( 0, m_size, PROT_READ, MAP_FILE | MAP_PRIVATE, reader.m_fd, 0 ) ) )
         {
            if ( intptr_t( m_data ) == -1 ) {
               PEGTL_THROW_INPUT_ERROR( "unable to mmap() file " << reader.m_source << " descriptor " << reader.m_fd );
            }
         }

         ~file_mapper()
         {
            ::munmap( const_cast< char * >( m_data ), m_size );  // Legacy C interface requires pointer-to-mutable but does not write through the pointer.
         }

         file_mapper( const file_mapper & ) = delete;
         void operator= ( const file_mapper & ) = delete;

         bool empty() const
         {
            return m_size == 0;
         }

         std::size_t size() const
         {
            return m_size;
         }

         using iterator = const char *;
         using const_iterator = const char *;

         iterator data() const
         {
            return m_data;
         }

         iterator begin() const
         {
            return m_data;
         }

         iterator end() const
         {
            return m_data + m_size;
         }

         std::string string() const
         {
            return std::string( m_data, m_size );
         }

      private:
         const std::size_t m_size;
         const char * const m_data;
      };

   } // internal

} // pegtl

#endif