irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_path_recursion.hpp
Go to the documentation of this file.
1 #ifndef IRODS_PATH_RECURSION_HPP
2 #define IRODS_PATH_RECURSION_HPP
3 
4 #include "rodsPath.h"
5 #include "parseCommandLine.h"
6 
7 #include <string>
8 #include <sstream>
9 #include <map>
10 #include <iomanip>
11 #include <chrono>
12 
13 #include <boost/filesystem.hpp>
14 
15 namespace irods
16 {
17  // When a directory structure is walked before the icommand
18  // operation, only a single occurrence of the canonical path
19  // is allowed.
20  typedef std::map< std::string, std::string > recursion_map_t;
21 
22  // The parameter path is the user path (not yet canonical).
23  // Returns true if the user path is a directory which has not
24  // yet been examined, or, throws an irods::exception if the path has
25  // already been examined (it's in the set<> already).
26  // The bool paramter is true if the "--link" flag was specified
27  bool is_path_valid_for_recursion(boost::filesystem::path const &, recursion_map_t &, bool);
28 
29  // Called in from places where file system loop detection is not desired/needed,
30  // regardless of whether or not the recursion_map_t has been initialized by
31  // check_directories_for_loops().
32  //
33  // The rodsArguments_t object is for checking for the "--link" flag, and the
34  // character buffer is for the user filename.
35  // Checks for existence of path as a symlink or a directory.
36  // Will throw irods::exception if boost fs errors occur in the process.
37  bool is_path_valid_for_recursion( rodsArguments_t const * const, const char * );
38 
39  // Throws an irods::exception if a file system loop was detected
40  void check_for_filesystem_loop(boost::filesystem::path const &, // Canonical path
41  boost::filesystem::path const &, // user path (just for emitting decent exception messages)
42  recursion_map_t &);
43 
44  // This is what the icommand xxxxUtil() function uses to scan recursively
45  // for directories/symlinks. The path is the user's non-canonical path, and
46  // the recursion_map_t is statically defined by the caller as needed.
47  // The bool paramter is true if the "--link" flag was specified
48  int check_directories_for_loops( boost::filesystem::path const &, irods::recursion_map_t &, bool);
49 
50  // Issue 3988: For irsync and iput mostly, scan all source physical directories
51  // for loops before doing any actual file transfers. Returns a 0 for success or
52  // rodsError error (< 0). The bool specifies whether the "--link" flag was specified.
53  int scan_all_source_directories_for_loops(irods::recursion_map_t &, const std::vector<std::string>&, bool);
54 
55  // This function does the filesystem loop and sanity check
56  // for both irsync and iput
58  rodsArguments_t const * const,
59  rodsPathInp_t const * const);
60 
61  // Issue 4006: disallow mixed files and directory sources with the
62  // recursive (-r) option.
63  int disallow_file_dir_mix_on_command_line( rodsArguments_t const * const rodsArgs,
64  rodsPathInp_t const * const rodsPathInp );
65 
66  // exporting this env variable will actually allow the scantime result to be printed
67  static const char *chrono_env = "IRODS_SCAN_TIME";
68 
69  class scantime
70  {
71  public:
72  explicit scantime();
73  virtual ~scantime();
74  std::string get_duration_string() const;
75  private:
76  std::chrono::time_point<std::chrono::high_resolution_clock> start_;
77  };
78 } // namespace irods
79 
80 #endif // IRODS_PATH_RECURSION_HPP
irods::scan_all_source_directories_for_loops
int scan_all_source_directories_for_loops(irods::recursion_map_t &, const std::vector< std::string > &, bool)
Definition: irods_path_recursion.cpp:255
rodsPath.h
rodsArguments_t
Definition: parseCommandLine.h:14
irods::scantime::~scantime
virtual ~scantime()
Definition: irods_path_recursion.cpp:406
irods::chrono_env
static const char * chrono_env
Definition: irods_path_recursion.hpp:67
irods::disallow_file_dir_mix_on_command_line
int disallow_file_dir_mix_on_command_line(rodsArguments_t const *const rodsArgs, rodsPathInp_t const *const rodsPathInp)
Definition: irods_path_recursion.cpp:354
RodsPathInp
Definition: rodsPath.h:33
irods::scantime
Definition: irods_path_recursion.hpp:70
irods::scantime::get_duration_string
std::string get_duration_string() const
Definition: irods_path_recursion.cpp:410
parseCommandLine.h
irods
Definition: apiHandler.hpp:35
irods::scantime::start_
std::chrono::time_point< std::chrono::high_resolution_clock > start_
Definition: irods_path_recursion.hpp:76
irods::file_system_sanity_check
int file_system_sanity_check(irods::recursion_map_t &, rodsArguments_t const *const, rodsPathInp_t const *const)
Definition: irods_path_recursion.cpp:282
irods::is_path_valid_for_recursion
bool is_path_valid_for_recursion(boost::filesystem::path const &, recursion_map_t &, bool)
Definition: irods_path_recursion.cpp:80
irods::check_directories_for_loops
int check_directories_for_loops(boost::filesystem::path const &, irods::recursion_map_t &, bool)
Definition: irods_path_recursion.cpp:200
irods::scantime::scantime
scantime()
Definition: irods_path_recursion.cpp:402
irods::check_for_filesystem_loop
void check_for_filesystem_loop(boost::filesystem::path const &, boost::filesystem::path const &, recursion_map_t &)
Definition: irods_path_recursion.cpp:29
irods::recursion_map_t
std::map< std::string, std::string > recursion_map_t
Definition: irods_path_recursion.hpp:20