Commit 867f5d98 authored by Steven Murray's avatar Steven Murray
Browse files

Added Utils::serrnoToString()

parent 32336b6f
cmake_minimum_required (VERSION 2.6)
include_directories(/usr/include/shift)
set (COMMON_LIB_SRC_FILES
ArchiveDirEntry.cpp
ArchiveDirIterator.cpp
......@@ -25,8 +27,9 @@ add_library (ctacommon SHARED
${COMMON_LIB_SRC_FILES})
target_link_libraries (ctacommon
${SQLITE3_LIBRARY_RELEASE}
castorcommon
pthread
${SQLITE3_LIBRARY_RELEASE}
uuid)
set (COMMON_UNIT_TESTS_LIB_SRC_FILES
......
......@@ -22,6 +22,7 @@
#include <attr/xattr.h>
#include <memory>
#include <shift/serrno.h>
#include <sstream>
#include <stdlib.h>
#include <strings.h>
......@@ -325,6 +326,21 @@ std::string cta::Utils::errnoToString(const int errnoValue) throw() {
}
}
//------------------------------------------------------------------------------
// serrnoToString
//------------------------------------------------------------------------------
std::string cta::Utils::serrnoToString(const int serrnoValue) throw() {
char buf[100];
if(!sstrerror_r(serrnoValue, buf, sizeof(buf))) {;
return buf;
} else {
std::ostringstream oss;
oss << "Failed to convert serrnoValue to string"
": sstrerror_r returned -1: serrnoValue=" << serrnoValue;
return oss.str();
}
}
//------------------------------------------------------------------------------
// toUint16
//------------------------------------------------------------------------------
......
......@@ -162,6 +162,18 @@ public:
*/
static std::string errnoToString(const int errnoValue) throw();
/**
* Determines the string representation of the specified SHIFT/CASTOR error
* number.
*
* Please note this method is thread safe.
*
* @param serrnoValue The serrno value.
* @return The string representation of the specified SHIFT/CASTOR error
* number.
*/
std::string serrnoToString(const int serrnoValue) throw();
/**
* Converts the specified string to an unsigned integer.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment