}
for(set<Target *>::iterator i=clean_tgts.begin(); i!=clean_tgts.end(); ++i)
- if(FileTarget *ft = dynamic_cast<FileTarget *>(*i))
- if(ft->get_mtime())
- FS::unlink(ft->get_path());
+ {
+ logger.log("tasks", format("RM %s", (*i)->get_name()));
+ if(!dry_run)
+ (*i)->clean();
+ }
return 0;
}
Target::build_finished(success);
}
+
+void FileTarget::clean()
+{
+ if(mtime)
+ {
+ FS::unlink(path);
+ mtime = Time::TimeStamp();
+ size = 0;
+ check_rebuild();
+ }
+}
protected:
virtual void build_finished(bool);
+
+public:
+ virtual void clean();
};
#endif
else if(!link.empty() && !FS::exists(link))
mark_rebuild("Symlink does not exist");
}
+
+void InstalledFile::clean()
+{
+ if(!link.empty() && mtime)
+ FS::unlink(link);
+ FileTarget::clean();
+}
virtual Target *get_real_target();
private:
virtual void check_rebuild();
+
+public:
+ virtual void clean();
};
#endif
protected:
/** Handler for Task::signal_finished. */
virtual void build_finished(bool);
+
+public:
+ /** Removes any results of building the target. */
+ virtual void clean() { }
};
#endif