MCPcopy Create free account
hub / github.com/annmuor/jnode / guessFilename

Method guessFilename

jnode-core/src/jnode/ftn/FtnTools.java:680–713  ·  view source on GitHub ↗
(String filename, boolean read)

Source from the content-addressed store, hash-verified

678 }
679
680 public static File guessFilename(String filename, boolean read) {
681 filename = filename.replaceAll("^[\\./\\\\]+", "_");
682 File f = new File(getInbound() + File.separator + filename);
683 boolean ninetoa = false;
684 boolean ztonull = false;
685 boolean underll = false;
686 while ((read) ? !f.exists() : f.exists()) {
687 if ((ninetoa && ztonull) || underll) {
688 logger.l4(read ? "Files not found"
689 : "Delete something to continue");
690 f = null;
691 break;
692 } else {
693 char[] array = filename.toCharArray();
694 char c = array[array.length - 1];
695 if ((c >= '0' && c <= '8') || (c >= 'a' && c <= 'y')) {
696 c++;
697 } else if (c == '9') {
698 c = 'a';
699 ninetoa = true;
700 } else if (c == 'z') {
701 c = '0';
702 ztonull = true;
703 } else {
704 c = '_';
705 underll = true;
706 }
707 array[array.length - 1] = c;
708 filename = new String(array);
709 f = new File(getInbound() + File.separator + filename);
710 }
711 }
712 return f;
713 }
714
715 /**
716 * Проверка соответствия маски :)

Callers 3

unpackMethod · 0.95
tossInboundDirectoryMethod · 0.95
packNetmailMethod · 0.80

Calls 4

getInboundMethod · 0.95
replaceAllMethod · 0.80
existsMethod · 0.80
l4Method · 0.80

Tested by

no test coverage detected