mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 20:45:22 +02:00
[198046] Improved and beautified code of previous checkin
This commit is contained in:
parent
9477539b58
commit
a8510db671
1 changed files with 19 additions and 20 deletions
|
@ -238,10 +238,8 @@ public class UniversalFileSystemMiner extends Miner {
|
||||||
return statusDone(status);
|
return statusDone(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
File[] srcFiles = new File[numOfSources];
|
List nonDirectoryArrayList = new ArrayList();
|
||||||
String[] names = new String[numOfSources];
|
List nonDirectoryNamesArrayList = new ArrayList();
|
||||||
ArrayList nonDirectoryArrayList = new ArrayList();
|
|
||||||
ArrayList nonDirectoryNamesArrayList = new ArrayList();
|
|
||||||
|
|
||||||
String virtualContainer = ""; //$NON-NLS-1$
|
String virtualContainer = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -254,12 +252,13 @@ public class UniversalFileSystemMiner extends Miner {
|
||||||
{
|
{
|
||||||
DataElement sourceFile = getCommandArgument(theElement, i+1);
|
DataElement sourceFile = getCommandArgument(theElement, i+1);
|
||||||
String srcType = sourceFile.getType();
|
String srcType = sourceFile.getType();
|
||||||
names[i] = sourceFile.getName();
|
String srcName = sourceFile.getName();
|
||||||
|
File srcFile;
|
||||||
|
|
||||||
if (srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) || srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR)
|
if (srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) || srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR)
|
||||||
|| srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR))
|
|| srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR))
|
||||||
{
|
{
|
||||||
srcFiles[i] = getFileFor(sourceFile);
|
srcFile = getFileFor(sourceFile);
|
||||||
}
|
}
|
||||||
else if (srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR) || srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR))
|
else if (srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR) || srcType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR))
|
||||||
{
|
{
|
||||||
|
@ -273,42 +272,42 @@ public class UniversalFileSystemMiner extends Miner {
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualChild child = shandler.getVirtualFile(svpath.getVirtualPart());
|
VirtualChild child = shandler.getVirtualFile(svpath.getVirtualPart());
|
||||||
srcFiles[i] = child.getExtractedFile();
|
srcFile = child.getExtractedFile();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//invalid source type
|
||||||
|
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||||
|
return statusDone(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If this source file object is directory, we will call ISystemArchiveHandler#add(File ...) method to
|
//If this source file object is directory, we will call ISystemArchiveHandler#add(File ...) method to
|
||||||
//it and all its descendants into the archive file.
|
//it and all its descendants into the archive file.
|
||||||
//If this source file object is not a directory, we will add it into a list, and then
|
//If this source file object is not a directory, we will add it into a list, and then
|
||||||
//call ISystemArchiveHandler#add(File[] ...) to add them in batch.
|
//call ISystemArchiveHandler#add(File[] ...) to add them in batch.
|
||||||
if (srcFiles[i].isDirectory())
|
if (srcFile.isDirectory())
|
||||||
{
|
{
|
||||||
result = handler.add(srcFiles[i], virtualContainer, names[i]);
|
result = handler.add(srcFile, virtualContainer, srcName);
|
||||||
if (result == false) {
|
if (!result) {
|
||||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||||
return statusDone(status);
|
return statusDone(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nonDirectoryArrayList.add(srcFiles[i]);
|
nonDirectoryArrayList.add(srcFile);
|
||||||
nonDirectoryNamesArrayList.add(names[i]);
|
nonDirectoryNamesArrayList.add(srcName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonDirectoryArrayList.size() > 0)
|
if (nonDirectoryArrayList.size() > 0)
|
||||||
{
|
{
|
||||||
File[] resultFiles = new File[nonDirectoryArrayList.size()];
|
File[] resultFiles = (File[])nonDirectoryArrayList.toArray(new File[nonDirectoryArrayList.size()]);
|
||||||
String[] resultNames = new String[nonDirectoryNamesArrayList.size()];
|
String[] resultNames = (String[])nonDirectoryArrayList.toArray(new String[nonDirectoryNamesArrayList.size()]);
|
||||||
for (int i=0; i<nonDirectoryArrayList.size(); i++)
|
|
||||||
{
|
|
||||||
resultFiles[i] = (File)nonDirectoryArrayList.get(i);
|
|
||||||
resultNames[i] = (String)nonDirectoryNamesArrayList.get(i);
|
|
||||||
}
|
|
||||||
//we need to add those files into the archive file as well.
|
//we need to add those files into the archive file as well.
|
||||||
result = handler.add(resultFiles, virtualContainer, resultNames);
|
result = handler.add(resultFiles, virtualContainer, resultNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true == result)
|
if (result)
|
||||||
{
|
{
|
||||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.SUCCESS);
|
status.setAttribute(DE.A_SOURCE, IServiceConstants.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue