diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2008-01-14 12:17:39 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2008-01-14 12:17:39 +0000 |
commit | 2fb5b413c1e96efd9fdc5608dbdbede6caf8be18 (patch) | |
tree | 39041f4cb8aca07e25c632aac0a93bad00eb157f | |
parent | 0910552e77deba1ca4f71a17f1a7ae26e7405a2a (diff) |
INTEGRATION: CWS qadev31 (1.6.38); FILE MERGED
2007/09/18 09:47:22 lla 1.6.38.2: #144950# handle not existant fix references
2007/09/14 10:00:33 lla 1.6.38.1: #144950#
-rw-r--r-- | qadevOOo/runner/convwatch/FileHelper.java | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/qadevOOo/runner/convwatch/FileHelper.java b/qadevOOo/runner/convwatch/FileHelper.java index 35dbeca2f6de..8ebfb42e395c 100644 --- a/qadevOOo/runner/convwatch/FileHelper.java +++ b/qadevOOo/runner/convwatch/FileHelper.java @@ -4,9 +4,9 @@ * * $RCSfile: FileHelper.java,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: obo $ $Date: 2006-01-19 14:18:01 $ + * last change: $Author: ihi $ $Date: 2008-01-14 13:17:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -201,8 +201,21 @@ public class FileHelper // public static void makeDirectories(String first, String path) { - String already_done = null; + makeDirectories(first, path, "0777"); + } + + public static void makeDirectories(String first, String path, String _sMode) + { String fs = System.getProperty("file.separator"); + if (path.startsWith(fs + fs)) // starts with UNC Path + { + int n = path.indexOf(fs, 2); + n = path.indexOf(fs, n + 1); + first = path.substring(0, n); + path = path.substring(n + 1); + } + + String already_done = null; StringTokenizer path_tokenizer = new StringTokenizer(path,fs,false); already_done = first; while (path_tokenizer.hasMoreTokens()) @@ -213,10 +226,29 @@ public class FileHelper // System.out.println(already_done); //create the directory new_dir.mkdirs(); + if (OSHelper.isUnix() && + _sMode.length() > 0) + { + try + { + chmod(new_dir, _sMode); + } + catch (java.io.IOException e) + { + GlobalLogWriter.get().println("Exception caught. FileHelper.makeDirectories('" + new_dir.getAbsolutePath() + "')"); + } + } } // return; } + public static void chmod(File file, String mode) throws java.io.IOException + { + Runtime.getRuntime().exec + (new String[] + {"chmod", mode, file.getAbsolutePath()}); + } + public static String removeFirstDirectorysAndBasenameFrom(String _sName, String _sRemovePath) { // pre: _sName: /a/b/c/d/e/f.g _sRemovePath /a/b/c @@ -282,13 +314,14 @@ public class FileHelper } else if (_sFileURL.startsWith("file://")) { - sSystemFile = _sFileURL.substring(7); + sSystemFile = _sFileURL.substring(5); } String fs = System.getProperty("file.separator"); if (! fs.equals("/")) { sSystemFile = sSystemFile.replace ('/', fs.toCharArray ()[0]); } +// FEATURE FOR UNC NEED!!! return sSystemFile; } @@ -315,4 +348,28 @@ public class FileHelper return bDebug; } + public static void copy(String _sSource, String _sDestination) + { + try + { + File inputFile = new File(_sSource); + File outputFile = new File(_sDestination); + + java.io.FileReader in = new java.io.FileReader(inputFile); + java.io.FileWriter out = new java.io.FileWriter(outputFile); + int c; + + while ((c = in.read()) != -1) + out.write(c); + + in.close(); + out.close(); + } + catch (java.io.IOException e) + { + GlobalLogWriter.get().println("Exception caught. FileHelper.copy('" + _sSource + ", " + _sDestination + "')"); + GlobalLogWriter.get().println("Message: " + e.getMessage()); + } + } } + |