Changeset 1280 for trunk/src/org/expeditee/gui/FrameIO.java
- Timestamp:
- 04/04/19 14:41:47 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameIO.java
r1277 r1280 1579 1579 * @return 1580 1580 */ 1581 public static Boolean canAccessFrameset(String framesetName) {1581 public static boolean canAccessFrameset(String framesetName) { 1582 1582 framesetName = framesetName.toLowerCase(); 1583 1583 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1584 if ( (new File(path + framesetName)).exists()) {1584 if (canAccessFrameset(framesetName, Paths.get(path))) { 1585 1585 return true; 1586 1586 } 1587 1587 } 1588 1588 return false; 1589 } 1590 1591 public static boolean canAccessFrameset(String framesetName, Path path) { 1592 File framesetDir = path.resolve(framesetName).toFile(); 1593 if (framesetDir.exists() && framesetDir.isDirectory()) { 1594 return true; 1595 } else { 1596 return false; 1597 } 1589 1598 } 1590 1599 … … 1723 1732 // Search all the available directories for the directory 1724 1733 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1725 String source = path + framesetName.toLowerCase() + File.separator; 1726 File framesetDirectory = new File(source); 1727 // Once we have found the directory move it 1728 if (framesetDirectory.exists()) { 1729 String destPath = destinationFolder 1730 + framesetName.toLowerCase(); 1731 int copyNumber = 1; 1732 File dest = new File(destPath + File.separator); 1733 // Create the destination folder if it doesnt already exist 1734 if (!dest.getParentFile().exists()) { 1735 dest.mkdirs(); 1734 return moveFrameset(framesetName, path, destinationFolder); 1735 } 1736 return false; 1737 } 1738 1739 public static boolean moveFrameset(String framesetName, String path, String destinationFolder) { 1740 String source = path + framesetName.toLowerCase() + File.separator; 1741 File framesetDirectory = new File(source); 1742 // Once we have found the directory move it 1743 if (framesetDirectory.exists()) { 1744 String destPath = destinationFolder 1745 + framesetName.toLowerCase(); 1746 int copyNumber = 1; 1747 File dest = new File(destPath + File.separator); 1748 // Create the destination folder if it doesnt already exist 1749 if (!dest.getParentFile().exists()) { 1750 dest.mkdirs(); 1751 } 1752 // If a frameset with the same name is already in the 1753 // destination add 1754 // a number to the end 1755 while (dest.exists()) { 1756 dest = new File(destPath + ++copyNumber + File.separator); 1757 } 1758 try { 1759 copyFileTree(framesetDirectory.toPath(), dest.toPath()); 1760 } catch (IOException e) { 1761 e.printStackTrace(); 1762 return false; 1763 } 1764 1765 for (File f : framesetDirectory.listFiles()) { 1766 if (!f.delete()) { 1767 return false; 1736 1768 } 1737 // If a frameset with the same name is already in the 1738 // destination add 1739 // a number to the end 1740 while (dest.exists()) { 1741 dest = new File(destPath + ++copyNumber + File.separator); 1742 } 1743 if (!framesetDirectory.renameTo(dest)) { 1744 for (File f : framesetDirectory.listFiles()) { 1745 if (!f.delete()) { 1746 return false; 1747 } 1748 } 1749 if (!framesetDirectory.delete()) { 1750 return false; 1751 } 1752 } 1753 return true; 1754 } 1755 } 1756 return false; 1769 } 1770 if (!framesetDirectory.delete()) { 1771 return false; 1772 } 1773 return true; 1774 } else { 1775 return false; 1776 } 1757 1777 } 1758 1778
Note:
See TracChangeset
for help on using the changeset viewer.