1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * $Id: upd-source.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
25 void copy_and_link_dir(string source, string target)
27 array files = get_dir(source);
29 foreach(files, string file)
31 string newSource = combine_path(source, file);
32 string newTarget = combine_path(target, file);
33 if (Stdio.is_dir(newSource))
35 copy_and_link_dir(newSource, newTarget);
36 } else if (Stdio.is_link(newTarget))
38 write("skipping backlink "+newTarget+"\n");
39 } else if (Stdio.is_file(newSource))
41 if (search(file, "~")!=-1)
42 write("skipping file "+newSource+"\n");
45 write("copy "+newSource+"\n to "+newTarget+"\n");
46 Stdio.cp(newSource, newTarget);
53 int main(int argc, array argv)
60 write("call with <source-dir> <target-dir>\n"+
61 "notice target-dir must alreay exist\n");
64 sSourceDir = combine_path(getcwd(), argv[1]);
65 sTargetDir = combine_path(getcwd(), argv[2]);
67 copy_and_link_dir(sSourceDir, sTargetDir);