FreeNOS
Public Member Functions | Private Member Functions
CreateFile Class Reference

Create new files on the filesystem. More...

#include <CreateFile.h>

Inheritance diagram for CreateFile:
POSIXApplication Application

Public Member Functions

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

Private Member Functions

Result createFile (const String &file) const
 Create a new empty file.
 

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.
 
int runProgram (const char *path, const char **argv)
 Runs an external program.
 
- Protected Member Functions inherited from Application
virtual Result initialize ()
 Initialize the application.
 
virtual Result output (String &string) const
 Print string to output.
 
ArgumentParser & parser ()
 Get program arguments parser.
 
const ArgumentParser & parser () const
 Get constant program arguments parser.
 
const ArgumentContainer & arguments () const
 Get program arguments.
 
void setVersion (const String &version)
 Set program version.
 
- Protected Attributes inherited from Application
int m_argc
 Input argument count.
 
char ** m_argv
 Input argument values.
 

Detailed Description

Create new files on the filesystem.

Definition at line 31 of file CreateFile.h.

Constructor & Destructor Documentation

◆ CreateFile()

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

Constructor.

Parameters
argcArgument count
argvArgument values

Definition at line 26 of file CreateFile.cpp.

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

◆ ~CreateFile()

CreateFile::~CreateFile ( )
virtual

Destructor.

Definition at line 33 of file CreateFile.cpp.

Member Function Documentation

◆ createFile()

CreateFile::Result CreateFile::createFile ( const String &  file) const
private

Create a new empty file.

Parameters
fileName of the file to create
Returns
Result code

Definition at line 60 of file CreateFile.cpp.

References creat(), errno, ERROR, Application::IOError, S_IRUSR, S_IWUSR, strerror(), and Application::Success.

Referenced by exec().

◆ exec()

CreateFile::Result CreateFile::exec ( )
virtual

Execute the application.

Returns
Result code

Implements Application.

Definition at line 37 of file CreateFile.cpp.

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


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