本文整理汇总了C++中FileName::removeAllPrefixes方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::removeAllPrefixes方法的具体用法?C++ FileName::removeAllPrefixes怎么用?C++ FileName::removeAllPrefixes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::removeAllPrefixes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkImageFileSize
bool checkImageFileSize(const FileName &name, const ImageInfo &imgInfo, bool error)
{
FileName ext = name.getExtension();
FileName dataFname;
if ( ext.contains("hed"))
dataFname = name.removeLastExtension().addExtension("img");
else if (ext.contains("inf"))
dataFname = name.removeLastExtension();
else if (ext.contains("tif") || ext.contains("jpg") || ext.contains("hdf") || ext.contains("h5"))
return true;
else
dataFname = name;
size_t expectedSize = imgInfo.adim.nzyxdim*gettypesize(imgInfo.datatype) + imgInfo.offset;
size_t actualSize = dataFname.removeAllPrefixes().removeFileFormat().getFileSize();
bool result = (actualSize >= expectedSize);
if (error && !result)
REPORT_ERROR(ERR_IO_SIZE, formatString("Image Extension: File %s has wrong size.\n"
"Expected size (at least) %u bytes. Actual size %u bytes.", name.c_str(), expectedSize, actualSize));
return result;
}
示例2: processImage
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
{
ImageGeneric img;
switch (operation)
{
case HEADER_PRINT:
img.read(fnImg, _HEADER_ALL);
img.print();
break;
case HEADER_EXTRACT:
img.read(fnImg, _HEADER_ALL);
rowOut = img.getGeometry();
if (round_shifts)
roundShifts(rowOut);
rowOut.setValue(MDL_IMAGE, fnImgOut);
break;
case HEADER_ASSIGN:
rowOut = rowIn;
if (round_shifts)
roundShifts(rowOut);
img.readApplyGeo(fnImg, rowOut, params);
img.setDataMode(_HEADER_ALL);
img.write(fnImg, ALL_IMAGES, fnImg.isInStack(), WRITE_REPLACE);
break;
case HEADER_RESET:
img.read(fnImg, _HEADER_ALL);
img.initGeometry();
img.write(fnImg, ALL_IMAGES, fnImg.isInStack(), WRITE_REPLACE);
break;
case HEADER_SAMPLINGRATE:
{
img.read(fnImg, _HEADER_ALL);
if (sampling < 0)
{
double samplingRead;
img.image->MDMainHeader.getValue(MDL_SAMPLINGRATE_X, samplingRead);
std::cout << samplingRead << std::endl;
}
else
{
img.image->MDMainHeader.setValue(MDL_SAMPLINGRATE_X, sampling);
img.image->MDMainHeader.setValue(MDL_SAMPLINGRATE_Y, sampling);
img.image->MDMainHeader.setValue(MDL_SAMPLINGRATE_Z, sampling);
img.write(fnImg, ALL_IMAGES, fnImg.isInStack(), WRITE_REPLACE);
std::cout << "New sampling rate (Angstrom) = " << sampling << std::endl;
}
}
break;
case HEADER_TREE:
{
XmippH5File H5File;
FileName filename = fnImg.removeAllPrefixes().removeFileFormat();
if (H5File.isHdf5(filename.c_str()))
{
H5File.openFile(fnImg.removeAllPrefixes().removeFileFormat(), H5F_ACC_RDONLY);
H5File.showTree();
}
else
REPORT_ERROR(ERR_IMG_UNKNOWN, "Unknown file format to display its data structure.");
}
break;
}
}