source: trunk/lib/CacheCopyer.cc @ 1449

Last change on this file since 1449 was 1449, checked in by Peter Johansson, 8 years ago

refs #387. svncopyright no longer listens to property
svndigest:ignore. New revision (71) in test repo where
svncopyright:ignore was added to dir_to_be ignored.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: CacheCopyer.cc 1449 2011-12-22 02:11:55Z peter $
2
3/*
4  Copyright (C) 2010 Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "CacheCopyer.h"
23
24#include "Directory.h"
25#include "File.h"
26#include "NodeVisitor.h"
27#include "utility.h"
28
29#include "yat/Exception.h"
30
31#include <sstream>
32#include <string>
33
34namespace theplu {
35namespace svndigest {
36
37  CacheCopyer::CacheCopyer(const std::string& target, bool verbose)
38    : NodeVisitor(), target_(target), verbose_(verbose)
39  {}
40
41
42  bool CacheCopyer::enter(Directory& dir) 
43  {
44    if (dir.svndigest_ignore() && dir.svncopyright_ignore())
45      return false;
46
47    std::string target_dir = concatenate_path(target_, dir.local_path());
48    if (!node_exist(target_dir)) {
49      throw yat::utility::errno_error(target_dir + ": ");
50    }
51    mkdir_p(concatenate_path(target_dir, ".svndigest"));
52    return true;
53  }
54 
55
56  void CacheCopyer::leave(Directory& dir) 
57  {
58  }
59 
60
61  void CacheCopyer::visit(File& file)
62  {
63    if (file.svndigest_ignore() && file.svncopyright_ignore())
64      return;
65    std::string src_file = file.cache_name();
66    if (!node_exist(src_file))
67      return;
68    if (access_rights(src_file, "r"))
69      throw yat::utility::errno_error(src_file + ": ");
70    std::string target_file = 
71      concatenate_path(target_, directory_name(file.local_path()));
72    target_file = concatenate_path(target_file, 
73                                   ".svndigest/"+file_name(src_file));
74    if (verbose_)
75      std::cout << src_file << " -> " << target_file << "\n";
76    copy_file(src_file, target_file);
77  }
78
79}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.