FreeNOS
Public Member Functions | Private Member Functions
Cat Class Reference

Concatenate files to standard output. More...

#include <Cat.h>

Inheritance diagram for Cat:
POSIXApplication Application

Public Member Functions

 Cat (int argc, char **argv)
 Constructor. More...
 
virtual ~Cat ()
 Destructor. More...
 
virtual Result initialize ()
 Initialize the application. More...
 
virtual Result exec ()
 Execute the application. More...
 
- Public Member Functions inherited from POSIXApplication
 POSIXApplication (int argc, char **argv)
 Class constructor. More...
 
virtual ~POSIXApplication ()
 Class destructor. More...
 
- Public Member Functions inherited from Application
 Application (int argc, char **argv)
 Class constructor. More...
 
virtual ~Application ()
 Class destructor. More...
 
virtual int run ()
 Run the application. More...
 

Private Member Functions

Result cat (const char *file) const
 Concatenate a file. More...
 

Additional Inherited Members

- Public Types inherited from Application
enum  Result {
  Success, NotFound, IOError, InvalidArgument,
  ShowUsage, TimedOut, OutOfMemory
}
 Result codes. More...
 
- Protected Member Functions inherited from POSIXApplication
virtual Result output (const char *string) const
 Print text to output. More...
 
int runProgram (const char *path, const char **argv)
 Runs an external program. More...
 
- Protected Member Functions inherited from Application
virtual Result output (String &string) const
 Print string to output. More...
 
ArgumentParserparser ()
 Get program arguments parser. More...
 
const ArgumentParserparser () const
 Get constant program arguments parser. More...
 
const ArgumentContainerarguments () const
 Get program arguments. More...
 
void setVersion (const String &version)
 Set program version. More...
 
- Protected Attributes inherited from Application
int m_argc
 Input argument count. More...
 
char ** m_argv
 Input argument values. More...
 

Detailed Description

Concatenate files to standard output.

Definition at line 31 of file Cat.h.

Constructor & Destructor Documentation

◆ Cat()

Cat::Cat ( int  argc,
char **  argv 
)

Constructor.

Parameters
argcArgument count
argvArgument values

Definition at line 27 of file Cat.cpp.

References Application::parser(), ArgumentParser::registerPositional(), and ArgumentParser::setDescription().

◆ ~Cat()

Cat::~Cat ( )
virtual

Destructor.

Definition at line 34 of file Cat.cpp.

Member Function Documentation

◆ cat()

Cat::Result Cat::cat ( const char *  file) const
private

Concatenate a file.

Parameters
fileName of file to concatenate
Returns
Result code

Definition at line 64 of file Cat.cpp.

References close(), DEBUG, errno, Application::InvalidArgument, Application::IOError, memset(), ArgumentParser::name(), Application::NotFound, O_RDONLY, open(), Application::parser(), printf(), read(), S_ISCHR, S_ISREG, stat::st_mode, stat(), strerror(), and Application::Success.

Referenced by exec().

◆ exec()

Cat::Result Cat::exec ( )
virtual

Execute the application.

Returns
Result code

Implements Application.

Definition at line 43 of file Cat.cpp.

References Application::arguments(), cat(), Vector< T >::count(), ArgumentContainer::getPositionals(), and Application::Success.

◆ initialize()

Cat::Result Cat::initialize ( )
virtual

Initialize the application.

Returns
Result code

Reimplemented from Application.

Definition at line 38 of file Cat.cpp.

References Application::arguments(), Vector< T >::count(), ArgumentContainer::getPositionals(), Application::ShowUsage, and Application::Success.


The documentation for this class was generated from the following files: