void lcsSpeciesSourcePluginFunction::doEvaluation() { wordList speciesList; label speciesIndex=getIndex(speciesList); if(speciesList.size()==0) { listAvailableClouds(Info); FatalErrorIn("lcsSpeciesSourcePluginFunction::doEvaluation()") << "No species list found (probably wrong cloud type)" << endl << "Supported cloud types (typeid): " \ << supportedTypes() << endl \ << exit(FatalError); } if(speciesIndex<0) { listAvailableClouds(Info); FatalErrorIn("lcsSpeciesSourcePluginFunction::doEvaluation()") << "Species " << speciesName_ << " not found in gas composition " << speciesList << endl << "Supported cloud types (typeid): " \ << supportedTypes() << endl \ << exit(FatalError); } autoPtr<dimScalarField> pSrho=internalEvaluate(speciesIndex);; noCloudFound(pSrho); const dimScalarField &Srho=pSrho(); autoPtr<volScalarField> pSource( new volScalarField( IOobject( cloudName()+"SpeciesSource", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh(), Srho.dimensions(), "zeroGradient" ) ); pSource->internalField()=Srho.field(); result().setObjectResult(pSource); }
static void initializeSupportedImageMIMETypesForEncoding() { supportedImageMIMETypesForEncoding = new HashSet<String>; #if PLATFORM(CG) #if PLATFORM(MAC) RetainPtr<CFArrayRef> supportedTypes(AdoptCF, CGImageDestinationCopyTypeIdentifiers()); CFIndex count = CFArrayGetCount(supportedTypes.get()); for (CFIndex i = 0; i < count; i++) { RetainPtr<CFStringRef> supportedType(AdoptCF, reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i))); String mimeType = MIMETypeForImageSourceType(supportedType.get()); if (!mimeType.isEmpty()) supportedImageMIMETypesForEncoding->add(mimeType); } #else // FIXME: Add Windows support for all the supported UTI's when a way to convert from MIMEType to UTI reliably is found. // For now, only support PNG, JPEG and GIF. See <rdar://problem/6095286>. supportedImageMIMETypesForEncoding->add("image/png"); supportedImageMIMETypesForEncoding->add("image/jpeg"); supportedImageMIMETypesForEncoding->add("image/gif"); #endif #elif PLATFORM(QT) QList<QByteArray> formats = QImageWriter::supportedImageFormats(); for (int i = 0; i < formats.size(); ++i) { String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData()); supportedImageMIMETypesForEncoding->add(mimeType); } supportedImageMIMETypesForEncoding->remove("application/octet-stream"); #elif PLATFORM(CAIRO) supportedImageMIMETypesForEncoding->add("image/png"); #endif }
static void initializeSupportedImageMIMETypesForEncoding() { supportedImageMIMETypesForEncoding = new HashSet<String>; #if PLATFORM(CG) #if PLATFORM(MAC) RetainPtr<CFArrayRef> supportedTypes(AdoptCF, CGImageDestinationCopyTypeIdentifiers()); CFIndex count = CFArrayGetCount(supportedTypes.get()); for (CFIndex i = 0; i < count; i++) { RetainPtr<CFStringRef> supportedType(AdoptCF, reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i))); String mimeType = getMIMETypeForUTI(supportedType.get()); if (!mimeType.isEmpty()) supportedImageMIMETypesForEncoding->add(mimeType); } #else // FIXME: Add Windows support for all the supported UTI's when a way to convert from MIMEType to UTI reliably is found. // For now, only support PNG, the minimum that the spec requires. supportedImageMIMETypesForEncoding->add("image/png"); #endif #elif PLATFORM(QT) QList<QByteArray> formats = QImageWriter::supportedImageFormats(); for (size_t i = 0; i < formats.size(); ++i) { String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData()); supportedImageMIMETypesForEncoding->add(mimeType); } #endif }
static void initializeSupportedImageMIMETypes() { #if PLATFORM(CG) RetainPtr<CFArrayRef> supportedTypes(AdoptCF, CGImageSourceCopyTypeIdentifiers()); CFIndex count = CFArrayGetCount(supportedTypes.get()); for (CFIndex i = 0; i < count; i++) { RetainPtr<CFStringRef> supportedType(AdoptCF, reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i))); String mimeType = getMIMETypeForUTI(supportedType.get()); if (!mimeType.isEmpty()) { supportedImageMIMETypes->add(mimeType); supportedImageResourceMIMETypes->add(mimeType); } } // On Tiger and Leopard, com.microsoft.bmp doesn't have a MIME type in the registry. supportedImageMIMETypes->add("image/bmp"); supportedImageResourceMIMETypes->add("image/bmp"); // Favicons don't have a MIME type in the registry either. supportedImageMIMETypes->add("image/x-icon"); supportedImageResourceMIMETypes->add("image/x-icon"); // We only get one MIME type per UTI, hence our need to add these manually supportedImageMIMETypes->add("image/pjpeg"); supportedImageResourceMIMETypes->add("image/pjpeg"); // We don't want to try to treat all binary data as an image supportedImageMIMETypes->remove("application/octet-stream"); supportedImageResourceMIMETypes->remove("application/octet-stream"); // Don't treat pdf/postscript as images directly supportedImageMIMETypes->remove("application/pdf"); supportedImageMIMETypes->remove("application/postscript"); #elif PLATFORM(QT) QList<QByteArray> formats = QImageReader::supportedImageFormats(); for (size_t i = 0; i < formats.size(); ++i) { #if ENABLE(SVG) /* * Qt has support for SVG, but we want to use KSVG2 */ if (formats.at(i).toLower().startsWith("svg")) continue; #endif String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData()); supportedImageMIMETypes->add(mimeType); supportedImageResourceMIMETypes->add(mimeType); } #else // assume that all implementations at least support the following standard // image types: static const char* types[] = { "image/jpeg", "image/png", "image/gif", "image/bmp", "image/x-icon", // ico "image/x-xbitmap" // xbm }; for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i) { supportedImageMIMETypes->add(types[i]); supportedImageResourceMIMETypes->add(types[i]); } #endif }
void _NewPartition() { if (!fPrepared) { if (fDevice->IsReadOnly()) printf("Device is read-only!\n"); else printf("Sorry, not prepared for modifications!\n"); return; } // get the parent partition BPartition* partition = NULL; int32 partitionIndex; if (!_SelectPartition("parent partition index [-1 to abort]: ", partition, partitionIndex)) { return; } printf("\nselected partition:\n\n"); print_partition_table_header(); print_partition(partition, 0, partitionIndex); if (!partition->ContainsPartitioningSystem()) { printf("The selected partition does not contain a partitioning " "system.\n"); return; } // get supported types BObjectList<BString> supportedTypes(20, true); BString typeBuffer; int32 cookie = 0; while (partition->GetNextSupportedChildType(&cookie, &typeBuffer) == B_OK) { supportedTypes.AddItem(new BString(typeBuffer)); } if (supportedTypes.IsEmpty()) { printf("The partitioning system is not able to create any " "child partition (no supported types).\n"); return; } // get partitioning info BPartitioningInfo partitioningInfo; status_t error = partition->GetPartitioningInfo(&partitioningInfo); if (error != B_OK) { printf("Failed to get partitioning info for partition: %s\n", strerror(error)); return; } int32 spacesCount = partitioningInfo.CountPartitionableSpaces(); if (spacesCount == 0) { printf("There's no space on the partition where a child partition " "could be created\n"); return; } // let the user select the partition type, if there's more than one int64 typeIndex = 0; int32 supportedTypesCount = supportedTypes.CountItems(); if (supportedTypesCount > 1) { // list them printf("Possible partition types:\n"); for (int32 i = 0; i < supportedTypesCount; i++) printf("%2ld %s\n", i, supportedTypes.ItemAt(i)->String()); if (!_ReadNumber("supported type index [-1 to abort]: ", 0, supportedTypesCount - 1, -1, "invalid index", typeIndex)) { return; } } const char* type = supportedTypes.ItemAt(typeIndex)->String(); // list partitionable spaces printf("Unused regions where the new partition could be created:\n"); for (int32 i = 0; i < spacesCount; i++) { off_t _offset; off_t _size; partitioningInfo.GetPartitionableSpaceAt(i, &_offset, &_size); BString offset, size; get_size_string(_offset, offset); get_size_string(_size, size); printf("%2ld start: %8s, size: %8s\n", i, offset.String(), size.String()); } // let the user select the partitionable space, if there's more than one int64 spaceIndex = 0; if (spacesCount > 1) { if (!_ReadNumber("unused region index [-1 to abort]: ", 0, spacesCount - 1, -1, "invalid index", spaceIndex)) { return; } } off_t spaceOffset; off_t spaceSize; partitioningInfo.GetPartitionableSpaceAt(spaceIndex, &spaceOffset, &spaceSize); off_t start; off_t size; BString parameters; while (true) { // let the user enter start, size, and parameters // start while (true) { BString spaceOffsetString; get_size_string(spaceOffset, spaceOffsetString); BString prompt("partition start [default: "); prompt << spaceOffsetString << "]: "; if (!_ReadSize(prompt.String(), spaceOffset, start)) return; if (start >= spaceOffset && start <= spaceOffset + spaceSize) break; printf("invalid partition start\n"); } // size off_t maxSize = spaceOffset + spaceSize - start; while (true) { BString maxSizeString; get_size_string(maxSize, maxSizeString); BString prompt("partition size [default: "); prompt << maxSizeString << "]: "; if (!_ReadSize(prompt.String(), maxSize, size)) return; if (size >= 0 && start + size <= spaceOffset + spaceSize) break; printf("invalid partition size\n"); } // parameters if (!_ReadLine("partition parameters: ", parameters)) return; // validate parameters off_t validatedStart = start; off_t validatedSize = size; // TODO: Support the name parameter! if (partition->ValidateCreateChild(&start, &size, type, NULL, parameters.String()) != B_OK) { printf("Validation of the given values failed. Sorry, can't " "continue.\n"); return; } // did the disk system change offset or size? if (validatedStart == start && validatedSize == size) { printf("Everything looks dandy.\n"); } else { BString startString, sizeString; get_size_string(validatedStart, startString); get_size_string(validatedSize, sizeString); printf("The disk system adjusted the partition start and " "size to %lld (%s) and %lld (%s).\n", validatedStart, startString.String(), validatedSize, sizeString.String()); start = validatedStart; size = validatedSize; } // let the user decide whether to continue, change parameters, or // abort bool changeParameters = false; while (true) { BString line; _ReadLine("[c]ontinue, change [p]arameters, or [a]bort? ", line); if (line == "a") return; if (line == "p") { changeParameters = true; break; } if (line == "c") break; printf("invalid input\n"); } if (!changeParameters) break; } // create child error = partition->CreateChild(start, size, type, NULL, parameters.String()); if (error != B_OK) printf("Creating the partition failed: %s\n", strerror(error)); }