01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.tools;
10:
11: import java.io.File;
12: import java.io.FileReader;
13: import java.io.FileWriter;
14: import java.io.IOException;
15:
16: /**
17: * @author Andrew Suprun
18: */
19: public class ChangeCvsRoot {
20: static char[] buf = new char[100000];
21:
22: public static void main(String[] args) throws IOException {
23: if (args.length < 2) {
24: System.out
25: .println("Usage: java com.completex.objective.tools.ChangeCvsRoot <from_uri> <to_uri> [project_directory_path]\n");
26: return;
27: }
28: if (args.length > 2) {
29: handleDir(new File(args[2]), args[0], args[1]);
30: } else {
31: handleDir(new File("."), args[0], args[1]);
32: }
33: }
34:
35: private static void handleDir(File dir, String from, String to)
36: throws IOException {
37: File[] files = dir.listFiles();
38: for (int i = 0; i < files.length; i++) {
39: if (files[i].isDirectory()) {
40: handleDir(files[i], from, to);
41: } else if (files[i].getName().equals("Root")) {
42: System.out.println(dir.getCanonicalPath());
43: FileReader reader = new FileReader(files[i]);
44: int len = reader.read(buf);
45: reader.close();
46: FileWriter writer = new FileWriter(files[i]);
47: writer.write(new String(buf, 0, len).replaceFirst(from,
48: to));
49: writer.close();
50: }
51: }
52: }
53: }
|