|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- // Utility.hpp
- //
- // Copyright (C) 2011 ARM Research Labs, LLC.
- // See www.armresearch.com for the copyright terms.
- //
- // This file defines the interface used by the configuration utilities.
- //
-
- #ifndef Utilityhpp_included
- #define Utilityhpp_included
-
- #include <sys/stat.h>
-
- #include <string>
-
- /// Base class for the Sniffer configuration.
- //
- // This class provides capability common to the configuration classes.
- //
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- class Utility {
-
- public:
-
- /// Default constructor.
- Utility();
-
- /// Check whether a file exists.
- //
- // \returns true if the file exists, false otherwise.
- //
- bool FileExists(std::string File);
-
- /// Copy a file.
- //
- // \param[in] From is the name of the source file.
- //
- // \param[in] To is the name of the destination file.
- //
- void Copy(std::string From, std::string To);
-
- /// Set the owner and group of the specified file.
- //
- // This function sets the owner and group of the specified file to the
- // value specified in Utility.cpp.
- //
- // \param[in] File is the specified file.
- //
- // \see SNFUserName.
- //
- // \see SNFGroupName.
- //
- void SetOwnerGroup(std::string &File);
-
- /// Set the mode of a file.
- //
- // This function sets the mode of the specified file. If an error
- // occurs, an exception is thrown.
- //
- // \param[in] File is the specified file.
- //
- // \param[in] is the mode.
- //
- void SetMode(std::string &File, mode_t mode);
-
- /// Create a directory.
- //
- // This function creates the specified directory. If an error
- // occurs, an exception is thrown.
- //
- // \param[in] Dir is the directory to create.
- //
- void MkDir(std::string &Dir);
-
- /// Check for a specified string at the beginning of a line.
- //
- // This function checks for the specified string at the beginning of a
- // line. Leading whitespace in the line is ignored.
- //
- // \param[in] Line is the line.
- //
- // \param[in] SearchString is the string to check for.
- //
- static bool CheckForString(std::string Line, std::string SearchString);
-
- /// Store the Verbose mode.
- //
- // \param[in] Mode stores the Verbose mode.
- //
- void SetVerbose(bool Mode);
-
- /// Provide verbose output?
- //
- // \returns true if the application is to provide verbose output.
- //
- bool Verbose();
-
- /// Store the Explain mode.
- //
- // \param[in] Mode stores the Explain mode.
- //
- void SetExplain(bool Mode);
-
- /// Provide an explanation of the actions only?
- //
- // \returns true if the application is to provide an explanation
- // of the actions without executing any commands.
- //
- bool Explain();
-
- /// Store the Help mode.
- //
- // \param[in] Mode stores the Help mode.
- //
- void SetHelp(bool Mode);
-
- /// Provide help?
- //
- // \returns true if the application is to output a help message.
- //
- bool Help();
-
- /// Output the end of a verbose output line.
- void OutputVerboseEnd();
-
- /// Directory separator.
- static const std::string DirectorySeparator;
-
- private:
-
- bool VerboseRequested; ///< User requested verbose processing.
-
- bool ExplainRequested; ///< User requested verbose processing but without actually executing the commands.
-
- bool HelpRequested; ///< User requested help.
-
- };
-
- #endif
|