This file is indexed.

/usr/include/crystalspace-2.0/csutil/syspath.h is in libcrystalspace-dev 2.0+dfsg-1build1.

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
/*
    Copyright (C) 2003 by Frank Richter

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_CSSYS_SYSPATH_H__
#define __CS_CSSYS_SYSPATH_H__

#include "csextern.h"
#include "array.h"
#include "csstring.h"
#include "ref.h"
#include "util.h"
#include "iutil/stringarray.h"

/**\file
 * Paths helpers.
 */
/**\addtogroup util
 * @{
 */
/**\name Helpers to deal with native paths
 * @{
 */

class csPathsList;

/**
 * Get the installation path.
 * This returns the path where the system has been installed to.  It has a
 * limited use because mostly everything should be done through VFS which is
 * installation directory - independent; but some initialization tasks still
 * need this.  May return the empty string if unable to determine the
 * installation path.
 */
CS_CRYSTALSPACE_EXPORT csString csGetConfigPath ();

/** 
 * Get a list of directories where plugins are installed.
 * \remark Caller is responsible to free the list with delete after using it.
 */
CS_CRYSTALSPACE_EXPORT csPathsList* csGetPluginPaths (const char* argv0);

/**
 * Class to manage a list of paths.
 * \remark Entries are ensured to not have a terminating path separator.
 * \remark Empty entries ("") are allowed.
 */
class CS_CRYSTALSPACE_EXPORT csPathsList
{
public:
  /**
  * This structure contains information about a plugin path.
  */
  struct CS_CRYSTALSPACE_EXPORT Entry
  {
    /**
    * The actual path.
    */
    csString path;
    /// "Type" of the directory (e.g. app, crystal ...)
    csString type;
    /// Whether this path should be recursively scanned for plugins.
    bool scanRecursive;
    
    void FixSeparators();

    Entry () : scanRecursive (false) {}
    Entry (const char* path, const char* type, bool recursive = false)
    {
      Entry::path = path;
      FixSeparators();
      Entry::type = type;
      scanRecursive = recursive;
    };
    Entry (const Entry& src)
    {
      path = src.path;
      type = src.type;
      scanRecursive = src.scanRecursive;
    };
  };
private:
  csArray<Entry, csArrayElementHandler<Entry>, CS::Container::ArrayAllocDefault,
    csArrayCapacityFixedGrow<4> > paths;
public:
  /// Constructor.
  csPathsList ();
  /// Copy constructor.
  csPathsList (csPathsList const& o);
  /// Construct from a list of paths separated by CS_PATH_DELIMITER.
  csPathsList (const char* pathList, bool expand = false);
  /**
   * Construct from a list of single paths. The list must be terminated by a
   * 0 entry.
   */
  csPathsList (const char* const pathList[], bool expand = false);
  /// Destructor.
  ~csPathsList();
  /// Assignment operator.
  csPathsList& operator= (csPathsList const& o);

  /**
   * Add a path, but only if it isn't in the list already.
   * \param path Path to add to the list. 
   * \param scanRecursive Mark the path to be scanned recursively.
   * \param type An arbitrary string assigning a type to the directory
   *  (i.e. "app", "crystal", etc.).
   * \param overrideRecursive If the path is already in the list, just set
   *  the 'scan recursive' flag.
   * \return Index of path in the list.
   * \remark Uses csPathsIdentical() to compare paths.
   */
  size_t AddUnique (const char* path, bool scanRecursive = false, 
    const char* type = 0, bool overrideRecursive = true);
  /**
   * Add a path, but only if it isn't in the list already.
   * \copydoc AddUnique(const char*, bool, const char*, bool)
   * \remark Saves full native paths and uses csExpandPath() for this.
   */
  size_t AddUniqueExpanded (const char* path, bool scanRecursive = false, 
    const char* type = 0, bool overrideRecursive = true);
  /**
   * Add a path, but only if it isn't in the list already.
   * \param path Path to add to the list. 
   * \param overrideRecursive If the path is already in the list, just set
   *  the 'scan recursive' flag.
   * \return Index of path in the list.
   * \remark Uses csPathsIdentical() to compare paths.
   */
  size_t AddUnique (const Entry& path, bool overrideRecursive = true);
  /**
   * Add a path, but only if it isn't in the list already.
   * \copydoc AddUnique(const Entry&, bool)
   * \remark Saves full native paths and uses csExpandPath() for this.
   */
  size_t AddUniqueExpanded (const Entry& path, bool overrideRecursive = true);
  /** 
   * Add entries of another path list that aren't already in this list.
   */
  void AddUnique (const csPathsList& list, bool overrideRecursive = true)
  {
    for (size_t i = 0; i < list.Length(); i++)
    {
      AddUnique (list[i], overrideRecursive);
    }
  }
  /**
   * Add a path, but only if it isn't in the list already.
   * \copydoc AddUnique(const csPathsList&, bool)
   * \remark Saves full native paths and uses csExpandPath() for this.
   */
  void AddUniqueExpanded (const csPathsList& list, 
    bool overrideRecursive = true)
  {
    for (size_t i = 0; i < list.Length(); i++)
    {
      AddUniqueExpanded (list[i], overrideRecursive);
    }
  }
  /// Remove an entry from the list.
  void DeleteIndex (size_t index);
  
  //@{
  /// Return number of contained paths.
  size_t Length () const { return paths.GetSize (); }
  size_t GetSize () const { return paths.GetSize (); }
  //@}
  CS_DEPRECATED_METHOD_MSG("Use GetSize() instead") 
  size_t GetCount () const { return Length(); }
  //@{
  /// Retrieve the n'th path record.
  Entry const& operator [] (size_t n) const { return paths[n]; }
  Entry& operator [] (size_t n) { return paths[n]; }
  //@}
  
  //@{
  /**
   * Create a list of paths where all paths are those on the left side
   * concatenated with those on the right (of course with a CS_PATH_SEPARATOR 
   * ensured to be in between).
   */
  CS_CRYSTALSPACE_EXPORT friend csPathsList operator* (const csPathsList& left,
    const csPathsList& right);
  csPathsList operator*= (const csPathsList& right);
  friend csPathsList operator* (const Entry& left, 
    const csPathsList& right);
  friend csPathsList operator* (const char* left, 
    const csPathsList& right);
  friend csPathsList operator* (const csPathsList& left, 
    const Entry& right);
  friend csPathsList operator* (const csPathsList& left, 
    const char* right);
  csPathsList operator*= (const Entry& right);
  csPathsList operator*= (const char* right);
  //@}
};

/**
 * A helper class with path-related utilities.
 */
class CS_CRYSTALSPACE_EXPORT csPathsUtilities
{
public:
  /**
   * Check whether two native paths actually point to the same location.
   * Use this instead of strcmp() or the like, as it may not suffice in all 
   * cases (e.g. on Windows paths names are case-insensitive, but on Unix
   * they aren't).
   * \remark Expects the paths to be fully qualified. Use csExpandPath() to 
   *   ensure this.
   */
  static bool PathsIdentical (const char* path1, const char* path2);
  /**
   * Expand a native path relative to the current directory.
   * \remark The specified path must refer to a directory, rather than a file.
   * \remark Caller is responsible to free the returned string with delete[] 
   *   after using it.
   */
  static char* ExpandPath (const char* path);
  
  /**
   * Determine which path(s) of a given set contains a given file.
   * \param paths List of (native) paths to check.
   * \param file Filename to search.
   * \param thorough Whether all paths should be checked. If \c false, at most
   *   only a single path, the first containing the file, is returned.
   */
  static csPathsList LocateFile (const csPathsList& paths, 
    const char* file, bool thorough = false);

  /// Filter all non-existent items out of a paths list.
  static void FilterInvalid (csPathsList& paths);

  /// Expands all paths in a path list.
  static csPathsList ExpandAll (const csPathsList& paths);
};


/**
 * A helper class containing a number of functions to deal with Crystal Space
 * installation paths.
 */
class CS_CRYSTALSPACE_EXPORT csInstallationPathsHelper
{
public:
  /**
   * Return one or more paths which themselves or whose subdirectories can 
   * contain CrystalSpace-related resources, plugins as well as common data and
   * configuration. There's no guarantee that any entry actually contains some
   * useable resource; it's up to the caller to check what resources are
   * available and to pick the appropriate entries for some purpose.
   * \remark Caller is responsible to free the list with delete after using it.
   */
  static csPathsList* GetPlatformInstallationPaths ();
  /**
   * Get the list of root directories.
   * For instance in Unix it simply returns '/' but for Windows it may return a
   * list of available drive letters.
   */
  static csRef<iStringArray> FindSystemRoots();
  /**
   * Return the absolute path of the executable.  For MacOS/X, returns the
   * absolute path of the executable within the Cocoa application wrapper.
   * \remark May return the empty string if some problem prevents determination
   *   of the application's path.
   * \remark This function is primarily intended for very low-level use before 
   *   or during the initialization of CS core components. After initialization,
   *   it is often more convenient to invoke iCommandLineParser::GetAppPath().
   * \param argv0 The first element of the argv[] array passed to main().  On
   *   many platforms, this is the only way to determine the actual location of
   *   the executable.
   */
  static csString GetAppPath (const char* argv0);
  
  /**
   * Return the directory in which the application executable resides.  For
   * MacOS/X, returns the directory in which the Cocoa application wrapper
   * resides.
   * \remark May return the empty string if some problem prevents determination
   *   of the application's directory.
   * \remark This function is primarily intended for very low-level use before 
   *   or during the initialization of CS core components. After initialization,
   *   it is often more convenient to invoke iCommandLineParser::GetAppDir().
   * \param argv0 The first element of the argv[] array passed to main().  On
   *   many platforms, this is the only way to determine the actual location of
   *   the executable.
   */
  static csString GetAppDir (const char* argv0);
  
  /**
   * Return the directory in which the application's resources reside.  On
   * many platforms, resources (such as plugin modules) reside in the same
   * directory as the application itself.  The default implementation
   * returns the same value as csGetAppPath(), however platforms may want to
   * override the default implementation if this behavior is unsuitable.  For
   * example, on MacOS/X, for GUI applications, resources reside in the
   * "Resources" directory within the Cocoa application wrapper.
   * \remark May return the empty string if some problem prevents determination
   *   of the resource path.
   * \remark This function is primarily intended for very low-level use before 
   *   or during the initialization of CS core components. After initialization,
   *   it is often more convenient to invoke
   *   iCommandLineParser::GetResourceDir().
   * \param argv0 The first element of the argv[] array passed to main().  On
   *   many platforms, this is the only way to determine the actual location of
   *   the resources.
   */
  static csString GetResourceDir (const char* argv0);
  /** 
  * Get a list of directories where plugins are installed.
  * \remark Caller is responsible to free the list with delete after using it.
  */
  static csPathsList* GetPluginPaths (const char* argv0);
  /**
  * Constructs an executable filename given a basename.
  */
  static csString GetAppFilename (const char* basename);
};


namespace CS
{
namespace Platform
{

/// Get system specific temporary folder
CS_CRYSTALSPACE_EXPORT csString GetTempDirectory ();

/// Get file name for temporary file within specified directory
CS_CRYSTALSPACE_EXPORT csString GetTempFilename (const char* path/* = 0*/);

/**
 * Create a directory.
 * \param path Name of the directory to create.
 * \returns 0 on success, or an error code in case of failure.
 *   (This is the error code the standard \c mkdir function would retutn in
 *   \c errno).
 */
CS_CRYSTALSPACE_EXPORT int CreateDirectory (const char* path);

}
}


/** @} */
/** @} */

#endif