(String filename, boolean read)
| 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 | * Проверка соответствия маски :) |
no test coverage detected