void strip(const std::string& bundlePath) { Poco::File f(bundlePath); if (f.isDirectory()) stripDirectory(bundlePath); else if (f.isFile()) stripFile(bundlePath); }
SmallImage::SmallImage(string fileName) { mImage = imread(fileName); if (mImage.empty()) { throw * (new CannotOpenImageException(fileName)); } mName = stripExtension(stripDirectory(fileName)); }
std::string FileSystem::stripDirectory(const std::string& path) { if (pathHasDrive(path)) // check for Windows drive return stripDirectory(pathWithoutDrive(path)); else { size_t last_slash = path.find_last_of("/"); if (last_slash == std::string::npos) // No slash return path; else if (last_slash == path.size() - 1) // Trailing slash if (path.size() == 1) return "/"; else return stripDirectory(path.substr(0, path.size() - 1)); else return path.substr(last_slash + 1, std::string::npos); return ""; } }