Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileRemoveFilter.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/simple_filters/FileRemoveFilter.cc
11 /// @brief
12 /// @author Sarel Fleishman
13 
14 
15 //Unit Headers
18 #include <utility/tag/Tag.hh>
19 //Project Headers
20 #include <basic/Tracer.hh>
21 #include <utility/vector1.hh>
22 #include <utility/string_util.hh>
23 #include <boost/foreach.hpp>
24 #include <stdio.h>
25 #include <fstream>
26 
27 #define foreach BOOST_FOREACH
28 
29 namespace protocols{
30 namespace simple_filters {
31 
32 using namespace core;
33 using namespace core::scoring;
34 
35 static basic::Tracer TR( "protocols.simple_filters.FileRemoveFilter" );
36 
39 
41 FileRemoveFilterCreator::keyname() const { return "FileRemove"; }
42 
43 //default ctor
45 protocols::filters::Filter( "FileRemove" ),
46 delete_content_only_( false )
47 {
48  file_names_.clear();
49 }
50 
52 
53 void
55 {
56  std::string s;
57  s = tag->getOption< std::string >( "filenames" );
58  file_names( utility::string_split( s, ',' ) );
59  delete_content_only( tag->getOption< bool >( "delete_content_only", false ) );
60 }
61 
62 bool
64  using namespace std;
65  foreach( std::string const f, file_names_ ){
66  if( remove( f.c_str() ) )
67  TR<<"Successfully removed "<<f<<std::endl;
68  else
69  TR<<"File "<<f<<" not found."<<std::endl;
70  if( delete_content_only() ){
71  TR<<"Leaving 0b placeholder for file "<<f<<std::endl;
72  ofstream outfile;
73  outfile.open( f.c_str(), ios::trunc );
74  outfile.close();
75  }
76  }
77  return true;
78 }
79 
80 void
81 FileRemoveFilter::report( std::ostream & out, core::pose::Pose const & pose ) const {
82  out<<compute( pose )<<std::endl;
83 }
84 
87  return( compute( pose ) );
88 }
89 
92  core::pose::Pose const &
93 ) const {
94  return 1;
95 }
96 
99  return file_names_;
100 }
101 
102 void
104  file_names_ = f;
105 }
106 
107 }
108 }