Commit be75a2f1 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

getParent util method for path string

parent 12e40648
......@@ -20,6 +20,8 @@
package org.videolan.vlc.util;
import android.text.TextUtils;
import org.videolan.vlc.MediaWrapper;
import java.text.DecimalFormat;
......@@ -138,4 +140,18 @@ public class Strings {
title = getName(mediaWrapper.getLocation());
return title;
}
public static String getParent(String path){
if (TextUtils.equals("/", path))
return path;
String parentPath = path;
if (parentPath.endsWith("/"))
parentPath = parentPath.substring(0, parentPath.length()-1);
int index = parentPath.lastIndexOf('/');
if (index > 0){
parentPath = parentPath.substring(0, index);
} else if (index == 0)
parentPath = "/";
return parentPath;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment