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.generators;
10:
11: import java.io.File;
12:
13: /**
14: * @author Gennady Krizhevsky
15: */
16: public class FileUtil {
17:
18: public static String makePath(String packageName, String destDir) {
19: // assert packageName != null;
20: // assert destDir != null;
21: File pathFile = null;
22: if ((packageName != null) && (packageName.length() > 0)) {
23: String path = packageName.replace('.', File.separatorChar);
24: pathFile = makeDir(destDir, path);
25: }
26: return pathFile == null ? "" : pathFile.getPath()
27: + File.separatorChar;
28: }
29:
30: public static String makePackage(String filePath) {
31: // assert filePath != null;
32: // assert filePath.length() > 0;
33: return filePath.replace(File.separatorChar, '.');
34: }
35:
36: public static File makeDir(String parentDir, String childPath) {
37: File pathFile;
38: if (parentDir == null)
39: pathFile = new File(childPath);
40: else {
41: pathFile = new File(parentDir, childPath);
42: }
43: boolean created = pathFile.mkdirs();
44: return pathFile;
45: }
46: }
|