Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 278402 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java (-30 / +33 lines)
Lines 371-405 Link Here
371
    	assertTrue(fileName + " does not appear to be compressed.", compressed);
371
    	assertTrue(fileName + " does not appear to be compressed.", compressed);
372
    }
372
    }
373
    
373
    
374
    private void verifyFolders(int folderCount, String type){
374
    private void verifyFolders(int folderCount, String type) throws Exception {
375
    	try{
375
		List allEntries = new ArrayList();
376
    		List allEntries = new ArrayList();
376
    	if (ZIP_FILE_EXT.equals(type)){
377
	    	if (ZIP_FILE_EXT.equals(type)){
377
    		ZipFile zipFile = new ZipFile(filePath);
378
	    		ZipFile zipFile = new ZipFile(filePath);
378
    		Enumeration entries = zipFile.entries();
379
	    		Enumeration entries = zipFile.entries();
379
    		while (entries.hasMoreElements()){
380
	    		while (entries.hasMoreElements()){
380
    			ZipEntry entry = (ZipEntry)entries.nextElement();
381
	    			ZipEntry entry = (ZipEntry)entries.nextElement();
381
    			allEntries.add(entry.getName());
382
	    			allEntries.add(entry.getName());
382
    		}
383
	    		}
383
    		zipFile.close();
384
	    		zipFile.close();
385
	    	}
386
	    	else{
387
	    		TarFile tarFile = new TarFile(filePath);
388
	    		Enumeration entries = tarFile.entries();
389
	    		while (entries.hasMoreElements()){
390
	    			TarEntry entry = (TarEntry)entries.nextElement();
391
	    			allEntries.add(entry.getName());
392
	    		}
393
	    		tarFile.close();
394
	    	}
395
	    	if (flattenPaths)
396
	    		verifyFiles(allEntries);
397
	    	else
398
	    		verifyArchive(folderCount, allEntries);
399
    	}
384
    	}
400
    	catch (Exception e){
385
    	else{
401
    		fail(e.getMessage());
386
    		TarFile tarFile = new TarFile(filePath);
387
    		Enumeration entries = tarFile.entries();
388
    		while (entries.hasMoreElements()){
389
    			TarEntry entry = (TarEntry)entries.nextElement();
390
    			allEntries.add(entry.getName());
391
    		}
392
    		tarFile.close();
402
    	}
393
    	}
394
    	if (flattenPaths)
395
    		verifyFiles(allEntries);
396
    	else
397
    		verifyArchive(folderCount, allEntries);
403
    }
398
    }
404
    
399
    
405
    private void verifyArchive(int folderCount, List entries){
400
    private void verifyArchive(int folderCount, List entries){
Lines 409-417 Link Here
409
    	Iterator archiveEntries = entries.iterator();
404
    	Iterator archiveEntries = entries.iterator();
410
    	while (archiveEntries.hasNext()){
405
    	while (archiveEntries.hasNext()){
411
    		String entryName = (String)archiveEntries.next();
406
    		String entryName = (String)archiveEntries.next();
412
			int idx = entryName.lastIndexOf("/");
407
    		// find the path separator at the end of this string
413
			String folderPath = entryName.substring(0, idx);
408
			int backIdx = entryName.lastIndexOf("/");
414
			String fileName = entryName.substring(idx+1, entryName.length());
409
			int forwardIdx = entryName.lastIndexOf("\\");
410
			int index = backIdx;
411
			if (backIdx == -1) {
412
				index = forwardIdx;
413
			} else if (forwardIdx != -1) {
414
				index = backIdx > forwardIdx ? backIdx : forwardIdx;
415
			}
416
			String folderPath = entryName.substring(0, index);
417
			String fileName = entryName.substring(index+1, entryName.length());
415
			// we get empty strings for folder entries, don't add them as a file name
418
			// we get empty strings for folder entries, don't add them as a file name
416
			if (fileName.length() != 0) {
419
			if (fileName.length() != 0) {
417
				files.add(fileName);	
420
				files.add(fileName);	

Return to bug 278402