StelFileMgr.hpp   StelFileMgr.hpp 
skipping to change at line 39 skipping to change at line 39
//! Provides utilities for locating and handling files. //! Provides utilities for locating and handling files.
//! StelFileMgr provides functions for locating files. It maintains a list of //! StelFileMgr provides functions for locating files. It maintains a list of
//! directories in which to look for files called the search path. Typciall y this //! directories in which to look for files called the search path. Typciall y this
//! includes the Stellarium installation directory, and a per-user settings //! includes the Stellarium installation directory, and a per-user settings
//! directory (on platforms which support it). //! directory (on platforms which support it).
//! The concept is that the StelFileMgr will be asked for a named path, and it //! The concept is that the StelFileMgr will be asked for a named path, and it
//! will try to locate that path within each of the search directories. //! will try to locate that path within each of the search directories.
//! @author Lippo Huhtala <lippo.huhtala@meridea.com> //! @author Lippo Huhtala <lippo.huhtala@meridea.com>
//! @author Matthew Gates <matthew@porpoisehead.net> //! @author Matthew Gates <matthew@porpoisehead.net>
//! @sa @ref fileStructure description.
class StelFileMgr class StelFileMgr
{ {
public: public:
//! @enum Flags used as named bitfield flags as specifiers to filter results of StelFileMgr methods. //! @enum Flags used as named bitfield flags as specifiers to filter results of StelFileMgr methods.
enum Flags { enum Flags {
RemovableMedia = 0x00000001, //!< Search on removable media if present (default is not to). RemovableMedia = 0x00000001, //!< Search on removable media if present (default is not to).
Writable = 0x00000002, //!< Only return writable path s. For directories this means Writable = 0x00000002, //!< Only return writable path s. For directories this means
//!< that it is possible to cr eate files within the directory. //!< that it is possible to cr eate files within the directory.
Directory = 0x00000004, //!< Exclude non-directories. Directory = 0x00000004, //!< Exclude non-directories.
File = 0x00000008, //!< Exclude non-files. File = 0x00000008, //!< Exclude non-files.
New = 0x00000010, //!< Exclude existing paths. New = 0x00000010, //!< Exclude existing paths.
Hidden = 0x00000020 //!< Include "hidden" paths (st arting with a . on POSIX systems). Hidden = 0x00000020 //!< Include "hidden" paths (st arting with a . on POSIX systems).
}; };
//! Constructor. //! Constructor.
//! By default, StelFileMgr will be created with the Stellarium inst allation directory //! By default, StelFileMgr will be created with the Stellarium inst allation directory
//! config_root in the search path. On systems which provide a per- user data/settings //! config_root in the search path. On systems which provide a per- user data/settings
//! directory (which we call the user_settings directory, this is al so included in //! directory (which we call the user_settings directory, this is al so included in
//! the search path, before the <config_root> directory. //! the search path, before the \<config_root> directory.
StelFileMgr(); StelFileMgr();
//! Destructor. //! Destructor.
~StelFileMgr(); ~StelFileMgr();
//! Search for a path within the search paths, for example "textures /fog.png". //! Search for a path within the search paths, for example "textures /fog.png".
//! findFile looks through the search paths in order, returning the first instance //! findFile looks through the search paths in order, returning the first instance
//! of the specified path. By specifying a flags parameter it is po ssible to constrain //! of the specified path. By specifying a flags parameter it is po ssible to constrain
//! the results to those matching various criteria. //! the results to those matching various criteria.
//! If the path argument is a complete path (is a full path on singl e root OSes, or //! If the path argument is a complete path (is a full path on singl e root OSes, or
//! unanbigiously identifies one and only one file on multi-root OSe s), it will //! unanbigiously identifies one and only one file on multi-root OSe s), it will
//! be tested for compliance with other conditions - the regular sea rch path will //! be tested for compliance with other conditions - the regular sea rch path will
//! not be tested. //! not be tested.
//! If you wish to search for a non-exiting file which is not in the search path //! If you wish to search for a non-exiting file which is not in the search path
//! you should explicitly prefix it with "./", or otherwise have a . at the start of //! you should explicitly prefix it with "./", or otherwise have a . at the start of
//! the path parameter, e.g. path="./my_config_file_in_the_pwd.ini" //! the path parameter, e.g. path="./my_config_file_in_the_pwd.ini"
//! @param path the name of the file to search for, for example "tex tures/fog.png". //! @param path the name of the file to search for, for example "tex tures/fog.png".
//! @param flags options which constrain the result. //! @param flags options which constrain the result.
//! @return returns a full path of the file if found, else return an empty path. //! @return returns a full path of the file if found, else return an empty path.
//! @exception std::exception what() -> "file not found: [filename]" //! @exception std::runtime_error what() -> "file not found: [filena
//! @exception std::exception what() -> "file does not match flags: me]"
[fullpath]". //! @exception std::runtime_error what() -> "file does not match fla
gs: [fullpath]".
//! This exception occurs if a full path is passes at th e path argument, but //! This exception occurs if a full path is passes at th e path argument, but
//! that path does not match the flags specified. //! that path does not match the flags specified.
QString findFile(const QString& path, const Flags& flags=(Flags)0); QString findFile(const QString& path, const Flags& flags=(Flags)0);
//! Set a set of all possible files/directories in any Stellarium se arch directory //! Set a set of all possible files/directories in any Stellarium se arch directory
//! @param path the path to search inside, e.g. "landscapes" //! @param path the path to search inside, e.g. "landscapes"
//! @param flags options which constrain the result //! @param flags options which constrain the result
//! @return returns a std::set of file and directory names (just the //! @param recursive if true, all sub-directories are walked recursi
basename, vely
//! not the whole path), which are available in any of the s //! @return returns a QSet of file and.or directory names, which are
earch available
//! paths + path. Returns empty list if none were found or //! in any of the search paths + path. Returns empty set if none we
the path re found
//! is invalid (not a directory / not existing) //! or the path is invalid (not a directory / not existing).
QSet<QString> listContents(const QString& path, const Flags& flags=( QSet<QString> listContents(const QString& path, const Flags& flags=(
Flags)0); Flags)0, bool recursive=false);
//! Get a vector of strings which describes the current search paths . //! Get a vector of strings which describes the current search paths .
//! @return returns a vector of strings representing the current sea rch paths. //! @return returns a vector of strings representing the current sea rch paths.
const QStringList& getSearchPaths(void) { return fileLocations; } const QStringList& getSearchPaths(void) { return fileLocations; }
//! Set the search paths. //! Set the search paths.
//! @param paths is a vector of strings which will become the new se arch paths //! @param paths is a vector of strings which will become the new se arch paths
void setSearchPaths(const QStringList& paths); void setSearchPaths(const QStringList& paths);
//! Check if a path exists. Note it might be a file or a directory. //! Check if a path exists. Note it might be a file or a directory.
skipping to change at line 117 skipping to change at line 118
//! if the file can be created. //! if the file can be created.
//! In the case of directories, return true if the directory can //! In the case of directories, return true if the directory can
//! have files created in it. //! have files created in it.
//! @param path to check //! @param path to check
static bool isWritable(const QString& path); static bool isWritable(const QString& path);
//! Check if a path exists and is a directory. //! Check if a path exists and is a directory.
//! @param path to check //! @param path to check
static bool isDirectory(const QString& path); static bool isDirectory(const QString& path);
//! Return the size of the file at the path.
//! @param path to file
static qint64 size(const QString& path);
//! Make a directory //! Make a directory
//! @param path the path of the directory to create. //! @param path the path of the directory to create.
//! @return true if success, else false //! @return true if success, else false
static bool mkDir(const QString& path); static bool mkDir(const QString& path);
//! Convenience function to find the parent directory of a given pat h //! Convenience function to find the parent directory of a given pat h
//! May return relative paths if the parameter is a relative path //! May return relative paths if the parameter is a relative path
//! @param path the path whose parent directory is to be returned //! @param path the path whose parent directory is to be returned
QString dirName(const QString& path); QString dirName(const QString& path);
 End of changes. 5 change blocks. 
13 lines changed or deleted 19 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/