Lines 12-18
Link Here
|
12 |
|
12 |
|
13 |
package org.eclipse.cdt.internal.core.model; |
13 |
package org.eclipse.cdt.internal.core.model; |
14 |
|
14 |
|
15 |
import java.io.File; |
|
|
16 |
import java.io.IOException; |
15 |
import java.io.IOException; |
17 |
import java.io.InputStream; |
16 |
import java.io.InputStream; |
18 |
import java.util.ArrayList; |
17 |
import java.util.ArrayList; |
Lines 49-54
Link Here
|
49 |
import org.eclipse.cdt.core.model.ISourceRoot; |
48 |
import org.eclipse.cdt.core.model.ISourceRoot; |
50 |
import org.eclipse.cdt.core.model.ITranslationUnit; |
49 |
import org.eclipse.cdt.core.model.ITranslationUnit; |
51 |
import org.eclipse.cdt.core.model.IWorkingCopy; |
50 |
import org.eclipse.cdt.core.model.IWorkingCopy; |
|
|
51 |
import org.eclipse.core.filesystem.*; |
52 |
import org.eclipse.core.resources.IFile; |
52 |
import org.eclipse.core.resources.IFile; |
53 |
import org.eclipse.core.resources.IFolder; |
53 |
import org.eclipse.core.resources.IFolder; |
54 |
import org.eclipse.core.resources.IProject; |
54 |
import org.eclipse.core.resources.IProject; |
Lines 404-445
Link Here
|
404 |
if (path == null || cproject == null) { |
404 |
if (path == null || cproject == null) { |
405 |
return null; |
405 |
return null; |
406 |
} |
406 |
} |
407 |
if (path.isAbsolute()) { |
407 |
try { |
408 |
File file = path.toFile(); |
408 |
if (path.isAbsolute()) { |
409 |
if (file == null || !file.isFile()) { |
409 |
IFileInfo fi = EFS.getStore(URIUtil.toURI(path)).fetchInfo(); |
410 |
return null; |
410 |
if (!fi.exists() || fi.isDirectory()) |
411 |
} |
411 |
return null; |
412 |
try { |
412 |
try { |
413 |
IIncludeReference[] includeReferences = cproject.getIncludeReferences(); |
413 |
IIncludeReference[] includeReferences = cproject.getIncludeReferences(); |
414 |
for (int i = 0; i < includeReferences.length; i++) { |
414 |
for (int i = 0; i < includeReferences.length; i++) { |
415 |
if (includeReferences[i].isOnIncludeEntry(path)) { |
415 |
if (includeReferences[i].isOnIncludeEntry(path)) { |
416 |
String id = CoreModel.getRegistedContentTypeId(cproject.getProject(), path.lastSegment()); |
416 |
String id = CoreModel.getRegistedContentTypeId(cproject.getProject(), path.lastSegment()); |
417 |
if (id == null) { |
417 |
if (id == null) { |
418 |
// fallback to C Header |
418 |
// fallback to C Header |
419 |
id = CCorePlugin.CONTENT_TYPE_CHEADER; |
419 |
id = CCorePlugin.CONTENT_TYPE_CHEADER; |
|
|
420 |
} |
421 |
return new ExternalTranslationUnit(includeReferences[i], path, id); |
420 |
} |
422 |
} |
421 |
return new ExternalTranslationUnit(includeReferences[i], path, id); |
|
|
422 |
} |
423 |
} |
|
|
424 |
} catch (CModelException e) { |
423 |
} |
425 |
} |
424 |
} catch (CModelException e) { |
426 |
} else { |
425 |
} |
427 |
try { |
426 |
} else { |
428 |
IIncludeReference[] includeReferences = cproject.getIncludeReferences(); |
427 |
try { |
429 |
for (int i = 0; i < includeReferences.length; i++) { |
428 |
IIncludeReference[] includeReferences = cproject.getIncludeReferences(); |
430 |
IPath includePath = includeReferences[i].getPath().append(path); |
429 |
for (int i = 0; i < includeReferences.length; i++) { |
431 |
IFileInfo fi = EFS.getStore(URIUtil.toURI(includePath)).fetchInfo(); |
430 |
IPath includePath = includeReferences[i].getPath().append(path); |
432 |
if (fi.exists() && (!fi.isDirectory())) { |
431 |
File file = includePath.toFile(); |
433 |
String id = CoreModel.getRegistedContentTypeId(cproject.getProject(), includePath.lastSegment()); |
432 |
if (file != null && file.isFile()) { |
434 |
if (id == null) { |
433 |
String id = CoreModel.getRegistedContentTypeId(cproject.getProject(), includePath.lastSegment()); |
435 |
// fallbakc to C Header |
434 |
if (id == null) { |
436 |
id = CCorePlugin.CONTENT_TYPE_CHEADER; |
435 |
// fallbakc to C Header |
437 |
} |
436 |
id = CCorePlugin.CONTENT_TYPE_CHEADER; |
438 |
return new ExternalTranslationUnit(includeReferences[i], includePath, id); |
437 |
} |
439 |
} |
438 |
return new ExternalTranslationUnit(includeReferences[i], includePath, id); |
|
|
439 |
} |
440 |
} |
|
|
441 |
} catch (CModelException e) { |
440 |
} |
442 |
} |
441 |
} catch (CModelException e) { |
|
|
442 |
} |
443 |
} |
|
|
444 |
} catch (CoreException e) { |
443 |
} |
445 |
} |
444 |
return null; |
446 |
return null; |
445 |
} |
447 |
} |
Lines 561-568
Link Here
|
561 |
|
563 |
|
562 |
public IBinaryFile createBinaryFile(IFile file) { |
564 |
public IBinaryFile createBinaryFile(IFile file) { |
563 |
//Avoid name special devices, empty files and the like |
565 |
//Avoid name special devices, empty files and the like |
564 |
File f = new File(file.getLocationURI()); |
566 |
try { |
565 |
if (!f.isFile() || f.length() == 0) { |
567 |
IFileInfo fi = EFS.getStore(file.getLocationURI()).fetchInfo(); |
|
|
568 |
if (fi.getLength() == 0 || fi.isDirectory()) { |
569 |
return null; |
570 |
} |
571 |
} catch (CoreException e) { |
566 |
return null; |
572 |
return null; |
567 |
} |
573 |
} |
568 |
|
574 |
|