src/share/jaxws_classes/com/sun/tools/internal/ws/processor/util/DirectoryUtil.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  79 
  80                 // Yes, so use working directory as the root...
  81                 outputDir = new File(workingDir, packagePath);
  82 
  83                 // Make sure the directory exists...
  84                 ensureDirectory(outputDir);
  85             }
  86         }
  87 
  88         // Finally, return the directory...
  89         return outputDir;
  90     }
  91 
  92     public static String getRelativePathfromCommonBase(File file, File base) throws IOException {
  93         String basePath = base.getCanonicalPath();
  94         String filePath = file.getCanonicalPath();
  95         return filePath.substring(basePath.length());
  96 
  97     }
  98 
  99     private static void ensureDirectory(File dir)
 100         throws GeneratorException {
 101 
 102         if (!dir.exists()) {
 103             dir.mkdirs();
 104             if (!dir.exists()) {


 105                 throw new GeneratorException("generator.cannot.create.dir",
 106                     dir.getAbsolutePath());
 107             }
 108         }
 109     }
 110 }
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  79 
  80                 // Yes, so use working directory as the root...
  81                 outputDir = new File(workingDir, packagePath);
  82 
  83                 // Make sure the directory exists...
  84                 ensureDirectory(outputDir);
  85             }
  86         }
  87 
  88         // Finally, return the directory...
  89         return outputDir;
  90     }
  91 
  92     public static String getRelativePathfromCommonBase(File file, File base) throws IOException {
  93         String basePath = base.getCanonicalPath();
  94         String filePath = file.getCanonicalPath();
  95         return filePath.substring(basePath.length());
  96 
  97     }
  98 
  99     private static void ensureDirectory(File dir) throws GeneratorException {




 100         if (!dir.exists()) {
 101             boolean created = dir.mkdirs();
 102             if (!created || !dir.exists()) {
 103                 throw new GeneratorException("generator.cannot.create.dir",
 104                     dir.getAbsolutePath());
 105             }
 106         }
 107     }
 108 }