29 #define access _access 48 if (path.length() == 0) {
51 while (path[path.length() - 1] ==
'/' || path[path.length() - 1] ==
'\\') {
52 path.erase(path.end() - 1);
54 if (path.length() == 0) {
57 return access(path.c_str(), R_OK) == 0;
66 const std::string::size_type beg = path.find_last_of(
"\\/");
67 if (beg == std::string::npos) {
70 return path.substr(0, beg + 1);
76 const std::string& path) {
78 return retPath + path;
84 const std::string::size_type colonPos = name.find(
":");
85 return (colonPos != std::string::npos) && (colonPos > 1);
95 if (path.length() > 0 && path[0] ==
'/') {
99 if (path.length() > 0 && path[0] ==
'\\') {
102 if (path.length() > 1 && path[1] ==
':') {
105 if (path ==
"nul" || path ==
"NUL") {
114 const std::string& basePath) {
115 if (filename ==
"stdout" || filename ==
"STDOUT" || filename ==
"-") {
118 if (filename ==
"stderr" || filename ==
"STDERR") {
121 if (filename ==
"nul" || filename ==
"NUL") {
133 const std::string::size_type sep_index = path.find_last_of(
"\\/");
134 if (sep_index == std::string::npos) {
135 return prefix + path;
137 return path.substr(0, sep_index + 1) + prefix + path.substr(sep_index + 1);
146 strm.write((
char*) &value,
sizeof(
int));
153 strm.write((
char*) &value,
sizeof(
double));
160 strm.write((
char*) &value,
sizeof(
char));
167 int size = (int)value.length();
168 const char* cstr = value.c_str();
170 strm.write((
char*) cstr, (std::streamsize)(
sizeof(
char)*size));
177 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.