Go to the documentation of this file.
50 if (positionals.
count() > 0)
52 for (
Size i = 0; i < positionals.
count(); i++)
54 result =
printFiles(positionals[i]->getValue());
67 getcwd(path,
sizeof(path));
86 if (
stat(*path, &st) != 0)
107 "%s/%s", *path, dent->
d_name);
138 if (
stat(*path, &st) != 0)
161 out <<
" uid:" << st.
st_uid <<
" ";
164 out <<
" gid:" << st.
st_gid <<
" ";
167 out <<
" " << st.
st_size <<
" ";
187 out <<
basename((
char *) *path) <<
" ";
#define S_ISBLK(m)
Test for a block special file.
const char * get(const char *name) const
Get argument by name.
off_t st_size
For regular files, the file size in bytes.
#define S_ISDIR(m)
Test for a directory.
#define S_IRUSR
Read permission, owner.
The <sys/stat.h> header shall define the stat structure.
String & pad(const Size length)
Pad line with trailing whitespace.
ssize_t write(int fildes, const void *buf, size_t nbyte)
Write on a file.
C int errno
The lvalue errno is used by many functions to return error values.
uid_t st_uid
User ID of file.
Size length() const
Same as count().
char * getcwd(char *buf, size_t size)
Get the pathname of the current working directory.
int closedir(DIR *dirp)
Close a directory stream.
struct dirent * readdir(DIR *dirp)
Read a directory.
#define S_IRGRP
Read permission, group.
#define S_IWUSR
Write permission, owner.
POSIX-compatible application.
#define PATH_MAX
Maximum file path length.
const ArgumentContainer & arguments() const
Get program arguments.
DIR * opendir(const char *dirname)
Open directory associated with file descriptor.
void setDescription(const String &desc)
Set program description.
#define S_IWOTH
Write permission, others.
#define S_IXGRP
Execute/search permission, group.
#define S_ISCHR(m)
Test for a character special file.
char * basename(char *path)
Return the last component of a pathname.
virtual Result exec()
Execute the application.
Represents a directory entry.
#define S_IROTH
Read permission, others.
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.
unsigned int Size
Any sane size indicator cannot go negative.
mode_t st_mode
Mode of file.
Result printSingleFile(const String &path, String &out) const
List single file on the filesystem.
Result registerFlag(char arg, const char *name, const char *description)
Register a flag Argument.
#define S_IXUSR
Execute/search permission, owner.
int stat(const char *path, struct stat *buf)
Get file status.
virtual ~ListFiles()
Destructor.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
A type representing a directory stream.
ArgumentParser & parser()
Get program arguments parser.
#define ERROR(msg)
Output an error message.
#define S_IWGRP
Write permission, group.
gid_t st_gid
Group ID of file.
char d_name[DIRLEN]
Name of entry.
ListFiles(int argc, char **argv)
Constructor.
#define S_IXOTH
Execute/search permission, others.
Result printFiles(const String &path) const
List files on the filesystem.
int snprintf(char *buffer, unsigned int size, const char *fmt,...)
Write a formatted string into a buffer.
const Vector< Argument * > & getPositionals() const
Get positional arguments.