# # old_revision [abed170b1da27108dc8dc5fb33729e3e9270f6f6] # # patch "src/netxx/serverbase.cxx" # from [7a9b465ce4b0b02cb8ff126acf86d3896b4eb456] # to [998f3d4723ced8d243091e416d01ab94ec2b8ffb] # ============================================================ --- src/netxx/serverbase.cxx 7a9b465ce4b0b02cb8ff126acf86d3896b4eb456 +++ src/netxx/serverbase.cxx 998f3d4723ced8d243091e416d01ab94ec2b8ffb @@ -44,6 +44,8 @@ #include "probeinfo.h" #include "socket.h" +#include + // standard includes #include #include @@ -59,6 +61,27 @@ namespace void operator() (const std::string &file) { unlink(file.c_str()); } }; + + bool get_cwd(std::string& out) + { + static const int initial_buffer_size = 1024; + int current_buffer_size = initial_buffer_size; + + do + { + std::vector buffer(current_buffer_size); + if (getcwd(&buffer[0], buffer.size()) != NULL) + { + out = &buffer[0]; + return true; + } + + current_buffer_size *= 2; + } + while(errno == ERANGE); + + return false; + } # endif } //#################################################################### @@ -167,10 +190,9 @@ void Netxx::ServerBase::bind_to(const Ad if (saun->sun_path[0] == '/') { files_.push_back(saun->sun_path); } else { - char buffer[MAXPATHLEN]; - - if (getcwd(buffer, sizeof(buffer))) { - std::string fullpath = buffer; fullpath += '/'; fullpath += saun->sun_path; + std::string fullpath; + if (get_cwd(fullpath)) { + fullpath += '/'; fullpath += saun->sun_path; files_.push_back(fullpath); } else { files_.push_back(saun->sun_path);