35 #define access _access 54 if (path.length() == 0) {
57 while (path[path.length() - 1] ==
'/' || path[path.length() - 1] ==
'\\') {
58 path.erase(path.end() - 1);
60 if (path.length() == 0) {
63 return access(path.c_str(), R_OK) == 0;
72 const std::string::size_type beg = path.find_last_of(
"\\/");
73 if (beg == std::string::npos || beg == 0) {
76 return path.substr(0, beg + 1);
82 const std::string& path) {
84 return retPath + path;
90 const std::string::size_type colonPos = name.find(
":");
91 return (colonPos != std::string::npos) && (colonPos > 1);
101 if (path.length() > 0 && path[0] ==
'/') {
105 if (path.length() > 0 && path[0] ==
'\\') {
108 if (path.length() > 1 && path[1] ==
':') {
111 if (path ==
"nul" || path ==
"NUL") {
120 const std::string& basePath) {
121 if (filename ==
"stdout" || filename ==
"STDOUT" || filename ==
"-") {
124 if (filename ==
"stderr" || filename ==
"STDERR") {
127 if (filename ==
"nul" || filename ==
"NUL") {
139 const std::string::size_type sep_index = path.find_last_of(
"\\/");
140 if (sep_index == std::string::npos) {
141 return prefix + path;
143 return path.substr(0, sep_index + 1) + prefix + path.substr(sep_index + 1);
152 strm.write((
char*) &value,
sizeof(
int));
159 strm.write((
char*) &value,
sizeof(
double));
166 strm.write((
char*) &value,
sizeof(
char));
173 int size = (int)value.length();
174 const char* cstr = value.c_str();
176 strm.write((
char*) cstr, (std::streamsize)(
sizeof(
char)*size));
183 strm.write((
char*) &value,
sizeof(
SUMOTime));
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
static std::string prependToLastPathComponent(const std::string &prefix, const std::string &path)
prepend the given prefix to the last path component of the given file path
static bool isReadable(std::string path)
Checks whether the given file is readable.
static bool isSocket(const std::string &name)
Returns the information whether the given name represents a socket.
static std::ostream & writeFloat(std::ostream &strm, double value)
Writes a float binary.
static std::ostream & writeTime(std::ostream &strm, SUMOTime value)
Writes a time description binary.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
static std::string checkForRelativity(const std::string &filename, const std::string &basePath)
Returns the path from a configuration so that it is accessable from the current working directory...
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
static std::ostream & writeString(std::ostream &strm, const std::string &value)
Writes a string binary.