本文整理汇总了C++中ZipFile::getNumEntries方法的典型用法代码示例。如果您正苦于以下问题:C++ ZipFile::getNumEntries方法的具体用法?C++ ZipFile::getNumEntries怎么用?C++ ZipFile::getNumEntries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZipFile
的用法示例。
在下文中一共展示了ZipFile::getNumEntries方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unzip
Result unzip (const MemoryBlock& data)
{
setStatusMessage ("Installing...");
File unzipTarget;
bool isUsingTempFolder = false;
{
MemoryInputStream input (data, false);
ZipFile zip (input);
if (zip.getNumEntries() == 0)
return Result::fail ("The downloaded file wasn't a valid JUCE file!");
unzipTarget = targetFolder;
if (unzipTarget.exists())
{
isUsingTempFolder = true;
unzipTarget = targetFolder.getNonexistentSibling();
if (! unzipTarget.createDirectory())
return Result::fail ("Couldn't create a folder to unzip the new version!");
}
Result r (zip.uncompressTo (unzipTarget));
if (r.failed())
{
if (isUsingTempFolder)
unzipTarget.deleteRecursively();
return r;
}
}
if (isUsingTempFolder)
{
File oldFolder (targetFolder.getSiblingFile (targetFolder.getFileNameWithoutExtension() + "_old")
.getNonexistentSibling());
if (! targetFolder.moveFileTo (oldFolder))
{
unzipTarget.deleteRecursively();
return Result::fail ("Could not remove the existing folder!");
}
if (! unzipTarget.moveFileTo (targetFolder))
{
unzipTarget.deleteRecursively();
return Result::fail ("Could not overwrite the existing folder!");
}
}
return Result::ok();
}
示例2: writeAPK
/*
* The directory hierarchy looks like this:
* "outputDir" and "assetRoot" are existing directories.
*
* On success, "bundle->numPackages" will be the number of Zip packages
* we created.
*/
status_t writeAPK(Bundle* bundle, int fd, const sp<OutputSet>& outputSet, bool isOverlay)
{
#if BENCHMARK
fprintf(stdout, "BENCHMARK: Starting APK Bundling \n");
long startAPKTime = clock();
#endif /* BENCHMARK */
status_t result = NO_ERROR;
ZipFile* zip = NULL;
status_t status;
zip = new ZipFile;
status = zip->openfd(fd, ZipFile::kOpenReadWrite);
if (status != NO_ERROR) {
fprintf(stderr, "ERROR: unable to open file as Zip file for writing\n");
result = PERMISSION_DENIED;
goto bail;
}
result = writeAPK(bundle, zip, "file_descriptor", outputSet, isOverlay);
if (result != NO_ERROR) {
fprintf(stderr, "ERROR: Writing apk failed\n");
goto bail;
}
/* anything here? */
if (zip->getNumEntries() == 0) {
if (bundle->getVerbose()) {
printf("Archive is empty -- removing\n");
}
delete zip; // close the file so we can remove it in Win32
zip = NULL;
close(fd);
}
assert(result == NO_ERROR);
bail:
delete zip; // must close before remove in Win32
close(fd);
if (result != NO_ERROR) {
if (bundle->getVerbose()) {
printf("Removing archive due to earlier failures\n");
}
}
if (result == NO_ERROR && bundle->getVerbose())
printf("Done!\n");
#if BENCHMARK
fprintf(stdout, "BENCHMARK: End APK Bundling. Time Elapsed: %f ms \n",(clock() - startAPKTime)/1000.0);
#endif /* BENCHMARK */
return result;
}
示例3: unzip
Result unzip (const ModuleList::Module& m, const MemoryBlock& data)
{
setStatusMessage ("Installing " + m.uid + "...");
MemoryInputStream input (data, false);
ZipFile zip (input);
if (zip.getNumEntries() == 0)
return Result::fail ("The downloaded file wasn't a valid module file!");
return zip.uncompressTo (targetList.getModulesFolder(), true);
}
示例4: createSVGDrawable
Drawable* ResourceLoader::createSVGDrawable(const String& filename)
{
initObjectIconMap();
if (iconsFromZipFile.size() == 0)
{
// If we've not already done so, load all the images from the zip file..
MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, false);
ZipFile icons (&iconsFileStream, false);
for (int i = 0; i < icons.getNumEntries(); ++i)
{
ScopedPointer<InputStream> svgFileStream (icons.createStreamForEntry (i));
if (svgFileStream != 0)
{
iconNames.add (icons.getEntry(i)->filename);
iconsFromZipFile.add (Drawable::createFromImageDataStream (*svgFileStream));
}
}
}
return iconsFromZipFile [iconNames.indexOf (filename)];//->createCopy();
}
示例5: writeAPK
//.........这里部分代码省略.........
if (count < 0) {
fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose()) {
printf("Generated %d file%s\n", count, (count==1) ? "" : "s");
}
count = processJarFiles(bundle, zip);
if (count < 0) {
fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose())
printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s");
result = NO_ERROR;
/*
* Check for cruft. We set the "marked" flag on all entries we created
* or decided not to update. If the entry isn't already slated for
* deletion, remove it now.
*/
{
if (bundle->getVerbose())
printf("Checking for deleted files\n");
int i, removed = 0;
for (i = 0; i < zip->getNumEntries(); i++) {
ZipEntry* entry = zip->getEntryByIndex(i);
if (!entry->getMarked() && entry->getDeleted()) {
if (bundle->getVerbose()) {
printf(" (removing crufty '%s')\n",
entry->getFileName());
}
zip->remove(entry);
removed++;
}
}
if (bundle->getVerbose() && removed > 0)
printf("Removed %d file%s\n", removed, (removed==1) ? "" : "s");
}
/* tell Zip lib to process deletions and other pending changes */
result = zip->flush();
if (result != NO_ERROR) {
fprintf(stderr, "ERROR: Zip flush failed, archive may be hosed\n");
goto bail;
}
/* anything here? */
if (zip->getNumEntries() == 0) {
if (bundle->getVerbose()) {
printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string());
}
delete zip; // close the file so we can remove it in Win32
zip = NULL;
if (unlink(outputFile.string()) != 0) {
fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string());
}
示例6: createSVGDrawable
void createSVGDrawable()
{
lastSVGLoadTime = Time::getCurrentTime();
MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, false);
ZipFile icons (&iconsFileStream, false);
// Load a random SVG file from our embedded icons.zip file.
const ScopedPointer<InputStream> svgFileStream (icons.createStreamForEntry (Random::getSystemRandom().nextInt (icons.getNumEntries())));
if (svgFileStream != nullptr)
{
svgDrawable = dynamic_cast <DrawableComposite*> (Drawable::createFromImageDataStream (*svgFileStream));
if (svgDrawable != nullptr)
{
// to make our icon the right size, we'll set its bounding box to the size and position that we want.
svgDrawable->setBoundingBox (RelativeParallelogram (Point<float> (-100, -100),
Point<float> (100, -100),
Point<float> (-100, 100)));
}
}
}
示例7: writeAPK
/*
* The directory hierarchy looks like this:
* "outputDir" and "assetRoot" are existing directories.
*
* On success, "bundle->numPackages" will be the number of Zip packages
* we created.
*/
status_t writeAPK(Bundle* bundle, const sp<AaptAssets>& assets,
const String8& outputFile)
{
status_t result = NO_ERROR;
ZipFile* zip = NULL;
int count;
//bundle->setPackageCount(0);
/*
* Prep the Zip archive.
*
* If the file already exists, fail unless "update" or "force" is set.
* If "update" is set, update the contents of the existing archive.
* Else, if "force" is set, remove the existing archive.
*/
FileType fileType = getFileType(outputFile.string());
if (fileType == kFileTypeNonexistent) {
// okay, create it below
} else if (fileType == kFileTypeRegular) {
if (bundle->getUpdate()) {
// okay, open it below
} else if (bundle->getForce()) {
if (unlink(outputFile.string()) != 0) {
fprintf(stderr, "ERROR: unable to remove '%s': %s\n", outputFile.string(),
strerror(errno));
goto bail;
}
} else {
fprintf(stderr, "ERROR: '%s' exists (use '-f' to force overwrite)\n",
outputFile.string());
goto bail;
}
} else {
fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.string());
goto bail;
}
if (bundle->getVerbose()) {
printf("%s '%s'\n", (fileType == kFileTypeNonexistent) ? "Creating" : "Opening",
outputFile.string());
}
status_t status;
zip = new ZipFile;
status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate);
if (status != NO_ERROR) {
fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n",
outputFile.string());
goto bail;
}
if (bundle->getVerbose()) {
printf("Writing all files...\n");
}
count = processAssets(bundle, zip, assets);
if (count < 0) {
fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose()) {
printf("Generated %d file%s\n", count, (count==1) ? "" : "s");
}
count = processJarFiles(bundle, zip);
if (count < 0) {
fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose())
printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s");
result = NO_ERROR;
/*
* Check for cruft. We set the "marked" flag on all entries we created
* or decided not to update. If the entry isn't already slated for
* deletion, remove it now.
*/
{
if (bundle->getVerbose())
printf("Checking for deleted files\n");
int i, removed = 0;
for (i = 0; i < zip->getNumEntries(); i++) {
ZipEntry* entry = zip->getEntryByIndex(i);
//.........这里部分代码省略.........
示例8: iconsFileStream
//==============================================================================
PreferencesPane::PreferencesPane (const Value& loudnessBarWidth,
const Value& loudnessBarMinValue,
const Value& loudnessBarMaxValue,
const Value& showIntegratedLoudnessHistoryValue,
const Value& showLoudnessRangeHistoryValue,
const Value& showShortTermLoudnessHistoryValue,
const Value& showMomentaryLoudnessHistoryValue)
: loudnessHistoryGroup (String::empty, "History Graph"),
showIntegratedLoudnessHistory ("I"),
showLoudnessRangeHistory("LRA"),
showShortTimeLoudnessHistory ("S"),
showMomentaryLoudnessHistory ("M")
{
// Get the icons from the embedded zip.
// ------------------------------------
// Source: JuceDemo WidgetsDemo.cpp:616
StringArray iconNames;
OwnedArray<Drawable> iconsFromZipFile;
const bool dontKeepInternalCopyOfData = false;
MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, dontKeepInternalCopyOfData);
const bool dontDeleteStreamWhenDestroyed = false;
ZipFile icons (&iconsFileStream, dontDeleteStreamWhenDestroyed);
for (int i = 0; i < icons.getNumEntries(); ++i)
{
ScopedPointer<InputStream> svgFileStream (icons.createStreamForEntry (i));
if (svgFileStream != 0)
{
// DBG(icons.getEntry(i)->filename);
iconNames.add (icons.getEntry(i)->filename);
iconsFromZipFile.add (Drawable::createFromImageDataStream (*svgFileStream));
}
}
ScopedPointer<DrawableComposite> wrench = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("wrenchByIonicons.svg")]->createCopy());
AnimatedSidePanel::setCaptionAndIcon("Preferences", wrench);
loudnessBarSizeLeftIcon = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("barsWide.svg")]->createCopy());
addAndMakeVisible (loudnessBarSizeLeftIcon);
loudnessBarSizeRightIcon = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("barsNarrow.svg")]->createCopy());
addAndMakeVisible (loudnessBarSizeRightIcon);
loudnessBarRangeLeftIcon = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("rangeArrow.svg")]->createCopy());
addAndMakeVisible (loudnessBarRangeLeftIcon);
resized();
const bool isReadOnly = false;
const int textEntryBoxWidth = 0;
const int textEntryBoxHeight = 0;
loudnessBarSize.setRange (-300.0, -5.0, 1.0); // This value multiplied by -1 results in the used with
// for each loudness bar. Negative values have been chosen to invert the behaviour of the slider
// (left side: big bars, right side: small bars).
loudnessBarSize.getValueObject().referTo(loudnessBarWidth);
loudnessBarSize.setTextBoxStyle(Slider::NoTextBox, isReadOnly, textEntryBoxWidth, textEntryBoxHeight);
loudnessBarSize.setColour(Slider::trackColourId, Colours::black);
addAndMakeVisible (&loudnessBarSize);
loudnessBarRange.setRange (-100, 0.0, 1.0);
loudnessBarRange.getMinValueObject().referTo (loudnessBarMinValue);
loudnessBarRange.getMaxValueObject().referTo (loudnessBarMaxValue);
loudnessBarRange.setTextBoxStyle (Slider::NoTextBox, isReadOnly, textEntryBoxWidth, textEntryBoxHeight);
loudnessBarRange.setPopupDisplayEnabled (true, this);
loudnessBarRange.setTextValueSuffix (" LUFS");
addAndMakeVisible (&loudnessBarRange);
addAndMakeVisible (&loudnessHistoryGroup);
showIntegratedLoudnessHistory.setClickingTogglesState (true);
showIntegratedLoudnessHistory.getToggleStateValue().referTo (showIntegratedLoudnessHistoryValue);
showIntegratedLoudnessHistory.setWantsKeyboardFocus (false);
loudnessHistoryGroup.addAndMakeVisible (&showIntegratedLoudnessHistory);
showLoudnessRangeHistory.setClickingTogglesState (true);
showLoudnessRangeHistory.getToggleStateValue().referTo (showLoudnessRangeHistoryValue);
showLoudnessRangeHistory.setWantsKeyboardFocus (false);
loudnessHistoryGroup.addAndMakeVisible (&showLoudnessRangeHistory);
showShortTimeLoudnessHistory.setClickingTogglesState (true);
showShortTimeLoudnessHistory.getToggleStateValue().referTo (showShortTermLoudnessHistoryValue);
showShortTimeLoudnessHistory.setWantsKeyboardFocus (false);
loudnessHistoryGroup.addAndMakeVisible (&showShortTimeLoudnessHistory);
showMomentaryLoudnessHistory.setClickingTogglesState (true);
showMomentaryLoudnessHistory.getToggleStateValue().referTo (showMomentaryLoudnessHistoryValue);
showMomentaryLoudnessHistory.setWantsKeyboardFocus (false);
loudnessHistoryGroup.addAndMakeVisible (&showMomentaryLoudnessHistory);
// Colours
// -------
setBackgroundColour (Colours::white.withAlpha (0.5f));
loudnessBarSize.setColour (Slider::thumbColourId, Colours::black);
loudnessBarRange.setColour (Slider::thumbColourId, Colours::black);
//.........这里部分代码省略.........