#include #include #include #include #include #include #include #include #include int remove_links(const std::string path, const std::string dirl, int timer) { // removes hard links in directory "dirl" to file "path" // in directory "dir", if they are older than "time" seconds. // Method: // using readdir, examine all components of dirl and see // if they have the same inode as "path". If so, remove, unless // the realname is the same as the realname of "path" // DIR *pdir; struct dirent *pent; int rc; struct stat buf; pdir = opendir(dirl.c_str()); if (!pdir) { std::cerr << "Cannot read link directory '"<d_name; if (name == ".") continue; if (name == "..") continue; realpath((dirl+"/"+name).c_str(),rpathc); rpath1 = rpathc; std::cerr<<"TD: looking at '"< buf.st_mtime + timer) { int rc = unlink(rpath1.c_str()); if (rc == 0) std::cerr<<"Unlinked '"<