27 #define access _access
50 if (path.length() == 0) {
53 while (path[path.length() - 1] ==
'/' || path[path.length() - 1] ==
'\\') {
54 path.erase(path.end() - 1);
56 if (path.length() == 0) {
65 struct _stat64 fileInfo;
71 throw ProcessError(
"Cannot get file attributes for file '" + path +
"'!");
73 return (fileInfo.st_mode & S_IFMT) == S_IFDIR;
82 const std::string::size_type beg = path.find_last_of(
"\\/");
83 if (beg == std::string::npos) {
86 return path.substr(0, beg + 1);
94 }
else if (extension.empty()) {
96 }
else if (path == extension) {
98 }
else if (path.size() < extension.size()) {
99 return path + extension;
102 std::string::const_reverse_iterator it_path = path.rbegin();
103 std::string::const_reverse_iterator it_extension = extension.rbegin();
105 while (it_extension != extension.rend()) {
107 if (*it_path != *it_extension) {
108 return path + extension;
122 return retPath + path;
128 const std::string::size_type colonPos = name.find(
":");
129 return (colonPos != std::string::npos) && (colonPos > 1);
139 if (path.length() > 0 && path[0] ==
'/') {
143 if (path.length() > 0 && path[0] ==
'\\') {
146 if (path.length() > 1 && path[1] ==
':') {
149 if (path ==
"nul" || path ==
"NUL") {
158 if (filename ==
"stdout" || filename ==
"STDOUT" || filename ==
"-") {
161 if (filename ==
"stderr" || filename ==
"STDERR") {
164 if (filename ==
"nul" || filename ==
"NUL") {
176 const std::string::size_type sep_index = path.find_last_of(
"\\/");
177 if (sep_index == std::string::npos) {
178 return prefix + path;
180 return path.substr(0, sep_index + 1) + prefix + path.substr(sep_index + 1);
190 strm.write((
char*) &value,
sizeof(
int));
197 strm.write((
char*) &value,
sizeof(
double));
204 strm.write((
char*) &value,
sizeof(
char));
211 int size = (int)value.length();
212 const char* cstr = value.c_str();
214 strm.write((
char*) cstr, (std::streamsize)(
sizeof(
char)*size));
221 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
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage