Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Stuff to make ntfs 8.3 dirs by Jorge Chayan **/
- public static String toNTFS83(File dir)
- {
- StringBuilder wholedir = new StringBuilder(dir.getAbsolutePath());
- if (wholedir.length() <= 8) return wholedir.toString();
- else {
- String disk = "";
- for (char i = 'A'; i <= 'Z'; i++) {
- if (wholedir.toString().contains(i + ":\\")) {
- disk = wholedir.substring(0, 3);
- System.out.println(disk);
- wholedir.delete(0, 3);
- System.out.println(wholedir.toString());
- break;
- }
- }
- int end = wholedir.indexOf("\\");
- StringBuilder dirs = new StringBuilder("");
- int point = dir.getName().indexOf(".");
- String xtens = "";
- if (point != -1) xtens = dir.getName().substring(point, dir.getName().length());
- while (true) {
- String aux;
- if (end == -1) {
- if (point != -1) aux = dir.getName().substring(0, point);
- else aux = dir.getName();
- }
- else aux = wholedir.substring(0, end);
- System.out.println(aux);
- wholedir.delete(0, end + 1);
- System.out.println(wholedir.toString());
- if (aux.length() >= 8) {
- if (aux.contains("" + ((char) 91))) aux.replace((char) 91, '_');
- if (aux.contains("" + ((char) 47))) aux.replace((char) 47, '_');
- for (char j = 0; j < 32; j++) {
- if (aux.contains("" + j)) aux.replace(j, '_');
- }
- for (char j = 33; j < 46; j++) {
- if (aux.contains("" + j)) aux.replace(j, '_');
- }
- if (end != -1 && aux.contains("" + ((char) 46))) aux.replace((char) 46, '_');
- for (char j = 58; j < 65; j++) {
- if (aux.contains("" + j)) aux.replace(j, '_');
- }
- for (char j = 93; j < 97; j++) {
- if (aux.contains("" + j)) aux.replace(j, '_');
- }
- for (char j = 123; j < 128; j++) {
- if (aux.contains("" + j)) aux.replace(j, '_');
- }
- int limit = 6;
- for (int k = 0; k < limit; k++) {
- if (aux.charAt(k) != ' ') {
- dirs.append(aux.charAt(k));
- }
- else limit++;
- }
- dirs.append("~1");
- if (end != -1) dirs.append("\\");
- }
- else dirs.append(aux + "\\");
- if (end == -1) break;
- end = wholedir.indexOf("\\");
- }
- return disk.toUpperCase() + dirs.toString().toUpperCase() + xtens.toUpperCase();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement