61 if (!realpath(relname.c_str(),buf)) {
63 << relname <<
"\": " << strerror(errno) <<
emit();
71 if (!getcwd(buf,PATH_MAX)) {
73 "current working directory: " << strerror(errno) <<
emit();
80 return !pathname.empty() && pathname[0] ==
'/';
87 int res = lstat(name.c_str(),&obj_info);
89 if (S_ISLNK(obj_info.st_mode)) {
92 res = stat(name.c_str(),&obj_info);
94 if (S_ISREG(obj_info.st_mode)) {
96 }
else if (S_ISDIR(obj_info.st_mode)) {
106 mode_t mode = S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH;
112 for (
int element = 0; !result && element < elements;) {
114 result = mkdir(prefix.c_str(),mode);
115 result *= (errno != EEXIST && errno != EISDIR);
119 result = mkdir(abs_path.c_str(),mode);
120 result *= (errno != EEXIST && errno != EISDIR);
131 struct stat obj_info;
132 int res = stat(filename.c_str(),&obj_info);
134 p = obj_info.st_mode & 0777;
141 return chmod(filename.c_str(),p & 0777);
unsigned obj_type_t
Abstract type of filesystem object types.
permissions get_permissions(std::string const &filename)
void make_dir(std::string const &abs_path, bool recursive=true)
Create a directory given an absolute path name.
std::string segment(size_t start=0, size_t len=std::string::npos) const
Get a sub-sequence of the path's elements as a string.
bool is_absolute(std::string pathname)
Say whether a filename is absolute or relative.
abend_msg< 16 > abend_cant_create_dir
Report can't create directory.
abend_msg< 15 > abend_cant_get_cwd
Report can't get the current working directory.
std::string cwd()
Get the absolute real pathname of the current working directory.
chew_mode::name const name
An exemplar chew_mode::name
The tag class is inserted in a diagnostic_base to tell it to emit itself.
size_t elements() const
Get the number of elements in the path
int set_permissions(std::string const &filename, permissions p)
std::string abs_path(std::string const &filename)
Get the absolute pathname for a filename.
std::string real_path(std::string const &relname)
Get the absolute real pathname of a file or directory name.
obj_type_t obj_type(std::string const &name)
Get the type of the object putatively designated by a filename.
error_msg< 16 > error_cant_get_realpath
Report failure from realpath()
int permissions
Type of file permissions mask.
string system_error_message(unsigned errnum)
Get the system error message for a system error number.