Changeset 1319
- Timestamp:
- 10/31/06 08:42:01
(2 years ago)
- Author:
- dsugar
- Message:
ticket:91 - don't copy version control info (.svn, CVS). Other things are copied.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1318 |
r1319 |
|
| 22 | 22 | import com.tresys.framework.plugin.wizards.NewSystemPage; |
|---|
| 23 | 23 | import com.tresys.framework.utility.CopyDir; |
|---|
| | 24 | import com.tresys.framework.utility.FileNameFilter; |
|---|
| | 25 | |
|---|
| 24 | 26 | import org.eclipse.jface.dialogs.MessageDialog; |
|---|
| 25 | 27 | import org.eclipse.jface.viewers.IStructuredSelection; |
|---|
| … | … | |
| 93 | 95 | String systemName = page1.getSystemName (); |
|---|
| 94 | 96 | |
|---|
| 95 | | |
|---|
| | 97 | IFolder srcDir = project.getFolder("src"); |
|---|
| | 98 | if (!srcDir.exists()) |
|---|
| | 99 | srcDir.create(true, false, null); |
|---|
| | 100 | |
|---|
| 96 | 101 | /*Add 'selinux-policy-<system's name>' directory to 'projectRefPolicyFolder' of project |
|---|
| 97 | 102 | * and recursively copy all files into folder |
|---|
| 98 | 103 | */ |
|---|
| 99 | | IFolder srcDir = project.getFolder("src"); |
|---|
| 100 | | |
|---|
| 101 | | /* Copy all of reference policy into 'selinux-policy-<system name> */ |
|---|
| 102 | | if (!srcDir.exists()) |
|---|
| 103 | | srcDir.create(true, false, null); |
|---|
| 104 | | |
|---|
| 105 | 104 | IFolder systemDir = srcDir.getFolder("selinux-policy-" + systemName); |
|---|
| 106 | 105 | if (!systemDir.exists()) |
|---|
| 107 | 106 | systemDir.create(true, false, null); |
|---|
| 108 | 107 | |
|---|
| | 108 | /* Copy all of reference policy into 'selinux-policy-<system name> */ |
|---|
| 109 | 109 | populateRefPolicyFiles (systemDir); |
|---|
| 110 | 110 | |
|---|
| … | … | |
| 114 | 114 | */ |
|---|
| 115 | 115 | |
|---|
| 116 | | project.refreshLocal (IResource.DEPTH_INFINITE, null); |
|---|
| | 116 | systemDir.refreshLocal (IResource.DEPTH_INFINITE, null); |
|---|
| 117 | 117 | |
|---|
| 118 | 118 | IFolder frameDir = systemDir.getFolder("framepol"); |
|---|
| … | … | |
| 212 | 212 | waitBox.open (); |
|---|
| 213 | 213 | |
|---|
| 214 | | CopyDir.copyDirectory (m_srcDir, m_destDir); |
|---|
| | 214 | String [] filter = new String [] { ".svn", "CVS" }; |
|---|
| | 215 | CopyDir.copyDirectory (m_srcDir, m_destDir, new FileNameFilter (filter)); |
|---|
| 215 | 216 | waitBox.close (); |
|---|
| 216 | 217 | } |
|---|
| r1316 |
r1319 |
|
| 1 | | package com.tresys.framework.utility; |
|---|
| 2 | | |
|---|
| 3 | 1 | /* Copyright (C) 2006 Tresys Technology, LLC |
|---|
| 4 | 2 | * License: refer to COPYING file for license information. |
|---|
| … | … | |
| 9 | 7 | */ |
|---|
| 10 | 8 | |
|---|
| | 9 | package com.tresys.framework.utility; |
|---|
| | 10 | |
|---|
| 11 | 11 | import java.io.File; |
|---|
| 12 | 12 | import java.io.FileInputStream; |
|---|
| 13 | 13 | import java.io.FileOutputStream; |
|---|
| | 14 | import java.io.FilenameFilter; |
|---|
| 14 | 15 | import java.io.IOException; |
|---|
| 15 | 16 | |
|---|
| 16 | | public class CopyDir { |
|---|
| | 17 | public class CopyDir |
|---|
| | 18 | { |
|---|
| 17 | 19 | |
|---|
| 18 | 20 | /** |
|---|
| … | … | |
| 20 | 22 | * not exist, creates one. No access checks are performed |
|---|
| 21 | 23 | * |
|---|
| 22 | | * @param Source directory of copy |
|---|
| 23 | | * @param Destination to copy to |
|---|
| 24 | | * @param file filter, can be null |
|---|
| | 24 | * @param Source |
|---|
| | 25 | * directory of copy |
|---|
| | 26 | * @param Destination |
|---|
| | 27 | * to copy to |
|---|
| | 28 | * @param file |
|---|
| | 29 | * filter, can be null |
|---|
| 25 | 30 | * @throws IOException |
|---|
| 26 | 31 | */ |
|---|
| 27 | | public static void copyDirectory(File srcDir, File dstDir ) { |
|---|
| 28 | | if (srcDir.canRead() && srcDir.isDirectory()) { |
|---|
| 29 | | if (!dstDir.exists()) { |
|---|
| 30 | | if(!dstDir.mkdir()) |
|---|
| | 32 | public static void copyDirectory (File srcDir, File dstDir, FilenameFilter filter) |
|---|
| | 33 | { |
|---|
| | 34 | if (srcDir.canRead () && srcDir.isDirectory ()) |
|---|
| | 35 | { |
|---|
| | 36 | if (!dstDir.exists ()) |
|---|
| | 37 | { |
|---|
| | 38 | if (!dstDir.mkdir ()) |
|---|
| 31 | 39 | return; |
|---|
| 32 | 40 | } |
|---|
| 33 | | File[] children = srcDir.listFiles(); |
|---|
| 34 | | for (int i = 0; i < children.length; i++) |
|---|
| | 41 | File[] children = srcDir.listFiles (filter); |
|---|
| | 42 | for (int i = 0; i < children.length; i++) |
|---|
| 35 | 43 | { |
|---|
| 36 | | if (children[i].isDirectory()) |
|---|
| 37 | | copyDirectory(children[i], new File(dstDir, children[i].getName()) ); |
|---|
| | 44 | if (children[i].isDirectory ()) |
|---|
| | 45 | copyDirectory (children[i], new File (dstDir, children[i].getName ()), filter); |
|---|
| 38 | 46 | else |
|---|
| 39 | | copyFile(children[i], new File(dstDir, children[i].getName())); |
|---|
| | 47 | copyFile (children[i], new File (dstDir, children[i].getName ())); |
|---|
| 40 | 48 | } |
|---|
| 41 | 49 | } |
|---|
| … | … | |
| 51 | 59 | * @return none |
|---|
| 52 | 60 | */ |
|---|
| 53 | | public static void copyFile(File src, File dest) { |
|---|
| 54 | | try { |
|---|
| | 61 | public static void copyFile (File src, File dest) |
|---|
| | 62 | { |
|---|
| | 63 | try |
|---|
| | 64 | { |
|---|
| 55 | 65 | FileInputStream reader = new FileInputStream (src); |
|---|
| 56 | 66 | FileOutputStream writer = new FileOutputStream (dest); |
|---|
| 57 | 67 | |
|---|
| 58 | 68 | int len; |
|---|
| 59 | | byte[] buf = new byte[(int) Math.min(10240,src.length())]; |
|---|
| 60 | | while ((len = reader.read(buf)) > 0) { |
|---|
| 61 | | writer.write(buf, 0, len); |
|---|
| | 69 | byte[] buf = new byte[(int) Math.min (10240, src.length ())]; |
|---|
| | 70 | while ( (len = reader.read (buf)) > 0) |
|---|
| | 71 | { |
|---|
| | 72 | writer.write (buf, 0, len); |
|---|
| 62 | 73 | } |
|---|
| 63 | | reader.close(); |
|---|
| 64 | | writer.close(); |
|---|
| 65 | | } catch(IOException ioe) { |
|---|
| | 74 | reader.close (); |
|---|
| | 75 | writer.close (); |
|---|
| 66 | 76 | } |
|---|
| | 77 | catch (IOException ioe) |
|---|
| | 78 | {} |
|---|
| 67 | 79 | } |
|---|
| 68 | 80 | } |
|---|
Download in other formats:
* Generating other formats may take time.