summaryrefslogtreecommitdiff
path: root/xsd/xsd.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/xsd.hxx')
-rw-r--r--xsd/xsd.hxx52
1 files changed, 3 insertions, 49 deletions
diff --git a/xsd/xsd.hxx b/xsd/xsd.hxx
index 43f38ea..83bfdfd 100644
--- a/xsd/xsd.hxx
+++ b/xsd/xsd.hxx
@@ -11,6 +11,7 @@
#include <cstdio> // std::remove
#include <cutl/shared-ptr.hxx>
+#include <cutl/fs/auto-remove.hxx>
#include <xsd-frontend/semantic-graph/elements.hxx> // Path
@@ -19,54 +20,7 @@
typedef std::set<NarrowString> WarningSet;
typedef std::vector<NarrowString> FileList;
-//
-//
-struct AutoUnlink
-{
- AutoUnlink (XSDFrontend::SemanticGraph::Path const& file)
- : file_ (file), canceled_ (false)
- {
- }
-
- ~AutoUnlink ()
- {
- if (!canceled_)
- std::remove (file_.native_file_string ().c_str ());
- }
-
- void
- cancel ()
- {
- canceled_ = true;
- }
-
-private:
- XSDFrontend::SemanticGraph::Path file_;
- bool canceled_;
-};
-
-//
-//
-struct AutoUnlinks
-{
- void
- add (XSDFrontend::SemanticGraph::Path const& file)
- {
- unlinks_.push_back(
- cutl::shared_ptr<AutoUnlink> (
- new (shared) AutoUnlink (file)));
- }
-
- void
- cancel ()
- {
- for (Unlinks::iterator i (unlinks_.begin ()); i != unlinks_.end (); ++i)
- (*i)->cancel ();
- }
-
-private:
- typedef std::vector<cutl::shared_ptr<AutoUnlink> > Unlinks;
- Unlinks unlinks_;
-};
+typedef cutl::fs::auto_remove AutoUnlink;
+typedef cutl::fs::auto_removes AutoUnlinks;
#endif // XSD_HXX