Skip to content

Commit

Permalink
Merge pull request #364 from gama-platform/Fix-for-#318-(Error-in-rel…
Browse files Browse the repository at this point in the history
…ative-file-paths)

Update FileUtils.java
  • Loading branch information
lesquoyb authored Oct 28, 2024
2 parents cc31fb1 + c39d93e commit 5ff2af8
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions gama.core/src/gama/core/common/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
********************************************************************************************************/
package gama.core.common.util;

import static java.util.stream.Collectors.toList;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -19,7 +17,6 @@
import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
Expand Down Expand Up @@ -160,13 +157,14 @@ static public String constructAbsoluteFilePath(final IScope scope, final String
if (a == null) return fp;
if (!a.isHeadless()) {
// Necessary to ask the workspace for the containers as projects might be linked
final List<IContainer> paths = a.getWorkingPaths().stream()
.map(s -> ROOT.findContainersForLocation(new Path(s))[0]).collect(toList());
for (final IContainer folder : paths) {
final String file = findInWorkspace(fp, folder, mustExist);
if (file != null) {
DEBUG.OUT("Hit with workspace-based search: " + file);
return file;
for (final String folder : a.getWorkingPaths()) {
IContainer[] containers = ROOT.findContainersForLocation(new Path(folder));
for (IContainer container : containers) {
final String file = findInWorkspace(fp, container, mustExist);
if (file != null) {
DEBUG.OUT("Hit with workspace-based search: " + file);
return file;
}
}
}
}
Expand Down Expand Up @@ -419,10 +417,9 @@ public static URI getURI(final String target, final URI existingResource) {
return null;
}
}

public static String escapeFilePath(String path) {
return path .replace("\\", "\\\\")
.replace("\"", "\\\"");

public static String escapeFilePath(final String path) {
return path.replace("\\", "\\\\").replace("\"", "\\\"");
}

/**
Expand Down Expand Up @@ -479,13 +476,6 @@ public static IContainer getFolder(final String path, final URI root, final bool
return null;
}

// public static IFile linkAndGetExternalFile(final URI uri, final URI
// workspaceResource) {
// final String path = URI.decode(uri.isFile() ? uri.toFileString() :
// uri.toString());
// return linkAndGetExternalFile(URI.decode(path), workspaceResource);
// }

/**
* Creates the linked file.
*
Expand Down

0 comments on commit 5ff2af8

Please sign in to comment.