~ubuntu-branches/ubuntu/quantal/deja-dup/quantal

« back to all changes in this revision

Viewing changes to common/RecursiveDelete.vala

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2012-09-25 11:00:17 UTC
  • mfrom: (1.2.1) (68.1.3 quantal)
  • Revision ID: package-import@ubuntu.com-20120925110017-m66dbx25alx9ywmg
Tags: 24.0-0ubuntu1
* New upstream release
  - Updated translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
 
2
/*
 
3
    This file is part of Déjà Dup.
 
4
    For copyright information, see AUTHORS.
 
5
 
 
6
    Déjà Dup is free software: you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation, either version 3 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    Déjà Dup is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
using GLib;
 
21
 
 
22
namespace DejaDup {
 
23
 
 
24
public class RecursiveDelete : RecursiveOp
 
25
{
 
26
  public RecursiveDelete(File source)
 
27
  {
 
28
    Object(src: source);
 
29
  }
 
30
  
 
31
  protected override void handle_file()
 
32
  {
 
33
    try {
 
34
      src.@delete(null);
 
35
    }
 
36
    catch (Error e) {
 
37
      raise_error(src, dst, e.message);
 
38
    }
 
39
  }
 
40
   
 
41
  protected override void finish_dir()
 
42
  {
 
43
    try {
 
44
      src.@delete(null); // will only be deleted if empty, so we won't
 
45
                         // accidentally toss files left over from a failed
 
46
                         // restore
 
47
    }
 
48
    catch (Error e) {
 
49
      // Ignore.  It's in /tmp, so it'll disappear, and most likely is just
 
50
      // a non-empty directory.
 
51
    }
 
52
  }
 
53
  
 
54
  protected override RecursiveOp clone_for_info(FileInfo info)
 
55
  {
 
56
    var child_name = info.get_name();
 
57
    var src_child = src.get_child(child_name);
 
58
    return new RecursiveDelete(src_child);
 
59
  }
 
60
}
 
61
 
 
62
} // namespace