use of java.nio.file.InvalidPathException in project knime-core by knime.
the class CreateFilenameNodeModel method handleSlash.
/**
* This method handles the slash between the base dir path and the file name.
*
* @param baseDir the directory path
* @param name the file name
* @param ext the file extension
* @return the concatenated string of all three input, or -1 if exception occurred.
*/
protected static String handleSlash(String baseDir, final String name, final String ext) {
String output = "";
try {
if (baseDir.endsWith("?")) {
baseDir = Pattern.compile("[?]+$").matcher(baseDir).replaceAll("");
}
if (!(baseDir.endsWith("/") || baseDir.endsWith("\\"))) {
if (!baseDir.toLowerCase().startsWith("knime") && IS_WINDOWS) {
output = baseDir + "\\" + name + ext;
} else {
output = baseDir + "/" + name + ext;
}
} else {
Matcher slash = Pattern.compile("[/]+$").matcher(baseDir);
if (slash.find()) {
baseDir = slash.replaceAll("") + "/";
}
slash = Pattern.compile("[\\\\]+$").matcher(baseDir);
if (slash.find()) {
baseDir = slash.replaceAll("") + "\\";
}
output = baseDir + name + ext;
}
} catch (InvalidPathException e) {
return "-1";
}
return output;
}
use of java.nio.file.InvalidPathException in project knime-core by knime.
the class CSVFilesHistoryPanel method fileLocationChanged.
private void fileLocationChanged() {
String selFile = getSelectedFile();
m_warnMsg.setText("");
if ((selFile != null) && !selFile.isEmpty()) {
try {
URL newUrl = FileUtil.toURL(selFile);
m_warnMsg.checkLocation(newUrl);
} catch (InvalidPathException ex) {
m_warnMsg.setText("Invalid file system path: " + ex.getMessage());
m_warnMsg.setForeground(Color.RED);
} catch (IOException ex) {
// ignore it
}
}
}
use of java.nio.file.InvalidPathException in project litiengine by gurkenlabs.
the class Program method handleArgs.
private static void handleArgs(String[] args) {
if (args.length == 0) {
return;
}
for (int i = 0; i < args.length; i++) {
if (args[i] == null || args[i].isEmpty()) {
continue;
}
// handle file loading
if (i == 0) {
if (args[i] == null || args[i].isEmpty()) {
continue;
}
try {
Paths.get(args[i]);
} catch (InvalidPathException e) {
continue;
}
File f = new File(args[i]);
EditorScreen.instance().load(f);
}
}
}
use of java.nio.file.InvalidPathException in project Universal-Pointer-Searcher by BullyWiiPlaza.
the class UniversalPointerSearcherGUI method restorePersistentSettings.
private void restorePersistentSettings() {
val lastAddedFilePath = persistentSettingsManager.get(LAST_ADDED_FILE_PATH.toString());
if (lastAddedFilePath != null) {
try {
this.lastAddedFilePath = Paths.get(lastAddedFilePath);
} catch (InvalidPathException exception) {
handleException(exception);
}
}
val pointerSearchDepth = persistentSettingsManager.get(POINTER_SEARCH_DEPTH.toString());
if (pointerSearchDepth != null) {
pointerSearchDepthField.setText(pointerSearchDepth);
}
val pointerValueAlignment = persistentSettingsManager.get(POINTER_VALUE_ALIGNMENT.toString());
if (pointerValueAlignment != null) {
pointerValueAlignmentField.setText(pointerValueAlignment);
}
val maximumMemoryChunkSize = persistentSettingsManager.get(MAXIMUM_MEMORY_CHUNK_SIZE.toString());
if (maximumMemoryChunkSize != null) {
maximumMemoryChunkSizeField.setText(maximumMemoryChunkSize);
}
val maximumOffset = persistentSettingsManager.get(MAXIMUM_OFFSET.toString());
if (maximumOffset != null) {
maximumPointerOffsetField.setText(maximumOffset);
}
val allowNegativeOffsets = persistentSettingsManager.get(ALLOW_NEGATIVE_OFFSETS.toString());
if (allowNegativeOffsets != null) {
val selected = parseBoolean(allowNegativeOffsets);
allowNegativeOffsetsCheckBox.setSelected(selected);
}
val singleMemoryDumpMethod = persistentSettingsManager.get(SINGLE_MEMORY_DUMP_METHOD.toString());
if (singleMemoryDumpMethod != null) {
val selected = parseBoolean(singleMemoryDumpMethod);
singleMemoryDumpMethodCheckBox.setSelected(selected);
}
val baseOffsetRange = persistentSettingsManager.get(BASE_OFFSET_RANGE.toString());
if (baseOffsetRange != null) {
val selected = parseBoolean(baseOffsetRange);
baseOffsetRangeSelection.setSelected(selected);
}
val startingBaseAddress = persistentSettingsManager.get(STARTING_BASE_ADDRESS.toString());
if (startingBaseAddress != null) {
startingBaseAddressField.setText(startingBaseAddress);
}
val endBaseAddress = persistentSettingsManager.get(END_BASE_ADDRESS.toString());
if (endBaseAddress != null) {
endBaseAddressField.setText(endBaseAddress);
}
}
use of java.nio.file.InvalidPathException in project yii2support by nvlad.
the class ViewUtil method resolveViewFromController.
@NotNull
private static ViewResolve resolveViewFromController(PhpClass clazz, String value) {
ViewResolve result = new ViewResolve(ViewResolveFrom.Controller);
final String classFQN = clazz.getFQN().replace('\\', '/');
StringBuilder key = new StringBuilder("@app");
String path = deletePathPart(classFQN);
if (path.startsWith("/modules/")) {
key.append("/modules");
path = deletePathPart(path);
}
int controllersPathPartPosition = path.indexOf("/controllers/");
if (controllersPathPartPosition == -1) {
throw new InvalidPathException(path, "Not found \"controllers\" directory.");
}
result.application = getFirstPathPart(classFQN);
if (controllersPathPartPosition > 0) {
final String module = path.substring(0, controllersPathPartPosition);
key.append(module);
path = path.substring(controllersPathPartPosition);
result.module = module;
}
path = deletePathPart(path);
key.append("/views");
if (value.startsWith("/")) {
result.key = normalizePath(key + value);
return result;
}
final String className = clazz.getName();
key.append(path, 0, path.length() - className.length());
key.append(StringUtils.CamelToId(className.substring(0, className.length() - 10), "-"));
key.append('/');
key.append(value);
result.key = normalizePath(key.toString());
return result;
}
Aggregations