1 // ANNA - Anna is Not 'N' Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // https://bitbucket.org/testillano/anna
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_io_functions_hpp
38 #define anna_io_functions_hpp
43 #include <anna/config/defines.hpp>
44 #include <anna/core/RuntimeException.hpp>
45 #include <anna/core/util/Millisecond.hpp>
52 Grupo de metodos relacionadas con operaciones de entrada/salida
56 Crea el arbol de directorios recibido como parametro.
58 static void mkdir(const std::string& path) throw(RuntimeException);
61 Indica si el PATH recibido como parametro existe o no.
62 \return Devuelve \em true si el PATH recibido como parametro existe o \em false
65 static bool exists(const std::string& path) throw(RuntimeException) { return exists(path.c_str()); }
68 Indica si el PATH recibido como parametro existe o no.
69 \return Devuelve \em true si el PATH recibido como parametro existe o \em false
72 static bool exists(const char* path) throw(RuntimeException);
75 Indica si el PATH recibido como parametro es un directorio o no.
76 \return Devuelve \em true si el PATH recibido como parametro es un directorio o \em false
79 static bool isADirectory(const std::string& path) throw(RuntimeException) { return isADirectory(path.c_str()); }
82 Indica si el PATH recibido como parametro es un directorio o no.
83 \return Devuelve \em true si el PATH recibido como parametro es un directorio o \em false
86 static bool isADirectory(const char* path) throw(RuntimeException);
89 * Devuelve el i-nodo asociado al nombre de fichero de recibido como parámetro.
90 * \param path Ruta completa del fichero a comprobar.
91 * \return El nº de i-nodo asociado al fichero
93 static ino_t getINode(const std::string& path) throw(RuntimeException) { return getINode(path.c_str()); }
96 * Devuelve el i-nodo asociado al nombre de fichero de recibido como parámetro.
97 * \param path Ruta completa del fichero a comprobar.
98 * \return El nº de i-nodo asociado al fichero
100 static ino_t getINode(const char* path) throw(RuntimeException);
103 * Espera a que haya actividad de entrada en el fd recibido como parámetro.
104 * \param fd File descriptor sobre el que vamos a comprobar la actividad.
105 * \param timeout Número máximo de milisegundos que puede quedar a la espera. Si vale 0 no realiza ninguna espera.
106 * \return \em true si el proceso detecta actividad o \em false si se cumplió el timeout sin recibir información.
108 static bool waitInput(const int fd, const Millisecond&) throw(RuntimeException);