upd-source._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
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.
7  *
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.
12  *
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
16  *
17  * $Id: upd-source.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 class upd-source {
20 public:
21 
22 
23 
24 
25 void copy_and_link_dir(string source, string target)
26 {
27  array files = get_dir(source);
28 
29  foreach(files, string file)
30  {
31  string newSource = combine_path(source, file);
32  string newTarget = combine_path(target, file);
33  if (Stdio.is_dir(newSource))
34  {
35  copy_and_link_dir(newSource, newTarget);
36  } else if (Stdio.is_link(newTarget))
37  {
38  write("skipping backlink "+newTarget+"\n");
39  } else if (Stdio.is_file(newSource))
40  {
41  if (search(file, "~")!=-1)
42  write("skipping file "+newSource+"\n");
43  else
44  {
45  write("copy "+newSource+"\n to "+newTarget+"\n");
46  Stdio.cp(newSource, newTarget);
47  }
48  }
49  }
50 }
51 
52 
53 int main(int argc, array argv)
54 {
55  string sSourceDir;
56  string sTargetDir;
57 
58  if (argc!=3)
59  {
60  write("call with <source-dir> <target-dir>\n"+
61  "notice target-dir must alreay exist\n");
62  _exit(0);
63  }
64  sSourceDir = combine_path(getcwd(), argv[1]);
65  sTargetDir = combine_path(getcwd(), argv[2]);
66 
67  copy_and_link_dir(sSourceDir, sTargetDir);
68 }
69 
70 
71 };