DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
File.cpp
Go to the documentation of this file.
1/*
2 * File.cxx
3 * ers
4 *
5 * Created by Matthias Wiesmann on 04.01.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
10#include <unistd.h>
11#include <stdio.h>
12#include <libgen.h>
13#include <unistd.h>
14#include <fcntl.h>
15#include <errno.h>
16#include <assert.h>
17#include <dirent.h>
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <sys/param.h>
21#include <iostream>
22#include <sstream>
23#include <fstream>
24#include <pwd.h>
25
26#include "ers/ers.hpp"
27
28#include "okssystem/File.hpp"
31#include "okssystem/User.hpp"
32
33#define SPACE_CHAR ' '
34
35const char * const OksSystem::File::HUMAN_SIZE_STR[] = { "B", "KB", "MB", "GB" };
36const char * const OksSystem::File::HUMAN_OPEN_STR[] = { "READ", "WRITE", "NOBLOCK", "APPEND", "CREATE", "TRUNCATE","EXCLUSIVE" };
37const char * const OksSystem::File::FILE_COMMAND_PATH = "/usr/bin/file";
38const char * const OksSystem::File::FILE_FLAG_STR = "-rwxS";
39const char * const OksSystem::File::FILE_PROTOCOL = "file";
40
41
42#define READ_CHAR_CODE (OksSystem::File::FILE_FLAG_STR[1])
43#define WRITE_CHAR_CODE (OksSystem::File::FILE_FLAG_STR[2])
44#define EXECUTE_CHAR_CODE (OksSystem::File::FILE_FLAG_STR[3])
45#define NOTHING_CHAR_CODE (OksSystem::File::FILE_FLAG_STR[0])
46#define SETUID_CHAR_CODE (OksSystem::File::FILE_FLAG_STR[4])
47
48#define SLASH_CHAR '/'
49#define COLON_CHAR ':'
50#define DOT_CHAR '.'
51
52const int OksSystem::File::KILOBYTE = 1024;
53
54
55// --------------------------------------
56// Static Methods
57// --------------------------------------
58
59
66std::string OksSystem::File::protocol(const std::string &url) throw() {
67 std::string::size_type colon = url.find(COLON_CHAR);
68 if (colon==std::string::npos) return std::string();
69 return url.substr(0,colon);
70} // protocol
71
77std::string OksSystem::File::extension(const std::string &url) throw() {
78 std::string::size_type dot = url.rfind(DOT_CHAR);
79 if (dot==std::string::npos) return std::string();
80 return url.substr(dot+1);
81} // extension
82
88std::string OksSystem::File::short_name(const std::string &url) throw() {
89 std::string::size_type slash = url.rfind(SLASH_CHAR);
90 if (slash==std::string::npos) return url;
91 return url.substr(slash+1);
92} // extension
93
101std::string OksSystem::File::uri(const std::string &url) throw() {
102 std::string::size_type colon = url.find(COLON_CHAR);
103 if (colon==std::string::npos) return url;
104 return url.substr(colon+1);
105} // uri
106
107
116int OksSystem::File::depth(const std::string &path) throw() {
117 if (path[0] == SLASH_CHAR) {
118 int count = 0;
119 std::string rest = path.substr(1);
120 while(! rest.empty()) {
121 std::string::size_type slash = rest.find(SLASH_CHAR);
122 if (slash==std::string::npos) return count;
123 count++;
124 rest = rest.substr(slash+1);
125 } // while
126 return count;
127 } // path with slash
128 if (protocol(path) == FILE_PROTOCOL) {
129 return depth(uri(path));
130 } //
131 return -1;
132} // depth
133
139std::string OksSystem::File::first_line(const std::string &text) {
140 std::string::size_type nl = text.find('\n');
141 if (nl>0) return text.substr(0,nl);
142 return text;
143} // first_line
144
145
152 std::string prot = protocol(url);
153 ERS_PRECONDITION(prot==FILE_PROTOCOL);
154 const std::string path = uri(url);
155 return File(path);
156} // from_url
157
161 char *wd_buffer = getcwd(0,MAXPATHLEN);
162 if (wd_buffer) {
163 std::string directory = std::string(wd_buffer);
164 free(wd_buffer);
165 return directory;
166 }
167 std::string message("getting the current working directory");
168 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "getcwd", message.c_str() );
169} // working_directory
170
172 const char * path = dir.c_full_name();
173 const int status = ::chdir(path);
174 if (status<0) {
175 std::string message = "on directory " + dir.full_name();
176 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "chdir", message.c_str() );
177 }
178} // working_directory
179
180
185std::string OksSystem::File::expand_home(const std::string path) {
186 ERS_PRECONDITION(! path.empty());
187 ERS_PRECONDITION(path[0] == '~');
188 std::string::size_type slash = path.find('/');
189 const std::string user_name = path.substr(1,slash-1);
190 const std::string rest_path = path.substr(slash);
191 OksSystem::User user;
192 if (! user_name.empty()) {
193 user = OksSystem::User(user_name);
194 }
195 return user.home() + rest_path;
196} // home_directory
197
198
205std::string OksSystem::File::pretty_permissions(mode_t permissions) {
206 char buffer[11];
207 buffer[0] = (permissions & S_ISUID) ? SETUID_CHAR_CODE : NOTHING_CHAR_CODE;
208 buffer[1] = (permissions & S_IRUSR) ? READ_CHAR_CODE : NOTHING_CHAR_CODE;
209 buffer[2] = (permissions & S_IWUSR) ? WRITE_CHAR_CODE : NOTHING_CHAR_CODE;
210 buffer[3] = (permissions & S_IXUSR) ? EXECUTE_CHAR_CODE : NOTHING_CHAR_CODE;
211 buffer[4] = (permissions & S_IRGRP) ? READ_CHAR_CODE : NOTHING_CHAR_CODE;
212 buffer[5] = (permissions & S_IWGRP) ? WRITE_CHAR_CODE : NOTHING_CHAR_CODE;
213 buffer[6] = (permissions & S_IXGRP) ? EXECUTE_CHAR_CODE : NOTHING_CHAR_CODE;
214 buffer[7] = (permissions & S_IROTH) ? READ_CHAR_CODE : NOTHING_CHAR_CODE;
215 buffer[8] = (permissions & S_IWOTH) ? WRITE_CHAR_CODE : NOTHING_CHAR_CODE;
216 buffer[9] = (permissions & S_IXOTH) ? EXECUTE_CHAR_CODE : NOTHING_CHAR_CODE;
217 buffer[10] = '\0';
218 return std::string(buffer);
219} // pretty_permissions
220
227std::string OksSystem::File::pretty_open_flag(int flags) {
228 std::ostringstream flag_str;
229 if (flags & O_WRONLY) {
230 flag_str << HUMAN_OPEN_STR[1];
231 } else if (flags & O_RDWR) {
232 flag_str << HUMAN_OPEN_STR[0] << "-" << HUMAN_OPEN_STR[1];
233 } else {
234 flag_str << HUMAN_OPEN_STR[0];
235 }
236 if (flags & O_NONBLOCK) {
237 flag_str << "/" << HUMAN_OPEN_STR[2];
238 }
239 if (flags & O_APPEND) {
240 flag_str << "/" << HUMAN_OPEN_STR[3];
241 }
242 if (flags & O_CREAT) {
243 flag_str << "/" << HUMAN_OPEN_STR[4];
244 }
245 if (flags & O_TRUNC) {
246 flag_str << "/" << HUMAN_OPEN_STR[5];
247 }
248 if (flags & O_EXCL) {
249 flag_str << "/" << HUMAN_OPEN_STR[6];
250 }
251 flag_str << "(" << flags << ")";
252 return flag_str.str();
253} // pretty_open_permission
254
255
257 ERS_PRECONDITION(u >= 0);
258 if (u==0) return 1;
259 return KILOBYTE * unit(u-1);
260} // unit
261
271std::string OksSystem::File::pretty_size(size_t size, bool cut_small) {
272 if (0==size) return "0";
273 std::ostringstream size_str;
274 bool writen_something = false;
275 for(int i=3;i>=0;i--) {
276 const unsigned int size_unit = unit(i);
277 if (size > size_unit && ! (cut_small && writen_something)) {
278 const int amount = size / size_unit;
279 size = size % size_unit;
280 size_str << amount << SPACE_CHAR << HUMAN_SIZE_STR[i];
281 writen_something = true;
282 } // if unit is present
283 } // loop
284 return size_str.str();
285} // pretty_size
286
287// --------------------------------------
288// Constructors
289// --------------------------------------
290
291
296OksSystem::File::File(const std::string &name) {
297 set_name(name);
298} // File
299
304OksSystem::File::File(const char* c_name) {
305 ERS_PRECONDITION(c_name);
306 std::string name = std::string(c_name);
307 set_name(name);
308} // File
309
315 set_name(other.m_full_name);
316} // File
317
318// --------------------------------------
319// Operators
320// --------------------------------------
321
322
323
324OksSystem::File::operator std::string() const throw() {
325 return m_full_name;
326} // operator std::string
327
328OksSystem::File::operator const char*() const throw() {
329 return m_full_name.c_str();
330} // operator const char*
331
336OksSystem::File::operator bool() const throw() {
337 return exists();
338} // operator bool
339
347bool OksSystem::File::equals(const File &other) const throw() {
348 return (m_full_name == other.m_full_name);
349} // operator==
350
356OksSystem::File::operator size_t() const {
357 return size();
358} // operator size_t
359
360
361
362
363// --------------------------------------
364// Methods
365// --------------------------------------
366
367
380void OksSystem::File::set_name(const std::string &name) {
381 ERS_PRECONDITION(! name.empty());
382 const char c = name[0];
383 std::string long_path;
384 switch (c) {
385 case '/' :
386 long_path = name;
387 break;
388 case '~' :
389 long_path = expand_home(name);
390 break;
391 default:
392 long_path = working_directory() + "/" + name;
393 break;
394 } // switch
395 char buffer[PATH_MAX];
396 const char* result = realpath(long_path.c_str(),buffer);
397 if (result==0) { // could not resolve path
398 m_full_name = long_path;
399 } else { // we could canonicalize the path
400 m_full_name = buffer;
401 } //
402} // set_name
403
406const std::string & OksSystem::File::full_name() const throw() {
407 return m_full_name;
408} // full_name
409
412const char* OksSystem::File::c_full_name() const throw() {
413 return m_full_name.c_str();
414} // c_full_name
415
416
419std::string OksSystem::File::short_name() const throw() {
420 return short_name(m_full_name);
421} // short_name
422
427std::string OksSystem::File::parent_name() const throw() {
428 std::string::size_type size = m_full_name.size();
429 std::string::size_type slash = m_full_name.rfind(SLASH_CHAR,size-1);
430 if (slash==std::string::npos || slash==0) return ("/");
431 return m_full_name.substr(0,slash);
432} // directory
433
436std::string OksSystem::File::extension() const throw() {
437 return extension(m_full_name);
438} // extension
439
440int OksSystem::File::depth() const throw() {
441 return depth(m_full_name);
442} // depth
443
447 return File(parent_name());
448} // parent
449
450OksSystem::File OksSystem::File::child(const std::string &name) const {
451 std::string child_name = m_full_name + "/" + name;
452 return OksSystem::File(child_name);
453} // child
454
455OksSystem::File OksSystem::File::temporary(const std::string &prefix) const {
456 char *tmp_name = tempnam(m_full_name.c_str(),prefix.c_str());
457 if ( !tmp_name ) {
458 std::string message = "while creating a valid filename in directory " + m_full_name;
459 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "tempnam", message.c_str() );
460 }
461 OksSystem::File tmp_file(tmp_name);
462 free(tmp_name);
463 return tmp_file;
464} // temporary
465
466
472bool OksSystem::File::exists() const throw() {
473 struct stat file_status;
474 const int result = stat(m_full_name.c_str(),&file_status);
475 if (0==result) return true;
476 return false;
477} // exists
478
486 struct stat file_status;
487 const int result = stat(m_full_name.c_str(),&file_status);
488 if (0==result) {
489 return file_status.st_mode;
490 } // if
491 std::string message = "on file/directory " + m_full_name;
492 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "stat", message.c_str() );
493} // mode
494
495
501 mode_t mode = get_mode();
502 return (mode & 07777);
503} // permissions
504
510 return pretty_permissions(permissions());
511} // pretty_permissions
512
518std::string OksSystem::File::to_string(mode_t permissions) throw() {
519 std::ostringstream stream;
520 stream.setf(std::ios::oct,std::ios::basefield);
521 stream << permissions;
522 return stream.str();
523} // to_string
524
525
530size_t OksSystem::File::size() const {
531 struct stat file_status;
532 const int result = stat(m_full_name.c_str(),&file_status);
533 if (0==result) return file_status.st_size;
534 std::string message = "on file/directory " + m_full_name;
535 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "stat", message.c_str() );
536} // size
537
543 struct stat file_status;
544 const int result = stat(m_full_name.c_str(),&file_status);
545 if (0==result) return file_status.st_uid;
546 std::string message = "on file/directory " + m_full_name;
547 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "stat", message.c_str() );
548} // owner_id
549
551 return User(owner_id());
552} // owner
553
554
560 struct stat file_status;
561 const int result = stat(m_full_name.c_str(),&file_status);
562 if (0==result) return file_status.st_gid;
563 std::string message = "on file/directory " + m_full_name;
564 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "stat", message.c_str() );
565} // owner
566
567
574 const mode_t mode = get_mode();
575 return (mode & S_IFREG);
576} // is_regular
577
578
585 const mode_t mode = get_mode();
586 return (mode & S_IFDIR);
587} // is_regular
588
595 const mode_t mode = get_mode();
596 return (mode & S_IFIFO);
597} // is_pipe
598
599
600std::string OksSystem::File::file_type() const {
601 OksSystem::Executable file_command(FILE_COMMAND_PATH);
603 params.push_back("-b");
604 params.push_back(full_name());
605 return first_line(file_command.pipe_in(params));
606} // file_type
607
615 file_list_t file_vector;
616 DIR* directory_ptr = opendir(m_full_name.c_str());
617 if (! directory_ptr) {
618 std::string message = "on directory " + m_full_name;
619 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "opendir", message.c_str() );
620 }
621 while(true) {
622 struct dirent* directory_entry = readdir(directory_ptr);
623 if (directory_entry) {
624 const std::string name = directory_entry->d_name;
625 if ((name!=".") && (name!="..")) {
626 std::string path = m_full_name + "/" + name;
627 OksSystem::File file(path);
628 file_vector.push_back(file);
629 } // if
630 } else {
631 break;
632 } // if / else
633 } // while
634 int status = closedir(directory_ptr);
635 if (status<0) {
636 std::string message = "on directory " + m_full_name;
637 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "closedir", message.c_str() );
638 }
639 return file_vector;
640} // directory
641
647 const int result = ::unlink(m_full_name.c_str());
648 if (0==result) return;
649 throw OksSystem::RemoveFileIssue( ERS_HERE, errno, m_full_name.c_str() );
650} //unlink
651
653 const int result = ::rmdir(m_full_name.c_str());
654 if (0==result) return;
655 std::string message = "on directory " + m_full_name;
656 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "rmdir", message.c_str() );
657} // rmdir
658
659
666 if (is_directory()) {
667 file_list_t childs = directory();
668 for (file_list_t::const_iterator p=childs.begin();p!=childs.end();p++) {
669 const File f = *p;
670 if(f.exists()) {
671 f.remove();
672 }
673 } // for
674 rmdir();
675 } else {
676 unlink();
677 }
678} // remove
679
680
686void OksSystem::File::rename(const File &other) const {
687 const char *source = c_full_name() ;
688 const char *dest = other.c_full_name();
689 const int result = ::rename(source,dest);
690 if (0==result) return;
691 throw OksSystem::RenameFileIssue( ERS_HERE, errno, source, dest );
692} // rename
693
699void OksSystem::File::permissions(mode_t perm) const {
700 if(perm != permissions()) {
701 const int result = ::chmod(m_full_name.c_str(),perm);
702 if (0==result) {
703 return;
704 }
705 std::string message = "on file/directory " + m_full_name;
706 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "chmod", message.c_str());
707 }
708} // permissions
709
717void OksSystem::File::make_dir(mode_t perm) const {
718
719 errno = 0;
720 const int result = ::mkdir(m_full_name.c_str(),perm);
721 int mkdir_error = errno;
722
723 if (0==result) {
724 try {
725 permissions(perm);
726 }
727 catch (OksSystem::OksSystemCallIssue &e){
728 std::string message = "on directory " + m_full_name;
729 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "mkdir -> chmod", message.c_str() );
730 }
731 return;
732 } else {
733 if (exists()) {
734 if (is_directory()) { // already exists we attempt a chmod
735 try {
736 permissions(perm);
737 }
738 catch (OksSystem::OksSystemCallIssue &e){
739 // ignore this case...
740 }
741 return;
742 } // is directory
743 } else { // exists
744 std::string message = "on directory " + m_full_name;
745 throw OksSystem::OksSystemCallIssue(ERS_HERE, mkdir_error, "mkdir", message.c_str());
746 }
747 }
748
749} // makedir
750
761void OksSystem::File::make_path(mode_t perm) const {
762 const File father = parent();
763 if (! father.exists()) {
764 mode_t father_permission = perm | S_IRWXU;// we need rights to write sons
765 father.make_path(father_permission);
766 } // if
767 make_dir(perm);
768} // makepath
769
776void OksSystem::File::ensure_path(mode_t perm) const {
777 const File father = parent();
778 father.make_path(perm);
779} // ensure_path
780
781
786void OksSystem::File::make_fifo(mode_t perm) const {
787 if (exists()) {
788 if (is_fifo()) {
789 if(perm != permissions()) {
790 permissions(perm);
791 return;
792 } else {
793 return;
794 }
795 } // is_fifo
796 } // exists
797 const int status = ::mkfifo(m_full_name.c_str(),perm);
798 if (status==0) {
799 permissions(perm);
800 return;
801 }
802 std::string message = "while creating FIFO " + m_full_name;
803 throw OksSystem::OksSystemCallIssue( ERS_HERE, errno, "mkfifo", message.c_str() );
804} // makefifo
805
806
807
808
815std::istream* OksSystem::File::input() const {
816 try {
817 std::ifstream *stream = new std::ifstream(m_full_name.c_str());
818 stream->exceptions(std::ios::failbit | std::ios::badbit);
819 return stream;
820 } catch (std::ios_base::failure &ex) {
821 throw OksSystem::OpenFileIssue( ERS_HERE, errno, m_full_name.c_str(), ex );
822 } // catch
823} // std::istream*
824
832std::ostream* OksSystem::File::output(bool append) const {
833 try {
834 std::ios::openmode mode = std::ios::out;
835 if (append) {
836 mode |= std::ios::app;
837 }
838 std::ofstream *stream = new std::ofstream(m_full_name.c_str(),mode);
839 stream->exceptions(std::ios::failbit | std::ios::badbit);
840 return stream;
841 } catch (std::ios_base::failure &ex) {
842 throw OksSystem::OpenFileIssue( ERS_HERE, errno, m_full_name.c_str(), ex );
843 } // catch
844} // std::ostream*
845
852std::ostream& operator<<(std::ostream& stream, const OksSystem::File& file) {
853 stream << OksSystem::File::FILE_PROTOCOL << ":/" << file.full_name();
854 return stream;
855} // operator<<
856
857bool operator ==(const OksSystem::File &a, const OksSystem::File &b) throw() {
858 return a.equals(b);
859} // operator ==
860
861bool operator !=(const OksSystem::File &a, const OksSystem::File &b) throw() {
862 return ! a.equals(b);
863} // operator !=
864
865
866
867
868
#define ERS_PRECONDITION(expression)
#define SETUID_CHAR_CODE
Definition File.cpp:46
#define NOTHING_CHAR_CODE
Definition File.cpp:45
#define WRITE_CHAR_CODE
Definition File.cpp:43
#define SLASH_CHAR
Definition File.cpp:48
#define EXECUTE_CHAR_CODE
Definition File.cpp:44
#define DOT_CHAR
Definition File.cpp:50
#define READ_CHAR_CODE
Definition File.cpp:42
#define COLON_CHAR
Definition File.cpp:49
#define SPACE_CHAR
Definition File.cpp:33
std::ostream & operator<<(std::ostream &stream, const OksSystem::File &file)
Definition File.cpp:852
#define ERS_HERE
Wrapper for executable file manipulation.
std::string pipe_in(const param_collection &params) const
run the executable and pipe results back
std::vector< std::string > param_collection
Wrapper for file operations.
Definition File.hpp:32
static std::string protocol(const std::string &url)
extracts the protocol part of an url *‍/
Definition File.cpp:66
static const int KILOBYTE
number of bytes in a kilobyte *‍/
Definition File.hpp:40
std::string short_name() const
short name for file *‍/
Definition File.cpp:419
void unlink() const
deletes (unlinks) file *‍/
Definition File.cpp:646
bool is_directory() const
is the file a regular file *‍/
Definition File.cpp:584
void make_path(mode_t permissions) const
creates a full path *‍/
Definition File.cpp:761
static std::string uri(const std::string &url)
extracts the local path of an url *‍/
Definition File.cpp:101
static const char *const FILE_PROTOCOL
string for the file protocol *‍/
Definition File.hpp:46
bool exists() const
does the file exist *‍/
Definition File.cpp:472
User owner() const
owner of the file *‍/
Definition File.cpp:550
OksSystem::File parent() const
parent of the current file *‍/
Definition File.cpp:446
void rmdir() const
deletes directory *‍/
Definition File.cpp:652
file_list_t directory() const
list of file in directory *‍/
Definition File.cpp:614
std::string extension() const
extension for file *‍/
Definition File.cpp:436
mode_t permissions() const
permissions for the file *‍/
Definition File.cpp:500
std::istream * input() const
returns an input stream from the file*‍/
Definition File.cpp:815
std::string parent_name() const
path of directory containing file *‍/
Definition File.cpp:427
File(const std::string &name)
Definition File.cpp:296
static std::string pretty_open_flag(int flags)
pretty prints open flags *‍/
Definition File.cpp:227
static File from_url(const std::string &url)
build a file out of an URL *‍/
Definition File.cpp:151
static const char *const HUMAN_OPEN_STR[]
strings for pretty printing open flags *‍/
Definition File.hpp:36
std::string file_type() const
type of the file *‍/
Definition File.cpp:600
int depth() const
depth of the file *‍/
Definition File.cpp:440
static std::string first_line(const std::string &text)
extracts the first line of a text *‍/
Definition File.cpp:139
size_t size() const
size of file *‍/
Definition File.cpp:530
static int unit(int u)
calculates the value of a computer unit of order n (i.e KB,GB, etc *‍/
Definition File.cpp:256
static const char *const FILE_COMMAND_PATH
Definition File.hpp:43
static std::string to_string(mode_t permissions)
converts permission to string *‍/
Definition File.cpp:518
void ensure_path(mode_t permissions) const
creates the parent path *‍/
Definition File.cpp:776
void rename(const File &other) const
rename or moves the file *‍/
Definition File.cpp:686
void remove() const
recursively delete files and directories *‍/
Definition File.cpp:665
OksSystem::File temporary(const std::string &prefix) const
Definition File.cpp:455
static const char *const HUMAN_SIZE_STR[]
strings for pretty printing file sizes *‍/
Definition File.hpp:35
const char * c_full_name() const
Definition File.cpp:412
static std::string working_directory()
current directory of process *‍/
Definition File.cpp:160
void make_dir(mode_t permissions) const
creates a directory *‍/
Definition File.cpp:717
static std::string pretty_size(size_t size, bool cut_small)
pretty prints a file size *‍/
Definition File.cpp:271
uid_t owner_id() const
owner id of file *‍/
Definition File.cpp:542
void make_fifo(mode_t permissions) const
creates a FIFO (named pipe) *‍/
Definition File.cpp:786
bool equals(const File &other) const
compare two files *‍/
Definition File.cpp:347
OksSystem::File child(const std::string &name) const
named child of the current directory *‍/
Definition File.cpp:450
void set_name(const std::string &name)
sets the name of the file *‍/
Definition File.cpp:380
static const char *const FILE_FLAG_STR
column headers for display of permissions *‍/
Definition File.hpp:45
gid_t group() const
group of file *‍/
Definition File.cpp:559
const std::string & full_name() const
full name for file *‍/
Definition File.cpp:406
static std::string expand_home(const std::string path)
resolve home directory *‍/
Definition File.cpp:185
std::ostream * output(bool append=false) const
returns an output stream to the file*‍/
Definition File.cpp:832
mode_t get_mode() const
get mode associated with file (permission + type) *‍/
Definition File.cpp:485
std::string m_full_name
full name (path) of the file *‍/
Definition File.hpp:36
bool is_fifo() const
is the file a named pipe *‍/
Definition File.cpp:594
std::vector< OksSystem::File > file_list_t
Definition File.hpp:34
bool is_regular() const
is the file a directory *‍/
Definition File.cpp:573
std::string pretty_permissions() const
pretty permissions for the file *‍/
Definition File.cpp:509
const std::string & home() const
home directory name
Definition User.cpp:213
bool operator!=(const Host &a, const Host &b)
inequality operator
Definition Host.cpp:183
bool operator==(const Host &a, const Host &b)
equality operator
Definition Host.cpp:179