Changeset 1293 for trunk/src/org/expeditee/gui/FrameIO.java
- Timestamp:
- 04/08/19 11:16:39 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameIO.java
r1289 r1293 36 36 import java.nio.file.Path; 37 37 import java.nio.file.Paths; 38 import java.nio.file.StandardCopyOption; 38 39 import java.sql.Time; 39 40 import java.util.Arrays; … … 1724 1725 1725 1726 public static boolean deleteFrameset(String framesetName) { 1726 return moveFrameset(framesetName, FrameIO.TRASH_PATH); 1727 } 1728 1729 public static boolean moveFrameset(String framesetName, 1730 String destinationFolder) { 1727 return moveFrameset(framesetName, FrameIO.TRASH_PATH, true); 1728 } 1729 1730 public static boolean moveFrameset(String framesetName, String destinationFolder, boolean override) { 1731 1731 if (!FrameIO.canAccessFrameset(framesetName)) { 1732 1732 return false; … … 1737 1737 // Search all the available directories for the directory 1738 1738 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1739 return moveFrameset(framesetName, path, destinationFolder );1739 return moveFrameset(framesetName, path, destinationFolder, override); 1740 1740 } 1741 1741 return false; 1742 1742 } 1743 1743 1744 public static boolean moveFrameset(String framesetName, String path, String destinationFolder ) {1744 public static boolean moveFrameset(String framesetName, String path, String destinationFolder, boolean override) { 1745 1745 String source = path + framesetName.toLowerCase() + File.separator; 1746 1746 File framesetDirectory = new File(source); … … 1758 1758 // destination add 1759 1759 // a number to the end 1760 while (dest.exists() ) {1760 while (dest.exists() && !override) { 1761 1761 dest = new File(destPath + ++copyNumber + File.separator); 1762 1762 } 1763 1763 try { 1764 copyFileTree(framesetDirectory.toPath(), dest.toPath());1764 moveFileTree(framesetDirectory.toPath(), dest.toPath()); 1765 1765 } catch (IOException e) { 1766 1766 e.printStackTrace(); … … 1962 1962 Path p = Paths.get(toCopy.getAbsolutePath()); 1963 1963 if (!p.getFileName().toString().equals(".res") && !p.getFileName().toString().equals("about")) { 1964 copyFileTree(p.toAbsolutePath(), personalResources.resolve(p.getFileName()));1964 moveFileTree(p.toAbsolutePath(), personalResources.resolve(p.getFileName())); 1965 1965 } 1966 1966 } … … 1993 1993 } 1994 1994 1995 private static void copyFileTree(Path source, Path target) throws IOException { 1996 Files.copy(source, target); 1995 private static void moveFileTree(Path source, Path target) throws IOException { 1997 1996 if (source.toFile().isDirectory()) { 1997 if (!target.toFile().exists()) { 1998 Files.copy(source, target); 1999 } 1998 2000 File[] files = source.toFile().listFiles(); 1999 2001 for (File file: files) { 2000 2002 Path asPath = Paths.get(file.getAbsolutePath()); 2001 copyFileTree(asPath, target.resolve(asPath.getFileName())); 2002 } 2003 moveFileTree(asPath, target.resolve(asPath.getFileName())); 2004 } 2005 } else { 2006 Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); 2003 2007 } 2004 2008 }
Note:
See TracChangeset
for help on using the changeset viewer.