#737 Exporting Scripts to single file

This commit is contained in:
honfika@gmail.com
2015-04-06 19:51:35 +02:00
parent 0d9c648641
commit acbf5647cb
32 changed files with 397 additions and 351 deletions

View File

@@ -1,21 +1,23 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.helpers;
import java.io.File;
import java.io.IOException;
/**
*
@@ -26,15 +28,21 @@ public class Path {
public static String combine(String... paths) {
String result = "";
String separator = File.separator;
String separator = File.separator;
for (String path : paths) {
if (path.startsWith(separator)) {
result = result.substring(separator.length());
}
if (!result.endsWith(separator)) {
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
if (i > 0) {
if (path.startsWith(separator)) {
path = path.substring(separator.length());
}
if (!result.endsWith(separator)) {
result += separator;
}
}
result += path;
}
return result;
}
@@ -69,4 +77,14 @@ public class Path {
}
return ext;
}
public static void createDirectorySafe(File directory) throws IOException {
if (!directory.exists()) {
if (!directory.mkdirs()) {
if (!directory.exists()) {
throw new IOException("Cannot create directory " + directory);
}
}
}
}
}