~darkxst/ubuntu/quantal/gnome-shell/lp1128804

« back to all changes in this revision

Viewing changes to js/misc/fileUtils.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2012-10-09 20:42:33 UTC
  • mfrom: (57.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121009204233-chcl8989muuzfpws
Tags: 3.6.0-0ubuntu3
* debian/patches/ubuntu-lightdm-user-switching.patch
  - Fix user switching when running lightdm.  LP: #1064269
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    return file['delete'](null);
29
29
}
30
30
 
31
 
function recursivelyDeleteDir(dir) {
 
31
function recursivelyDeleteDir(dir, deleteParent) {
32
32
    let children = dir.enumerate_children('standard::name,standard::type',
33
33
                                          Gio.FileQueryInfoFlags.NONE, null);
34
34
 
39
39
        if (type == Gio.FileType.REGULAR)
40
40
            deleteGFile(child);
41
41
        else if (type == Gio.FileType.DIRECTORY)
42
 
            recursivelyDeleteDir(child);
43
 
    }
44
 
 
45
 
    deleteGFile(dir);
 
42
            recursivelyDeleteDir(child, true);
 
43
    }
 
44
 
 
45
    if (deleteParent)
 
46
        deleteGFile(dir);
 
47
}
 
48
 
 
49
function recursivelyMoveDir(srcDir, destDir) {
 
50
    let children = srcDir.enumerate_children('standard::name,standard::type',
 
51
                                             Gio.FileQueryInfoFlags.NONE, null);
 
52
 
 
53
    if (!destDir.query_exists(null))
 
54
        destDir.make_directory_with_parents(null);
 
55
 
 
56
    let info, child;
 
57
    while ((info = children.next_file(null)) != null) {
 
58
        let type = info.get_file_type();
 
59
        let srcChild = srcDir.get_child(info.get_name());
 
60
        let destChild = destDir.get_child(info.get_name());
 
61
        log([srcChild.get_path(), destChild.get_path()]);
 
62
        if (type == Gio.FileType.REGULAR)
 
63
            srcChild.move(destChild, Gio.FileCopyFlags.NONE, null, null);
 
64
        else if (type == Gio.FileType.DIRECTORY)
 
65
            recursivelyMoveDir(srcChild, destChild);
 
66
    }
46
67
}