This file is indexed.

/usr/include/tulip/TulipProject.h is in libtulip-dev 4.6.0dfsg-2+b5.

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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/*
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux
 *
 * Tulip 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 3
 * of the License, or (at your option) any later version.
 *
 * Tulip 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.
 *
 */

#ifndef TULIPPROJECT_H
#define TULIPPROJECT_H

#include <QDir>
#include <QString>
#include <QStringList>
#include <QDate>
#include <QObject>
#include <QIODevice>

#include <tulip/tulipconf.h>

#include <fstream>

namespace tlp {

class PluginProgress;

/**
  @ingroup Plugins

  @brief The TulipProject object handles the content of a Tulip project.

  All tulip projects contain a set of defined static meta-information:
  @list
  @li name (QString): the name of the project
  @li description (QString): Comments about the project
  @li author (QString): the author of the project
  @li perspective (QString): the name of the perspective plugin associated to the project
  @li date (QDate): the date of project's last modification
  @li version (QString): the version of the Tulip project format
  @endlist

  Alongside this information, one can store any kind of file into a Tulip project. Since a project is meant to be associated to a specific perspective, the responisbility of those file
  is left to the perspective.

  A TulipProject DOES NOT automatically save to disk. One will have to call the write() method to serialize data.
  @warning Precise implementation of the TulipProject object should NOT be known or used by the user since it could be subject to changes.

  If something wrong happens when calling a method from TulipProject, this method will return either false or a invalid result (see specific method documentation). The last error message can be retrieved with the lastError() method.

  After opening and before saving a project, user will be able to list/delete files and directories available in the project and open them using std filestreams or Qt's QIODevice.
  Files can be opened using the stdFileStram and fileStream methods. They will always be opened in Read/Write mode.

  Files in a tulip project are identified by their path. Those path ar similar to the path of a standard file system and use the "/" character as a separator.
  The root directory is identified by "/".

  @warning TulipProject paths ALWAYS use the "/" character as a directory separator. This is OS-independant.

  @note A file called graph.tlp located at the top-level directory will be identified by the "/graph.tlp" path while the file "graph.tlp" located in the "data" directory will be identified by "/data/graph.tlp".
  */
class TLP_QT_SCOPE TulipProject: public QObject {
  Q_OBJECT

  TulipProject();
  TulipProject(const QString &);
public:

  virtual ~TulipProject();

  /**
    @brief Starts a new TulipProject from scratch

    This method builds up a new TulipProject file without taking any input.
    @see openProject()
    */
  static TulipProject *newProject();

  /**
    @brief Opens a previously saved tulip project file and returns the corresponding project

    This method will unpack a tulip project file into some directory and allow the user to manipulate the files.
    @see TulipProject::save()
    @param file The file to open.
    @param progress A progress handler.
    @return a pointer to a TulipProject object.
    */
  static TulipProject *openProject(const QString &file, tlp::PluginProgress *progress=NULL);

  /**
    @brief Opens a previously saved tulip project file

    This method will unpack a tulip project file into some directory and allow the user to manipulate the files.
    @see TulipProject::save()
    @param file The file to open.
    @param progress A progress handler.
    @return true if the file has been successfully opened
    */
  bool openProjectFile(const QString &file, tlp::PluginProgress *progress=NULL);

  /**
    @brief Restores a project which has already been extracted into path

    @warning Using several TulipProject instances on the same directory may result in undefined behavior. This method should only be used for crash handling purposes.
    @param path The path where the archive was previously extracted
    @return a pointer to a TulipProject object.
    */
  static TulipProject *restoreProject(const QString &path);


  /**
    @brief Writes files in the TulipProject into a packed archive.

    This method packs every file in the project into a single archive.
    @note This method DOES NOT close the project. It only  commits changes to the specified file. A TulipProject is only closed when destroyed.
    @param file Absolute path where files should be packed.
    @param progress A progress handler
    @return False if method failed
    */
  bool write(const QString &file,tlp::PluginProgress *progress=NULL);

  /**
    @brief Lists entries in a directory

    @see QDir documentation for a complete description of filtering arguments
    @param path The path to scan. @see TulipProject
    @return The list of files and directories present in the given directory
    */
  QStringList entryList(const QString &path, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort);

  /**
    @brief Lists entries in a directory

    @see QDir documentation for a complete description of filtering arguments
    @param path The path to scan. @see TulipProject
    @return The list of files and directories present in the given directory
    */
  QStringList entryList(const QString &path, const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort);

  /**
    @brief Checks if the specified file/folder exists

    @param path The path to check.
    @return true if the path exists.
    */
  bool exists(const QString &path);

  /**
    @brief Recursively creates the specified path.

    Created folders will be empty
    @return true if path was successfully created.
    */
  bool mkpath(const QString &path);

  /**
    @brief Checks if the given path is a directory.

    @param path The path to check. @see TulipProject
    @return true/false wether the path is a directory.
    */
  bool isDir(const QString &path);

  /**
    @brief Removes a file from the project.

    If the given path points to a directory, or if the file does not exist, this method will fail and return false
    @param path The path to delete. @see TulipProject
    */
  bool removeFile(const QString &path);

  /**
    @brief Removes a directory from the project.

    If the given file points to a file, or if the directory does not exist, or if the directory is not empty, this method will fail and return false.
    @see removeAllDir to remove a non-empty directory.
    @param path The path to delete. @see TulipProject
    */
  bool removeDir(const QString &path);

  /**
    @brief Removes a directory and all its content from the project.

    If the given file points to a file, or if the directory does not exist, this method will fail and return false.
    @warning This will remove every file stored in the specified directory.
    @param path The path to delete. @see TulipProject
    */
  bool removeAllDir(const QString &path);

  /**
    @brief Copies a file from the local filesystem into the project

    @param source The absolute path of the file to copy
    @param destination The project path where to copy the file
    @return false if copy failed
    */
  bool copy(const QString& source, const QString& destination);

  /**
    @brief Creates a empty file

    This method is similar to the UNIX's touch shell command. Except it won't renew the file's creation date if the file already exists.
    @param file the file to create
    @return true if file creation was sucessful.
    */
  bool touch(const QString& path);

  /**
    @brief Gets a STL file stream (default to R/W access mode) to the given path.

    @warning This method does not check if the given path is a directory or a file. User might get an invalid filestream.
    @warning It is up to the user to delete the std::fstream returned.
    @param path The path to open. @see TulipProject
    @return an opened filestream on the given path.
    */
  std::fstream *stdFileStream(const QString &path, std::ios_base::openmode=std::fstream::in | std::fstream::out | std::fstream::app);

  /**
    @brief Gets a Qt I/O device (default to R/W access mode) to the given path.

    @warning This method does not check if the given path is a directory or a file. User might get an invalid filestream.
    @warning User SHOULD NOT cast the QIODevice returned by this method into any of its subclass since the implementation might change in future versions.
    @warning It is up to the user to delete the QIODevice returned.
    @param path The path to open. @see TulipProject
    @param mode The opening mode as described in the Qt documentation.
    @return an opened Qt device on the given path.
    */
  QIODevice *fileStream(const QString &path, QIODevice::OpenMode mode=QIODevice::ReadWrite);

  /**
    @brief Returns the last error raised.

    @note The returned string is null if no error was raised.
    */
  QString lastError() const {
    return _lastError;
  }

  /**
    @brief Check if the object is a valid TulipProject.

    @warning Calling methods on invalid TulipProject instances may result in undefined behavior.
    */
  bool isValid() const {
    return _isValid;
  }

  /**
    @brief Return the archive file associated with this project.

    If the project has been opened from an existing file or if the write method has already been called, this method will return the last file path specified.
    In other cases, this method will return an empty string.
    */
  QString projectFile() const {
    return _projectFile;
  }

  /**
    @brief This method returns the real absolute path corresponding to / in the TulipProject.

    This can be used to create a TulipProject directly from a path.
    @warning Using several TulipProject instances at the same time on the same path may result in undefined behavior.
    */
  QString absoluteRootPath() const;

  // Developer note: Every field in the TulipProject tagged as a Q_PROPERTY will automaticaly be serialized in the project.xml file
  /**
    @brief the name of the project
    */
  Q_PROPERTY(QString name READ name WRITE setName)
  /**
   * @see name
   */
  QString name() const;

  /**
    @brief User-written description of the project
    */
  Q_PROPERTY(QString description READ description WRITE setDescription)
  /**
   * @see description
   */
  QString description() const;

  /**
    @brief Name of the author
    */
  Q_PROPERTY(QString author READ author WRITE setAuthor)
  /**
   * @see author
   */
  QString author() const;

  /**
    @brief Name of the perspective associated to the project.

    When the user open a project from Tulip, this porperty is first read to identify find kind of perspective plugin should be launched to
    open the project

    @warning If the perspective name associated to the project is invalid or correspond to a missing plugin, tulip may not be able to open the file.
    */
  Q_PROPERTY(QString perspective READ perspective WRITE setPerspective)
  /**
   * @see perspective
   */
  QString perspective() const;

  /**
    @brief The version of the Tulip project format with which the file was created.
    Project from older format versions will always by saved into the newest version available.
    */
  QString version() const;

  /**
    @brief Returns the absolute filesystem path used to store the file
    @warning Be cautious though since directly modifying project files without using TulipProject methods could result in undefined behavior.
    */
  QString toAbsolutePath(const QString &relativePath);

signals:
  void projectFileChanged(const QString& projectFile);

public slots:
  /**
   * @see name
   */
  void setName(const QString &);
  /**
   * @see description
   */
  void setDescription(const QString &);
  /**
   * @see author
   */
  void setAuthor(const QString &);
  /**
   * @see perspective
   */
  void setPerspective(const QString &);

private:
  static QString temporaryPath();

  bool writeMetaInfos();
  bool readMetaInfos();

  bool removeAllDirPrivate(const QString &path);

  // Core fileset
  QDir _rootDir;
  QDir _dataDir;
  QString _projectFile;

  // Meta information
  QString _author;
  QString _name;
  QString _description;
  QString _perspective;

  // Error handling
  QString _lastError;
  bool _isValid;
};

}
#endif // TULIPPROJECT_H