// Spectre Samba Mounter // // Douglas Thrift // // Mounter.cpp #include "Mounter.h" void Mounter::mount() { samba(); if (debug) cerr << "folders = {\n"; for (map::iterator itor = folders.begin(); itor != folders.end(); itor++) { if (debug) cerr << " " << itor->first << " = {\n" << " local = " << itor->second.local << "\n" << " remote = " << itor->second.remote << "\n" << " }\n"; mount(itor->first, itor->second.local); } if (debug) cerr << "}\n"; } void Mounter::samba() { string path = config.root + "/" + host; DIR* dir = opendir(path.c_str()); dirent* file; while ((file = readdir(dir)) != NULL) { struct stat dir; string folder = path + "/" + file->d_name; stat(folder.c_str(), &dir); if (S_ISDIR(dir.st_mode)) { string folder = file->d_name; if (folder == "." || folder == "..") continue; string share = folder.find('.') == 0 ? folder.erase(0, 1) + "$" : folder; if (folders.find(share) == folders.end()) { folders.insert(pair(share, regular)); } } } closedir(dir); } void Mounter::samba(ipstream& pin) { // } void Mounter::mount(const string& folder, const string& user) { // }