diff options
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 56 |
1 files changed, 6 insertions, 50 deletions
diff --git a/src/utility.h b/src/utility.h index 82f52aa..b841373 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1,59 +1,15 @@ -#ifndef UTILITY_H_ -#define UTILITY_H_ +#ifndef INPUTXSLT_SRC_UTILITY_H_ +#define INPUTXSLT_SRC_UTILITY_H_ -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - -#include <cstddef> -#include <cstdio> +#include <string> +namespace xalanc_1_11 { }; namespace xalan = xalanc_1_11; -namespace { - -const int OpenFlags = O_RDONLY; -const mode_t OpenMode = S_IRUSR | S_IWUSR; - -} - namespace InputXSLT { -std::string readFile(const std::string& path) { - int descriptor( - open(path.data(), OpenFlags, OpenMode) - ); - - if ( descriptor == -1 ) { - close(descriptor); - - return "io error"; - } else { - struct stat info; - fstat(descriptor, &info); - const std::size_t size(info.st_size); - - char* const buffer(new char[size]); - - ssize_t readSize(read( - descriptor, - static_cast<void*const>(buffer), - size - )); - - close(descriptor); - - std::string content( - buffer, - readSize - ); - - delete[] buffer; - - return content; - } -} +std::string readFile(const std::string&); } -#endif // UTILITY_H_ +#endif // INPUTXSLT_SRC_UTILITY_H_ |