+ inline bool
+ isSep(char c) {
+ if (c == '/') {
+ return true;
+ }
+#ifdef _WIN32
+ if (c == '\\') {
+ return true;
+ }
+#endif
+ return false;
+ }
+
+ Buffer::iterator rfindSep(void) {
+ Buffer::iterator it = buffer.end();
+
+ // Skip trailing '\0'
+ assert(it != buffer.begin());
+ --it;
+ assert(*it == '\0');
+
+ // Skip trailing separators
+ while (it != buffer.begin()) {
+ --it;
+ if (isSep(*it)) {
+ // Halt if find the root
+ if (it == buffer.begin()) {
+ return it;
+ }
+ } else {
+ break;
+ }
+ }
+
+ // Advance to the last separator
+ while (it != buffer.begin()) {
+ --it;
+ if (isSep(*it)) {
+ return it;
+ }
+ }
+
+ return buffer.end();
+ }
+
+