This file is indexed.

/usr/include/synfig-1.0/synfig/filesystem.h is in libsynfig-dev 1.2.1-0ubuntu4.

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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* === S Y N F I G ========================================================= */
/*!	\file filesystem.h
**	\brief FileSystem
**
**	$Id$
**
**	\legal
**	......... ... 2013 Ivan Mahonin
**
**	This package is free software; you can redistribute it and/or
**	modify it under the terms of the GNU General Public License as
**	published by the Free Software Foundation; either version 2 of
**	the License, or (at your option) any later version.
**
**	This package 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
**	General Public License for more details.
**	\endlegal
*/
/* ========================================================================= */

/* === S T A R T =========================================================== */

#ifndef __SYNFIG_FILESYSTEM_H
#define __SYNFIG_FILESYSTEM_H

/* === H E A D E R S ======================================================= */

#include <cstdio>

#include <istream>
#include <ostream>
#include <streambuf>
#include <vector>

#include <ETL/handle>

#include "string.h"

/* === M A C R O S ========================================================= */

/* === T Y P E D E F S ===================================================== */

/* === C L A S S E S & S T R U C T S ======================================= */

namespace synfig
{

	class FileSystem : public etl::shared_object
	{
	public:
		typedef etl::handle<FileSystem> Handle;
		typedef std::vector<String> FileList;

		class Stream : public etl::shared_object
		{
		public:
			typedef etl::handle<Stream> Handle;

		protected:
			FileSystem::Handle file_system_;
			Stream(FileSystem::Handle file_system);
		public:
			virtual ~Stream();
			FileSystem::Handle file_system() const { return file_system_; }
		};

		class ReadStream :
			public Stream,
			private std::streambuf,
			public std::istream
		{
		public:
			typedef etl::handle<ReadStream> Handle;

		protected:
			char buffer_;

			ReadStream(FileSystem::Handle file_system);
			virtual int underflow();
			virtual size_t internal_read(void *buffer, size_t size) = 0;

		public:
			size_t read_block(void *buffer, size_t size)
				{ return read((char*)buffer, size).gcount(); }
			bool read_whole_block(void *buffer, size_t size)
				{ return size == read_block(buffer, size); }
			template<typename T> bool read_variable(T &v)
				{ return read_whole_block(&v, sizeof(T)); }
		};

		class WriteStream :
			public Stream,
			private std::streambuf,
			public std::ostream
		{
		public:
			typedef etl::handle<WriteStream> Handle;

		protected:
			WriteStream(FileSystem::Handle file_system);
	        virtual int overflow(int ch);
			virtual size_t internal_write(const void *buffer, size_t size) = 0;

		public:
			bool write_block(const void *buffer, size_t size)
			{
				for(size_t i = 0; i < size; i++)
					if (!put(((const char*)buffer)[i]).good())
						return i;
				return size;
			}
			bool write_whole_block(const void *buffer, size_t size)
				{ return size == write_block(buffer, size); }
			bool write_whole_stream(std::streambuf &streambuf)
				{ return (*this << &streambuf).good(); }
			bool write_whole_stream(std::istream &stream)
				{ return write_whole_stream(*stream.rdbuf()); }
			bool write_whole_stream(ReadStream::Handle stream)
				{ return !stream || write_whole_stream(*(std::istream*)&(*stream)); }
			template<typename T> bool write_variable(const T &v)
				{ return write_whole_block(&v, sizeof(T)); }
		};

		class Identifier {
		public:
			FileSystem::Handle file_system;
			String filename;
			Identifier() { }
			Identifier(const FileSystem::Handle &file_system, const String &filename):
				file_system(file_system), filename(filename) { }

			bool empty() const { return file_system; }
			operator bool () const { return !empty(); }

			bool operator < (const Identifier &other) const
			{
				if (file_system.get() < other.file_system.get()) return true;
				if (other.file_system.get() < file_system.get()) return false;
				if (filename < other.filename) return true;
				if (other.filename < filename) return false;
				return false;
			}
			bool operator > (const Identifier &other) const
				{ return other < *this; }
			bool operator != (const Identifier &other) const
				{ return *this > other || other < *this; }
			bool operator == (const Identifier &other) const
				{ return !(*this != other); }

			ReadStream::Handle get_read_stream() const;
			WriteStream::Handle get_write_stream() const;
		};

		FileSystem();
		virtual ~FileSystem();

		virtual bool is_file(const String &filename) = 0;
		virtual bool is_directory(const String &filename) = 0;

		virtual bool directory_create(const String &dirname) = 0;
		virtual bool directory_scan(const String &dirname, FileList &out_files) = 0;

		virtual bool file_remove(const String &filename) = 0;
		virtual bool file_rename(const String &from_filename, const String &to_filename);
		virtual ReadStream::Handle get_read_stream(const String &filename) = 0;
		virtual WriteStream::Handle get_write_stream(const String &filename) = 0;
		virtual String get_real_uri(const String &filename);

		inline bool is_exists(const String filename) { return is_file(filename) || is_directory(filename); }

		String get_real_filename(const String &filename);
		Identifier get_identifier(const String &filename) { return Identifier(this, filename); }

		bool directory_create_recursive(const String &dirname);
		bool remove_recursive(const String &filename);

		static bool copy(Handle from_file_system, const String &from_filename, Handle to_file_system, const String &to_filename);
		static bool copy_recursive(Handle from_file_system, const String &from_filename, Handle to_file_system, const String &to_filename);

		static String fix_slashes(const String &filename);

		///!@brief Read a stream line by line even '\r\n' ended
		static std::istream& safe_get_line(std::istream& is, String& t);
	};

}

/* === E N D =============================================================== */

#endif