本文整理汇总了Java中com.cloud.storage.Storage.ImageFormat.TAR属性的典型用法代码示例。如果您正苦于以下问题:Java ImageFormat.TAR属性的具体用法?Java ImageFormat.TAR怎么用?Java ImageFormat.TAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.cloud.storage.Storage.ImageFormat
的用法示例。
在下文中一共展示了ImageFormat.TAR属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
@Override
public FormatInfo process(final String templatePath, final ImageFormat format, final String templateName) {
if (format != null) {
s_logger.debug("We currently don't handle conversion from " + format + " to TAR.");
return null;
}
final String tarPath = templatePath + File.separator + templateName + "." + ImageFormat.TAR.getFileExtension();
if (!_storage.exists(tarPath)) {
s_logger.debug("Unable to find the tar file: " + tarPath);
return null;
}
final FormatInfo info = new FormatInfo();
info.format = ImageFormat.TAR;
info.filename = templateName + "." + ImageFormat.TAR.getFileExtension();
final File tarFile = _storage.getFile(tarPath);
info.size = _storage.getSize(tarPath);
info.virtualSize = getVirtualSize(tarFile);
return info;
}
示例2: getTemplateFormat
private ImageFormat getTemplateFormat(final String filePath) {
String ext = null;
final int extensionPos = filePath.lastIndexOf('.');
final int lastSeparator = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
final int i = lastSeparator > extensionPos ? -1 : extensionPos;
if (i > 0) {
ext = filePath.substring(i + 1);
}
if (ext != null) {
if (ext.equalsIgnoreCase("vhd")) {
return ImageFormat.VHD;
} else if (ext.equalsIgnoreCase("qcow2")) {
return ImageFormat.QCOW2;
} else if (ext.equalsIgnoreCase("tar")) {
return ImageFormat.TAR;
} else if (ext.equalsIgnoreCase("img") || ext.equalsIgnoreCase("raw")) {
return ImageFormat.RAW;
} else if (ext.equalsIgnoreCase("vdi")) {
return ImageFormat.VDI;
}
}
return null;
}
示例3: getVirtualSize
protected long getVirtualSize(final File file, final ImageFormat format) {
Processor processor = null;
try {
if (format == null) {
return file.length();
} else if (format == ImageFormat.QCOW2) {
processor = new QCOW2Processor();
} else if (format == ImageFormat.VHD) {
processor = new VhdProcessor();
} else if (format == ImageFormat.RAW) {
processor = new RawImageProcessor();
}
if (format == ImageFormat.TAR) {
processor = new TARProcessor();
}
if (processor == null) {
return file.length();
}
final Map<String, Object> params = new HashMap<>();
params.put(StorageLayer.InstanceConfigKey, _storage);
processor.configure("template processor", params);
return processor.getVirtualSize(file);
} catch (final Exception e) {
s_logger.warn("Failed to get virtual size of file " + file.getPath() + ", returning file size instead: ", e);
return file.length();
}
}