comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java @ 22209:dcee887614b1

Removing hardcoded MIME types in the source. Each language is supposed to register its own FileTypeDetector as SL did in cf19259edf87.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 30 Sep 2015 13:09:22 +0200
parents dc83cc1f94f2
children b56fe0d3b560
comparison
equal deleted inserted replaced
22208:df57bc2fcdbd 22209:dcee887614b1
903 return path.hashCode(); 903 return path.hashCode();
904 } 904 }
905 905
906 @Override 906 @Override
907 String findMimeType() { 907 String findMimeType() {
908 if (file.getName().endsWith(".c")) { 908 try {
909 return "text/x-c"; 909 return Files.probeContentType(file.toPath());
910 } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) { 910 } catch (IOException ex) {
911 return "application/x-r"; 911 LOG.log(Level.SEVERE, null, ex);
912 } else {
913 try {
914 return Files.probeContentType(file.toPath());
915 } catch (IOException ex) {
916 LOG.log(Level.SEVERE, null, ex);
917 }
918 } 912 }
919 return null; 913 return null;
920 } 914 }
921 915
922 @Override 916 @Override
991 return new StringReader(code); 985 return new StringReader(code);
992 } 986 }
993 987
994 @Override 988 @Override
995 String findMimeType() { 989 String findMimeType() {
996 if (file.getName().endsWith(".c")) { 990 try {
997 return "text/x-c"; 991 return Files.probeContentType(file.toPath());
998 } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) { 992 } catch (IOException ex) {
999 return "application/x-r"; 993 LOG.log(Level.SEVERE, null, ex);
1000 } else {
1001 try {
1002 return Files.probeContentType(file.toPath());
1003 } catch (IOException ex) {
1004 LOG.log(Level.SEVERE, null, ex);
1005 }
1006 } 994 }
1007 return null; 995 return null;
1008 } 996 }
1009 997
1010 @Override 998 @Override