1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
14 #include <anna/core/util/Tokenizer.hpp>
15 #include <anna/config/defines.hpp>
16 #include <anna/core/functions.hpp>
18 #include <anna/io/functions.hpp>
23 void io::functions::mkdir(const std::string& path)
24 throw(RuntimeException) {
28 tokenizer.apply(path, "/");
30 for(Tokenizer::const_iterator ii = tokenizer.begin(), maxii = tokenizer.end(); ii != maxii; ii ++) {
32 w += Tokenizer::data(ii);
34 if(io::functions::exists(w) == false) {
35 anna_signal_shield(r, ::mkdir(w.c_str(), S_IRWXU | S_IRWXG));
38 throw RuntimeException(path, errno, ANNA_FILE_LOCATION);
43 bool io::functions::exists(const char* path)
44 throw(RuntimeException) {
47 anna_signal_shield(r, stat(path, &data));
55 throw RuntimeException(path, errno, ANNA_FILE_LOCATION);
58 bool io::functions::isADirectory(const char* path)
59 throw(RuntimeException) {
62 anna_signal_shield(r, stat(path, &data));
65 throw RuntimeException(path, errno, ANNA_FILE_LOCATION);
67 return ((data.st_mode & S_IFDIR) != 0);
70 ino_t io::functions::getINode(const char* path)
71 throw(RuntimeException) {
74 anna_signal_shield(r, stat(path, &data));
77 throw RuntimeException(path, errno, ANNA_FILE_LOCATION);
83 bool io::functions::waitInput(const int fd, const Millisecond &timeout)
84 throw(RuntimeException) {
88 waiting.events = POLLIN;
89 anna_signal_shield(r, poll(&waiting, 1, timeout));
92 string msg("io::functions::waitInput: ");
93 msg += anna::functions::asString(fd);
94 throw RuntimeException(msg, errno, ANNA_FILE_LOCATION);