public static String detectMimeType(File file) { if (file == null || !file.exists()) { return null; } InputStream is = null; try { is = openFileForReading(file); return detectMimeType(is); } catch (IOException e) { return null; } catch (SVNException e) { return null; } finally { closeFile(is); } }
public static Map computeAutoProperties(ISVNOptions options, File file, Map properties) throws SVNException { properties = options.applyAutoProperties(file, properties); if (!properties.containsKey(SVNProperty.MIME_TYPE)) { String mimeType = SVNFileUtil.detectMimeType(file, options.getFileExtensionsToMimeTypes()); if (mimeType != null) { properties.put(SVNProperty.MIME_TYPE, mimeType); } } if (SVNProperty.isBinaryMimeType((String) properties.get(SVNProperty.MIME_TYPE))) { properties.remove(SVNProperty.EOL_STYLE); properties.remove(SVNProperty.CHARSET); } if (!properties.containsKey(SVNProperty.EXECUTABLE)) { if (SVNFileUtil.isExecutable(file)) { properties.put(SVNProperty.EXECUTABLE, ""); } } return properties; }
public static Map computeAutoProperties(ISVNOptions options, File file, Map properties) throws SVNException { properties = options.applyAutoProperties(file, properties); if (!properties.containsKey(SVNProperty.MIME_TYPE)) { String mimeType = SVNFileUtil.detectMimeType(file, options.getFileExtensionsToMimeTypes()); if (mimeType != null) { properties.put(SVNProperty.MIME_TYPE, mimeType); } } if (SVNProperty.isBinaryMimeType((String) properties.get(SVNProperty.MIME_TYPE))) { properties.remove(SVNProperty.EOL_STYLE); properties.remove(SVNProperty.CHARSET); } if (!properties.containsKey(SVNProperty.EXECUTABLE)) { if (SVNFileUtil.isExecutable(file)) { properties.put(SVNProperty.EXECUTABLE, ""); } } return properties; }
public static Map computeAutoProperties(ISVNOptions options, File file, Map properties) throws SVNException { properties = options.applyAutoProperties(file, properties); if (!properties.containsKey(SVNProperty.MIME_TYPE)) { String mimeType = SVNFileUtil.detectMimeType(file, options.getFileExtensionsToMimeTypes()); if (mimeType != null) { properties.put(SVNProperty.MIME_TYPE, mimeType); } } if (SVNProperty.isBinaryMimeType((String) properties.get(SVNProperty.MIME_TYPE))) { properties.remove(SVNProperty.EOL_STYLE); properties.remove(SVNProperty.CHARSET); } if (!properties.containsKey(SVNProperty.EXECUTABLE)) { if (SVNFileUtil.isExecutable(file)) { properties.put(SVNProperty.EXECUTABLE, ""); } } return properties; }
public static Map computeAutoProperties(ISVNOptions options, File file) { Map properties = options.applyAutoProperties(file, null); if (!properties.containsKey(SVNProperty.MIME_TYPE)) { String mimeType = SVNFileUtil.detectMimeType(file); if (mimeType != null) { properties.put(SVNProperty.MIME_TYPE, mimeType); } } if (SVNProperty.isBinaryMimeType((String) properties.get(SVNProperty.MIME_TYPE))) { properties.remove(SVNProperty.EOL_STYLE); } if (!properties.containsKey(SVNProperty.EXECUTABLE)) { if (SVNFileUtil.isExecutable(file)) { properties.put(SVNProperty.EXECUTABLE, SVNProperty.getValueOfBooleanProperty(SVNProperty.EXECUTABLE)); } } return properties; }
public boolean isObjectBinary(@Nullable GitFilter filter, @Nullable GitObject<? extends ObjectId> objectId) throws IOException, SVNException { if (objectId == null || filter == null) return false; final String key = filter.getName() + " " + objectId.getObject().name(); Boolean result = binaryCache.get(key); if (result == null) { try (InputStream stream = filter.inputStream(objectId)) { result = SVNFileUtil.detectMimeType(stream) != null; } binaryCache.putIfAbsent(key, result); } return result; }
try { is = openFileForReading(file, SVNLogType.WC); return detectMimeType(is); } catch (IOException e) { return null;
try { is = openFileForReading(file, SVNLogType.WC); return detectMimeType(is); } catch (IOException e) { return null;
try { is = openFileForReading(file, SVNLogType.WC); return detectMimeType(is); } catch (IOException e) { return null;
} else if (fileType == SVNFileType.FILE) { String mimeType1 = null; String mimeType2 = SVNFileUtil.detectMimeType(file); String filePath = SVNPathUtil.append(dir.getRelativePath(myAdminInfo.getAnchor()), file.getName()); getDiffCallback().fileAdded(filePath, null, file, 0, 0, mimeType1, mimeType2, null, null);
} else if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) { String mimeType1 = null; String mimeType2 = SVNFileUtil.detectMimeType(file, null); String filePath = SVNPathUtil.append(parentRelativePath, file.getName()); getDiffCallback().fileAdded(filePath, null, file, 0, 0, mimeType1, mimeType2, null, null, null);
} else if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) { String mimeType1 = null; String mimeType2 = SVNFileUtil.detectMimeType(file, null); String filePath = SVNPathUtil.append(parentRelativePath, file.getName()); getDiffCallback().fileAdded(filePath, null, file, 0, 0, mimeType1, mimeType2, null, null, null);
} else if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) { String mimeType1 = null; String mimeType2 = SVNFileUtil.detectMimeType(file, null); String filePath = SVNPathUtil.append(parentRelativePath, file.getName()); getDiffCallback().fileAdded(filePath, null, file, 0, 0, mimeType1, mimeType2, null, null, null);
} else if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) { String mimeType1 = null; String mimeType2 = SVNFileUtil.detectMimeType(file, null); String filePath = SVNPathUtil.append(parentRelativePath, file.getName()); getDiffCallback().fileAdded(getDiffCallbackResult(), new File(getWorkingCopyRoot(), filePath), null, file, -1, -1, mimeType1, mimeType2, null, -1, null, null);
autoProperties = getOptions().applyAutoProperties(file, autoProperties); if (!autoProperties.containsKey(SVNProperty.MIME_TYPE)) { mimeType = SVNFileUtil.detectMimeType(file); if (mimeType != null) { autoProperties.put(SVNProperty.MIME_TYPE, mimeType);
private void printBinaryMimeTypeWarning(Collection targets, String propertyName, SVNPropertyValue propertyValue) throws SVNException { if (SVNProperty.MIME_TYPE.equals(propertyName)) { for (Object target : targets) { String path = (String) target; File localAbsPath = SVNFileUtil.createFilePath(path).getAbsoluteFile(); if (SVNFileType.getNodeKind(SVNFileType.getType(localAbsPath)) != SVNNodeKind.FILE) { continue; } SVNPropertyValue canonicalPropertyValue = SVNPropertiesManager.validatePropertyValue(localAbsPath, SVNNodeKind.FILE, propertyName, propertyValue, false, null, null); if (SVNProperty.isBinaryMimeType(SVNPropertyValue.getPropertyAsString(canonicalPropertyValue))) { String detectedMimeType = SVNFileUtil.detectMimeType(localAbsPath, null); if (detectedMimeType == null || !SVNProperty.isBinaryMimeType(detectedMimeType)) { getEnvironment().getErr().println("svn: warning: '" + SVNPropertyValue.getPropertyAsString(canonicalPropertyValue) + "' is a binary mime-type but file '" + localAbsPath + "' " + "looks like text; diff, merge, blame, and other " + "operations will stop working on this file"); } } } } } }
private void printBinaryMimeTypeWarning(Collection targets, String propertyName, SVNPropertyValue propertyValue) throws SVNException { if (SVNProperty.MIME_TYPE.equals(propertyName)) { for (Object target : targets) { String path = (String) target; File localAbsPath = SVNFileUtil.createFilePath(path).getAbsoluteFile(); if (SVNFileType.getNodeKind(SVNFileType.getType(localAbsPath)) != SVNNodeKind.FILE) { continue; } SVNPropertyValue canonicalPropertyValue = SVNPropertiesManager.validatePropertyValue(localAbsPath, SVNNodeKind.FILE, propertyName, propertyValue, false, null, null); if (SVNProperty.isBinaryMimeType(SVNPropertyValue.getPropertyAsString(canonicalPropertyValue))) { String detectedMimeType = SVNFileUtil.detectMimeType(localAbsPath, null); if (detectedMimeType == null || !SVNProperty.isBinaryMimeType(detectedMimeType)) { getEnvironment().getErr().println("svn: warning: '" + SVNPropertyValue.getPropertyAsString(canonicalPropertyValue) + "' is a binary mime-type but file '" + localAbsPath + "' " + "looks like text; diff, merge, blame, and other " + "operations will stop working on this file"); } } } } } }
boolean mineIsBinary = false; try { mineIsBinary = mineBytes != null && SVNFileUtil.detectMimeType(new ByteArrayInputStream(mineBytes)) != null; } catch (IOException e) { incomingIsBinary = incomingBytes != null && SVNFileUtil.detectMimeType(new ByteArrayInputStream(incomingBytes)) != null; } catch (IOException e) { originalIsBinary = originalBytes != null && SVNFileUtil.detectMimeType(new ByteArrayInputStream(originalBytes)) != null; } catch (IOException e) {
String mimeType = SVNFileUtil.detectMimeType(localAbsPath1, context.getOptions().getFileExtensionsToMimeTypes()); String mimeType = SVNFileUtil.detectMimeType(localAbsPath2, context.getOptions().getFileExtensionsToMimeTypes());