27 #define access _access
49 if (path.length() == 0) {
52 while (path[path.length() - 1] ==
'/' || path[path.length() - 1] ==
'\\') {
53 path.erase(path.end() - 1);
55 if (path.length() == 0) {
58 return access(path.c_str(), R_OK) == 0;
64 if (stat(path.c_str(), &fileInfo) != 0) {
65 throw ProcessError(
"Cannot get file attributes for file '" + path +
"'!");
67 return (fileInfo.st_mode & S_IFMT) == S_IFDIR;
76 const std::string::size_type beg = path.find_last_of(
"\\/");
77 if (beg == std::string::npos) {
80 return path.substr(0, beg + 1);
88 }
else if (extension.empty()) {
90 }
else if (path == extension) {
92 }
else if (path.size() < extension.size()) {
93 return path + extension;
96 std::string::const_reverse_iterator it_path = path.rbegin();
97 std::string::const_reverse_iterator it_extension = extension.rbegin();
99 while (it_extension != extension.rend()) {
101 if (*it_path != *it_extension) {
102 return path + extension;
116 return retPath + path;
122 const std::string::size_type colonPos = name.find(
":");
123 return (colonPos != std::string::npos) && (colonPos > 1);
133 if (path.length() > 0 && path[0] ==
'/') {
137 if (path.length() > 0 && path[0] ==
'\\') {
140 if (path.length() > 1 && path[1] ==
':') {
143 if (path ==
"nul" || path ==
"NUL") {
152 if (filename ==
"stdout" || filename ==
"STDOUT" || filename ==
"-") {
155 if (filename ==
"stderr" || filename ==
"STDERR") {
158 if (filename ==
"nul" || filename ==
"NUL") {
170 const std::string::size_type sep_index = path.find_last_of(
"\\/");
171 if (sep_index == std::string::npos) {
172 return prefix + path;
174 return path.substr(0, sep_index + 1) + prefix + path.substr(sep_index + 1);
184 strm.write((
char*) &value,
sizeof(
int));
191 strm.write((
char*) &value,
sizeof(
double));
198 strm.write((
char*) &value,
sizeof(
char));
205 int size = (int)value.length();
206 const char* cstr = value.c_str();
208 strm.write((
char*) cstr, (std::streamsize)(
sizeof(
char)*size));
215 strm.write((
char*) &value,
sizeof(
SUMOTime));
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
static std::ostream & writeFloat(std::ostream &strm, double value)
Writes a float binary.
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 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 addExtension(const std::string &path, const std::string &extension)
Add an extension to the given file path.
static std::ostream & writeString(std::ostream &strm, const std::string &value)
Writes a string binary.
static bool isReadable(std::string path)
Checks whether the given file is readable.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
static std::ostream & writeTime(std::ostream &strm, SUMOTime value)
Writes a time description binary.
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
static bool isSocket(const std::string &name)
Returns the information whether the given name represents a socket.
static bool isDirectory(std::string path)
Checks whether the given file is a directory.
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
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