FolderUtils.java
2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.gimi.common.cinema.utils;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
/**
* Created by 李攀 on 2015/6/2
*/
public class FolderUtils {
public static String getClassPath(String moviePath, String localPath) {
String cur = moviePath.replace(localPath, "");
String className = cur.substring(0, cur.indexOf("/"));
return localPath + className + "/";
}
public static String getMovieFolderPath(String moviePath, String localPath) {
String classPath = getClassPath(moviePath, localPath);
String cur = moviePath.replace(classPath, "");
String className = cur.substring(0, cur.indexOf("/"));
return classPath + className + "/";
}
public static String getClassPath(String moviePath, String ip, String folder) {
String rootPath;
if (!TextUtils.isEmpty(folder)) {
rootPath = "/mnt/samba/" + ip + File.separator + folder;
} else {
rootPath = "/mnt/samba/" + ip;
}
if (TextUtils.isEmpty(moviePath)) {
Log.d("wugian", "╟ moviePath is null");
return null;
}
Log.d("wugian", "╟ " + rootPath);
while (!new File(moviePath).getParent().equals(rootPath)) {
if (new File(new File(moviePath).getParent() + "/TJ").exists()) {
return new File(moviePath).getPath() + File.separator;
}
moviePath = new File(moviePath).getParent();
}
return null;
}
public static String getMovieFolderPath(String moviePath, String ip, String folder) {
String classPath = getClassPath(moviePath, ip, folder);
String replace = moviePath.replace(classPath, "");
int i = replace.indexOf("/");
return classPath + replace.substring(0, i + 1);
}
public static String getMovieFolderName(String moviePath, String ip, String folder) {
String classPath = getClassPath(moviePath, ip, folder);
String movieFolderPath = getMovieFolderPath(moviePath, ip, folder);
return (movieFolderPath.replace(classPath, "")).replace("/", "");
}
}