Go to the documentation of this file.
49 for (
Size i = 0; i < positionals.
count(); i++)
52 result =
cat(*(positionals[i]->getValue()));
71 DEBUG(
"file = " << file);
74 if (
stat(file, &st) != 0)
76 printf(
"%s: failed to stat '%s': %s\r\n",
84 printf(
"%s: not a file: '%s'\r\n", name, file);
89 memset(buf, 0,
sizeof(buf));
94 printf(
"%s: failed to open '%s': %s\r\n",
102 e =
read(fd, buf,
sizeof(buf) - 1);
107 printf(
"%s: failed to read '%s': %s\r\n",
Cat(int argc, char **argv)
Constructor.
virtual Result initialize()
Initialize the application.
The <sys/stat.h> header shall define the stat structure.
virtual ~Cat()
Destructor.
C int errno
The lvalue errno is used by many functions to return error values.
virtual Result exec()
Execute the application.
POSIX-compatible application.
const ArgumentContainer & arguments() const
Get program arguments.
int open(const char *path, int oflag,...)
Open file relative to directory file descriptor.
void setDescription(const String &desc)
Set program description.
ssize_t read(int fildes, void *buf, size_t nbyte)
Read from a file.
#define DEBUG(msg)
Output a debug message to standard output.
#define S_ISCHR(m)
Test for a character special file.
int printf(const char *format,...)
Output a formatted string to standard output.
int close(int fildes)
Close a file descriptor.
virtual Size count() const
Returns the number of items inside the Vector.
char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
#define S_ISREG(m)
Test for a regular file.
unsigned int Size
Any sane size indicator cannot go negative.
mode_t st_mode
Mode of file.
const String & name() const
Retrieve program name.
int stat(const char *path, struct stat *buf)
Get file status.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
ArgumentParser & parser()
Get program arguments parser.
void * memset(void *dest, int ch, size_t count)
Fill memory with a constant byte.
Result cat(const char *file) const
Concatenate a file.
#define O_RDONLY
Open for reading only.
const Vector< Argument * > & getPositionals() const
Get positional arguments.