/**
 * Copyright (c) 2018 committers of YAKINDU and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * Contributors:
 * 	committers of YAKINDU - initial API and implementation
 *
 */
package org.yakindu.sct.commons;

import java.io.File;
import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

import org.eclipse.core.resources.IResource;
import org.eclipse.emf.common.util.URI;

public class PathHelper {
	public String toPathString(File file) {
		try {
			return file.getCanonicalPath();
		} catch (IOException e) {
			e.printStackTrace();
			return file.getAbsolutePath();
		}
	}

	public Path toPath(String pathString, LinkOption... options) {
		if (pathString == null) {
			return null;
		}
		Path path = Paths.get(pathString);
		try {
			return path.toRealPath(options);
		} catch (IOException e) {
			e.printStackTrace();
			return path;
		}
	}
	
	public Path toPath(URI uri, LinkOption... options) {
		return toPath(uri.toFileString(), options);
	}

	public Path toPath(IResource file, LinkOption... options) {
		return toPath(file.getLocation().toOSString(), options);
	}
	
	public Path toWorkspaceRelativePath(IResource file, LinkOption... options) {
		Path filePath = toPath(file, options);
		Path wsPath = toPath(file.getWorkspace().getRoot(), options);
		return wsPath.relativize(filePath);
	}
	
	public Path toProjectRelativePath(IResource file, LinkOption... options) {
		Path filePath = toPath(file, options);
		Path prjPath = toPath(file.getProject(), options);
		return prjPath.relativize(filePath);
	}

	public boolean pathsEqual(String p1, String p2) {
		Path path1 = toPath(p1);
		Path path2 = toPath(p2);
		return pathsEqual(path1, path2);
	}

	public boolean pathsEqual(Path p1, Path p2) {
		return Objects.equals(p1, p2);
	}
}
@@ -1373,447 +1373,8 @@
 %7D%0A%09%0A
-%09public Path toWorkspaceRelativePath(IResource file, LinkOption... options) %7B%0A%09%09Path filePath = toPath(file, options);%0A%09%09Path wsPath = toPath(file.getWorkspace().getRoot(), options);%0A%09%09return wsPath.relativize(filePath);%0A%09%7D%0A%09%0A%09public Path toProjectRelativePath(IResource file, LinkOption... options) %7B%0A%09%09Path filePath = toPath(file, options);%0A%09%09Path prjPath = toPath(file.getProject(), options);%0A%09%09return prjPath.relativize(filePath);%0A%09%7D%0A%0A
 %09pub

Remove unused methods (#2821)