blob: a71d8f82f0f0ed42045a43056d74ffba5fe1914b [file] [log] [blame]
/*
* Copyright 2012-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.facebook.buck.util;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
public final class MorePaths {
// Utility class: do not instantiate.
private MorePaths() {}
public static Path newPathInstance(String path) {
return separatorsToUnix(path);
}
public static Path newPathInstance(File file) {
return separatorsToUnix(file.getPath());
}
/**
* @return The path using UNIX path separators.
*/
public static Path separatorsToUnix(String path) {
return Paths.get(path.replace(File.separator, "/")).normalize();
}
/**
* @return The path using UNIX path separators.
*/
public static Path separatorsToUnix(Path path) {
return separatorsToUnix(path.toString());
}
}