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.*;
12:
13: /**
14: * @author Gennady Krizhevsky
15: */
16: public class CvsDos2Unix {
17: public static void main(String[] args) throws IOException {
18: if (args.length < 1) {
19: System.out
20: .println("Usage: java com.completex.objective.tools.ChangeCvsRoot [project_directory_path]\n");
21: return;
22: }
23: handleDir(new File(args[0]));
24: }
25:
26: private static void handleDir(File dir) throws IOException {
27: File[] files = dir.listFiles();
28: for (int i = 0; i < files.length; i++) {
29: if (files[i].isDirectory()) {
30: handleDir(files[i]);
31: } else if (files[i].getName().equals("Root")
32: || files[i].getName().equals("Entries")
33: || files[i].getName().equals("Repository")) {
34: System.out.println(dir.getCanonicalPath());
35: FileReader reader = new FileReader(files[i]);
36: BufferedReader bufferedReader = new BufferedReader(
37: reader);
38: File tmpFile = new File(files[i].getAbsolutePath()
39: + ".tmp");
40: if (tmpFile.exists()) {
41: boolean rc = tmpFile.delete();
42: if (!rc) {
43: System.err.println("Cannot delete temp file "
44: + tmpFile);
45: }
46: }
47: FileWriter writer = new FileWriter(tmpFile);
48: String line;
49: while ((line = bufferedReader.readLine()) != null) {
50: line = line + "\n";
51: writer.write(line);
52: writer.flush();
53: }
54: bufferedReader.close();
55: writer.close();
56: files[i].delete();
57: tmpFile.renameTo(files[i]);
58: }
59: }
60: }
61: }
|