Revision 1545

tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load079BinaryCorpus.java (revision 1545)
47 47
 */
48 48
public class Load079BinaryCorpus {
49 49

  
50
	public static boolean canLoad(File zipFile) {
51
		String basedirname = Zip.getRoot(zipFile);
52
		return Zip.hasEntries(zipFile, basedirname+"/import.xml", basedirname+"/data/", basedirname+"/txm/", basedirname+"/HTML/", basedirname+"/registry/");
53
	}
54
	
50 55
	/**
51 56
	 * Load a 0.7.9 binary corpus archive: 
52 57
	 * 
......
70 75
			return null;
71 76
		}
72 77
		
73
		if (!Zip.hasEntries(zipFile, basedirname+"/import.xml", basedirname+"/data/", basedirname+"/txm/", basedirname+"/HTML/", basedirname+"/registry/")) {
78
		if (!canLoad(zipFile)) {
74 79
			System.out.println(TXMUIMessages.binaryCorpusIsNotATXM079CorpusNoImportXmlFile);	
75 80
			return null;
76 81
		}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 1545)
267 267
			//			}
268 268

  
269 269
			//CHECK ZIPPED FILE
270
			project = Load080BinaryCorpus.loadBinaryCorpus(zipFile, monitor);
271
			if (project == null) {
270
			if (Load080BinaryCorpus.canLoad(zipFile)) {
271
				project = Load080BinaryCorpus.loadBinaryCorpus(zipFile, monitor);
272
			} else if (Load079BinaryCorpus.canLoad(zipFile)) {
272 273
				project = Load079BinaryCorpus.loadBinaryCorpusArchive(zipFile, monitor);
274
			} else {
275
				System.out.println(NLS.bind("Error: the {0} archive is not a TXM corpus.", zipFile));
276
				return null;
273 277
			}
274 278
			if (project == null) {
275
				System.out.println("Error: cant load corpus from file="+zipFile);
279
				System.out.println(NLS.bind("Error: could not load {0} corpus.", zipFile));
276 280
				return null; 
277 281
			}
278 282

  
......
356 360

  
357 361
		Project project = null;
358 362
		File paramFile = new File(destDir, ".settings");
363
		File importXMLFile = new File(destDir, "import.xml");
359 364
		File dotProjectFile = new File(destDir, ".project");
360 365
		if (paramFile.exists() && paramFile.isDirectory() && dotProjectFile.exists() && dotProjectFile.isFile()) {
361 366
			System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM080Corpus, destDir));
362 367
			project = Load080BinaryCorpus.loadBinaryCorpusAsDirectory(destDir);
363
			//			continue;
364
			if (project != null) {
365
				return project;
366
			}
367
		}
368

  
369
		paramFile = new File(destDir, "import.xml");
370
		if (paramFile.exists()) {
368
		} else if (importXMLFile.exists()) {
371 369
			System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM079Corpus, destDir));
372 370
			project = Load079BinaryCorpus.loadBinaryCorpusAsDirectory(destDir, null);
373
			//			continue;
371
		} else {
372
			System.out.println(NLS.bind("Error: {0} is not a binary corpus directory.", destDir));
374 373
		}
375 374

  
376 375
		return project;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load080BinaryCorpus.java (revision 1545)
44 44
 */
45 45
public class Load080BinaryCorpus {
46 46

  
47
	
48
	public static boolean canLoad(File zipFile) {
49
		String basedirname = Zip.getRoot(zipFile);
50
		return Zip.hasEntries(zipFile, basedirname+"/.settings/", basedirname+"/.project", basedirname+"/data/", basedirname+"/txm/", basedirname+"/HTML/", basedirname+"/registry/");
51
	}
47 52
	/**
48 53
	 * load the content of the file if its a directory containing at least the sub folders :
49 54
	 * txm, html, data and registry.
......
65 70
			return null;
66 71
		}
67 72
		
68
		if (!Zip.hasEntries(zipFile, basedirname+"/.settings/", basedirname+"/.project", basedirname+"/data/", basedirname+"/txm/", basedirname+"/HTML/", basedirname+"/registry/")) {
73
		if (!canLoad(zipFile)) {
69 74
			Log.info(NLS.bind(TXMUIMessages.binaryCorpusIsNotATXM080CorpusNoSettingsNorProjectFile, zipFile.getName()));
70 75
			return null;
71 76
		}

Also available in: Unified diff