Common::SeekableReadStream *MsCabinet::createReadStreamForMember(const Common::String &name) const { byte *fileBuf; if (!hasFile(name)) return 0; const FileEntry &entry = _fileMap[name]; //Check if the file has already been decompressed and it's in the cache, // otherwise decompress it and put it in the cache if (_cache.contains(name)) fileBuf = _cache[name]; else { //Check if the decompressor should be reinitialized if (!_decompressor || entry.folder != _decompressor->getFolder()) { if (_decompressor) delete _decompressor; _decompressor = new Decompressor(entry.folder, _data); } if (!_decompressor->decompressFile(fileBuf, entry)) return 0; _cache[name] = fileBuf; } return new Common::MemoryReadStream(fileBuf, entry.length, DisposeAfterUse::NO); }
const Common::ArchiveMemberPtr Lab::getMember(const Common::String &name) const { if (!hasFile(name)) return Common::ArchiveMemberPtr(); Common::String fname(name); fname.toLowercase(); return _entries[fname]; }
IMpkFileManip* MpkManip::openFile(const char* filename) { if(!hasFile(filename))return 0; HANDLE hFile = 0; if(!SFileOpenFileEx(m_hMpk,filename,0,&hFile))return 0; return new MpkFileManip(hFile); }
bool ModVersion::addFile(ModVersionFile * file) { if(file == NULL || Utilities::stringLength(file->getName()) == 0 || hasFile(*file)) { return false; } m_files.push_back(file); return true; }
bool PicManager::nextPic() { if(!hasFile() || list.size() < 1) return false; // currentIndex = getNextIndex(currentIndex); readFile(currentIndex); preReadingNextPic(); return true; }
bool Field::hasFiles() const { for(int i=0 ; i<files.size() ; ++i) { if(hasFile((FileType)i)) { return true; } } return hasFiles2() || hasCharaFile(); }
bool PicManager::prePic() { // maybe current file is not a picture, and current dir has no any picture also, so we need check if(list.size() < 1). if(!hasFile() || list.size() < 1) return false; currentIndex = getPreIndex(currentIndex); readFile(currentIndex); preReadingPrePic(); return true; }
// Get a stream to file in the archive // - same as createReadStreamForMember except it checks if the file exists and will assert / output a debug message if not Common::SeekableReadStream *ResourceManager::getFileStream(const Common::String &name) const { // Check if the file exits in the archive if (!hasFile(name)) { debugC(2, kLastExpressDebugResource, "Error opening file: %s", name.c_str()); return NULL; } debugC(2, kLastExpressDebugResource, "Opening file: %s", name.c_str()); return createReadStreamForMember(name); }
void PicManager::deleteFile(bool needAsk) { if(!hasFile() || !QFile::exists(curPath)) return; if(needAsk){ int ret = QMessageBox::question( 0, tr("Delete File"), tr("Are you sure to delete file '%1'?").arg(curName), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if(ret == QMessageBox::No) return; } curImage->recycle(); OSRelated::moveFile2Trash(curPath); /// }
Common::SeekableReadStream *Lab::createReadStreamForMember(const Common::String &filename) const { if (!hasFile(filename)) return 0; Common::String fname(filename); fname.toLowercase(); LabEntryPtr i = _entries[fname]; /*If the whole Lab has been loaded into ram, we return a MemoryReadStream that map requested data directly, without copying them. Otherwise open a new stream from disk.*/ if(_memLab) return new Common::MemoryReadStream((_memLab + i->_offset), i->_len, DisposeAfterUse::NO); Common::File *file = new Common::File(); file->open(_labFileName); return new Common::SeekableSubReadStream(file, i->_offset, i->_offset + i->_len, DisposeAfterUse::YES ); }
DictionaryTriePerfTest(int32_t argc, const char *argv[], UErrorCode &status) : UPerfTest(argc, argv, NULL, 0, "", status), numTextLines(0) { if(hasFile()) { getLines(status); for(int32_t i=0; i<numLines; ++i) { // Skip comment lines (start with a character below 'A'). if(lines[i].name[0]>=0x41) { ++numTextLines; // Remove trailing CR LF. int32_t len=lines[i].len; UChar c; while(len>0 && ((c=lines[i].name[len-1])==0xa || c==0xd)) { --len; } lines[i].len=len; } } } }
std::istream& ZipFileInput::openFile(const stromx::runtime::InputProvider::OpenMode mode) { if(! m_initialized) throw WrongState("Zip file input has not been initialized."); if(m_currentFile) throw WrongState("File has already been opened."); if(! hasFile()) throw NoInputFile(); std::ios_base::openmode iosmode = std::ios_base::in; if(mode == BINARY) iosmode |= std::ios_base::binary; struct zip_stat stat; if(zip_stat(m_archiveHandle, m_currentFilename.c_str(), 0, &stat) < 0) throw FileAccessFailed(m_currentFilename, m_archive, "Failed to access file in zip archive."); if(stat.size == 0) throw FileAccessFailed(m_currentFilename, m_archive, "File in zip archive has zero size."); unsigned int fileSize = (unsigned int)(stat.size); std::vector<char> content(fileSize); zip_file* file = zip_fopen(m_archiveHandle, m_currentFilename.c_str(), 0); if(! file) throw FileAccessFailed(m_currentFilename, m_archive, "Failed to open file in zip archive."); if((unsigned int)(zip_fread(file, &content[0], fileSize)) != fileSize) throw FileAccessFailed(m_currentFilename, m_archive, "Failed to read file in zip archive."); m_currentFile = new std::istringstream(std::string(&content[0], fileSize), iosmode); return *m_currentFile; }
bool Field::hasPmdFile() const { return hasFile(Pmd); }
EntryFile *Entry::file() const { ASSERT(hasFile()); return file_; }
bool Field::hasPvpFile() const { return hasFile(Pvp); }
UPerfFunction *DictionaryTriePerfTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) { if(hasFile()) { switch(index) { case 0: name="ucharstriematches"; if(exec) { return new UCharsTrieDictMatches(*this); } break; case 1: name="ucharstriecontains"; if(exec) { return new UCharsTrieDictContains(*this); } break; case 2: name="bytestriematches"; if(exec) { return new BytesTrieDictMatches(*this); } break; case 3: name="bytestriecontains"; if(exec) { return new BytesTrieDictContains(*this); } break; default: name=""; break; } } else { if(index==0 && exec) { puts("Running BytesTrie perf tests on the .dat package file from the --sourcedir.\n" "For UCharsTrie perf tests on a dictionary text file, specify the -f or --file-name.\n"); } switch(index) { case 0: name="simplebinarysearch"; if(exec) { return new BinarySearchPackageLookup(*this); } break; case 1: name="prefixbinarysearch"; if(exec) { return new PrefixBinarySearchPackageLookup(*this); } break; case 2: name="bytestrie"; if(exec) { return new BytesTriePackageLookup(*this); } break; default: name=""; break; } } return NULL; }
bool Field::hasSfxFile() const { return hasFile(Sfx); }
ArchiveMemberPtr ZipArchive::getMember(const String &name) { if (!hasFile(name)) return ArchiveMemberPtr(); return ArchiveMemberPtr(new GenericArchiveMember(name, this)); }
bool Field::hasInfFile() const { return hasFile(Inf); }
const ArchiveMemberPtr CdfArchive::getMember(const String &name) const { return hasFile(name) ? ArchiveMemberPtr(new GenericArchiveMember(name, this)) : ArchiveMemberPtr(); }
bool Field::hasTdwFile() const { return hasFile(Tdw); }
bool Field::hasMskFile() const { return hasFile(Msk); }
Common::SeekableReadStream *AndroidAssetArchive::createReadStreamForMember(const Common::String &path) const { if (!hasFile(path)) { return nullptr; } return new AssetInputStream(_am, path); }
const Common::ArchiveMemberPtr ResourceManager::getMember(const Common::String &name) const { if (!hasFile(name)) return Common::ArchiveMemberPtr(); return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); }
bool Field::hasPmpFile() const { return hasFile(Pmp); }
bool Field::hasBackgroundFile() const { return hasFile(Background); }
/* * Start the Dalvik Virtual Machine. * * Various arguments, most determined by system properties, are passed in. * The "mOptions" vector is updated. * * CAUTION: when adding options in here, be careful not to put the * char buffer inside a nested scope. Adding the buffer to the * options using mOptions.add() does not copy the buffer, so if the * buffer goes out of scope the option may be overwritten. It's best * to put the buffer at the top of the function so that it is more * unlikely that someone will surround it in a scope at a later time * and thus introduce a bug. * * Returns 0 on success. */ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) { int result = -1; JavaVMInitArgs initArgs; char propBuf[PROPERTY_VALUE_MAX]; char stackTraceFileBuf[sizeof("-Xstacktracefile:")-1 + PROPERTY_VALUE_MAX]; char jniOptsBuf[sizeof("-Xjniopts:")-1 + PROPERTY_VALUE_MAX]; char heapstartsizeOptsBuf[sizeof("-Xms")-1 + PROPERTY_VALUE_MAX]; char heapsizeOptsBuf[sizeof("-Xmx")-1 + PROPERTY_VALUE_MAX]; char heapgrowthlimitOptsBuf[sizeof("-XX:HeapGrowthLimit=")-1 + PROPERTY_VALUE_MAX]; char heapminfreeOptsBuf[sizeof("-XX:HeapMinFree=")-1 + PROPERTY_VALUE_MAX]; char heapmaxfreeOptsBuf[sizeof("-XX:HeapMaxFree=")-1 + PROPERTY_VALUE_MAX]; char gctypeOptsBuf[sizeof("-Xgc:")-1 + PROPERTY_VALUE_MAX]; char backgroundgcOptsBuf[sizeof("-XX:BackgroundGC=")-1 + PROPERTY_VALUE_MAX]; char heaptargetutilizationOptsBuf[sizeof("-XX:HeapTargetUtilization=")-1 + PROPERTY_VALUE_MAX]; char dex2oatXmsImageFlagsBuf[sizeof("-Xms")-1 + PROPERTY_VALUE_MAX]; char dex2oatXmxImageFlagsBuf[sizeof("-Xmx")-1 + PROPERTY_VALUE_MAX]; char dex2oatXmsFlagsBuf[sizeof("-Xms")-1 + PROPERTY_VALUE_MAX]; char dex2oatXmxFlagsBuf[sizeof("-Xmx")-1 + PROPERTY_VALUE_MAX]; char dex2oatCompilerFilterBuf[sizeof("--compiler-filter=")-1 + PROPERTY_VALUE_MAX]; char dex2oatImageCompilerFilterBuf[sizeof("--compiler-filter=")-1 + PROPERTY_VALUE_MAX]; char dex2oatFlagsBuf[PROPERTY_VALUE_MAX]; char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX]; char extraOptsBuf[PROPERTY_VALUE_MAX]; char voldDecryptBuf[PROPERTY_VALUE_MAX]; enum { kEMDefault, kEMIntPortable, kEMIntFast, kEMJitCompiler, } executionMode = kEMDefault; char profilePeriod[sizeof("-Xprofile-period:")-1 + PROPERTY_VALUE_MAX]; char profileDuration[sizeof("-Xprofile-duration:")-1 + PROPERTY_VALUE_MAX]; char profileInterval[sizeof("-Xprofile-interval:")-1 + PROPERTY_VALUE_MAX]; char profileBackoff[sizeof("-Xprofile-backoff:")-1 + PROPERTY_VALUE_MAX]; char profileTopKThreshold[sizeof("-Xprofile-top-k-threshold:")-1 + PROPERTY_VALUE_MAX]; char profileTopKChangeThreshold[sizeof("-Xprofile-top-k-change-threshold:")-1 + PROPERTY_VALUE_MAX]; char profileType[sizeof("-Xprofile-type:")-1 + PROPERTY_VALUE_MAX]; char profileMaxStackDepth[sizeof("-Xprofile-max-stack-depth:")-1 + PROPERTY_VALUE_MAX]; char langOption[sizeof("-Duser.language=") + 3]; char regionOption[sizeof("-Duser.region=") + 3]; char lockProfThresholdBuf[sizeof("-Xlockprofthreshold:")-1 + PROPERTY_VALUE_MAX]; char nativeBridgeLibrary[sizeof("-XX:NativeBridge=") + PROPERTY_VALUE_MAX]; bool checkJni = false; property_get("dalvik.vm.checkjni", propBuf, ""); if (strcmp(propBuf, "true") == 0) { checkJni = true; } else if (strcmp(propBuf, "false") != 0) { /* property is neither true nor false; fall back on kernel parameter */ property_get("ro.kernel.android.checkjni", propBuf, ""); if (propBuf[0] == '1') { checkJni = true; } } ALOGD("CheckJNI is %s\n", checkJni ? "ON" : "OFF"); if (checkJni) { /* extended JNI checking */ addOption("-Xcheck:jni"); /* with -Xcheck:jni, this provides a JNI function call trace */ //addOption("-verbose:jni"); } property_get("dalvik.vm.execution-mode", propBuf, ""); if (strcmp(propBuf, "int:portable") == 0) { executionMode = kEMIntPortable; } else if (strcmp(propBuf, "int:fast") == 0) { executionMode = kEMIntFast; } else if (strcmp(propBuf, "int:jit") == 0) { executionMode = kEMJitCompiler; } parseRuntimeOption("dalvik.vm.stack-trace-file", stackTraceFileBuf, "-Xstacktracefile:"); strcpy(jniOptsBuf, "-Xjniopts:"); if (parseRuntimeOption("dalvik.vm.jniopts", jniOptsBuf, "-Xjniopts:")) { ALOGI("JNI options: '%s'\n", jniOptsBuf); } /* route exit() to our handler */ addOption("exit", (void*) runtime_exit); /* route fprintf() to our handler */ addOption("vfprintf", (void*) runtime_vfprintf); /* register the framework-specific "is sensitive thread" hook */ addOption("sensitiveThread", (void*) runtime_isSensitiveThread); /* enable verbose; standard options are { jni, gc, class } */ //addOption("-verbose:jni"); addOption("-verbose:gc"); //addOption("-verbose:class"); /* * The default starting and maximum size of the heap. Larger * values should be specified in a product property override. */ parseRuntimeOption("dalvik.vm.heapstartsize", heapstartsizeOptsBuf, "-Xms", "4m"); parseRuntimeOption("dalvik.vm.heapsize", heapsizeOptsBuf, "-Xmx", "16m"); parseRuntimeOption("dalvik.vm.heapgrowthlimit", heapgrowthlimitOptsBuf, "-XX:HeapGrowthLimit="); parseRuntimeOption("dalvik.vm.heapminfree", heapminfreeOptsBuf, "-XX:HeapMinFree="); parseRuntimeOption("dalvik.vm.heapmaxfree", heapmaxfreeOptsBuf, "-XX:HeapMaxFree="); parseRuntimeOption("dalvik.vm.heaptargetutilization", heaptargetutilizationOptsBuf, "-XX:HeapTargetUtilization="); property_get("ro.config.low_ram", propBuf, ""); if (strcmp(propBuf, "true") == 0) { addOption("-XX:LowMemoryMode"); } parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:"); parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC="); /* enable debugging; set suspend=y to pause during VM init */ /* use android ADB transport */ addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y"); parseRuntimeOption("dalvik.vm.lockprof.threshold", lockProfThresholdBuf, "-Xlockprofthreshold:"); if (executionMode == kEMIntPortable) { addOption("-Xint:portable"); } else if (executionMode == kEMIntFast) { addOption("-Xint:fast"); } else if (executionMode == kEMJitCompiler) { addOption("-Xint:jit"); } // If we are booting without the real /data, don't spend time compiling. property_get("vold.decrypt", voldDecryptBuf, ""); bool skip_compilation = ((strcmp(voldDecryptBuf, "trigger_restart_min_framework") == 0) || (strcmp(voldDecryptBuf, "1") == 0)); // Extra options for boot.art/boot.oat image generation. parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xms", dex2oatXmsImageFlagsBuf, "-Xms", "-Ximage-compiler-option"); parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xmx", dex2oatXmxImageFlagsBuf, "-Xmx", "-Ximage-compiler-option"); if (skip_compilation) { addOption("-Ximage-compiler-option"); addOption("--compiler-filter=verify-none"); } else { parseCompilerOption("dalvik.vm.image-dex2oat-filter", dex2oatImageCompilerFilterBuf, "--compiler-filter=", "-Ximage-compiler-option"); } // Make sure there is a preloaded-classes file. if (!hasFile("/system/etc/preloaded-classes")) { ALOGE("Missing preloaded-classes file, /system/etc/preloaded-classes not found: %s\n", strerror(errno)); goto bail; } addOption("-Ximage-compiler-option"); addOption("--image-classes=/system/etc/preloaded-classes"); // If there is a compiled-classes file, push it. if (hasFile("/system/etc/compiled-classes")) { addOption("-Ximage-compiler-option"); addOption("--compiled-classes=/system/etc/compiled-classes"); } property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, ""); parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option"); // Extra options for DexClassLoader. parseCompilerRuntimeOption("dalvik.vm.dex2oat-Xms", dex2oatXmsFlagsBuf, "-Xms", "-Xcompiler-option"); parseCompilerRuntimeOption("dalvik.vm.dex2oat-Xmx", dex2oatXmxFlagsBuf, "-Xmx", "-Xcompiler-option"); if (skip_compilation) { addOption("-Xcompiler-option"); addOption("--compiler-filter=verify-none"); // We skip compilation when a minimal runtime is brought up for decryption. In that case // /data is temporarily backed by a tmpfs, which is usually small. // If the system image contains prebuilts, they will be relocated into the tmpfs. In this // specific situation it is acceptable to *not* relocate and run out of the prebuilts // directly instead. addOption("--runtime-arg"); addOption("-Xnorelocate"); } else { parseCompilerOption("dalvik.vm.dex2oat-filter", dex2oatCompilerFilterBuf, "--compiler-filter=", "-Xcompiler-option"); } property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, ""); parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option"); /* extra options; parse this late so it overrides others */ property_get("dalvik.vm.extra-opts", extraOptsBuf, ""); parseExtraOpts(extraOptsBuf, NULL); /* Set the properties for locale */ { strcpy(langOption, "-Duser.language="); strcpy(regionOption, "-Duser.region="); readLocale(langOption, regionOption); addOption(langOption); addOption(regionOption); } /* * Set profiler options */ // Whether or not the profiler should be enabled. property_get("dalvik.vm.profiler", propBuf, "0"); if (propBuf[0] == '1') { addOption("-Xenable-profiler"); } // Whether the profile should start upon app startup or be delayed by some random offset // (in seconds) that is bound between 0 and a fixed value. property_get("dalvik.vm.profile.start-immed", propBuf, "0"); if (propBuf[0] == '1') { addOption("-Xprofile-start-immediately"); } // Number of seconds during profile runs. parseRuntimeOption("dalvik.vm.profile.period-secs", profilePeriod, "-Xprofile-period:"); // Length of each profile run (seconds). parseRuntimeOption("dalvik.vm.profile.duration-secs", profileDuration, "-Xprofile-duration:"); // Polling interval during profile run (microseconds). parseRuntimeOption("dalvik.vm.profile.interval-us", profileInterval, "-Xprofile-interval:"); // Coefficient for period backoff. The the period is multiplied // by this value after each profile run. parseRuntimeOption("dalvik.vm.profile.backoff-coeff", profileBackoff, "-Xprofile-backoff:"); // Top K% of samples that are considered relevant when // deciding if the app should be recompiled. parseRuntimeOption("dalvik.vm.profile.top-k-thr", profileTopKThreshold, "-Xprofile-top-k-threshold:"); // The threshold after which a change in the structure of the // top K% profiled samples becomes significant and triggers // recompilation. A change in profile is considered // significant if X% (top-k-change-threshold) of the top K% // (top-k-threshold property) samples has changed. parseRuntimeOption("dalvik.vm.profile.top-k-ch-thr", profileTopKChangeThreshold, "-Xprofile-top-k-change-threshold:"); // Type of profile data. parseRuntimeOption("dalvik.vm.profiler.type", profileType, "-Xprofile-type:"); // Depth of bounded stack data parseRuntimeOption("dalvik.vm.profile.stack-depth", profileMaxStackDepth, "-Xprofile-max-stack-depth:"); // Native bridge library. "0" means that native bridge is disabled. property_get("ro.dalvik.vm.native.bridge", propBuf, ""); if (propBuf[0] == '\0') { ALOGW("ro.dalvik.vm.native.bridge is not expected to be empty"); } else if (strcmp(propBuf, "0") != 0) { snprintf(nativeBridgeLibrary, sizeof("-XX:NativeBridge=") + PROPERTY_VALUE_MAX, "-XX:NativeBridge=%s", propBuf); addOption(nativeBridgeLibrary); } initArgs.version = JNI_VERSION_1_4; initArgs.options = mOptions.editArray(); initArgs.nOptions = mOptions.size(); initArgs.ignoreUnrecognized = JNI_FALSE; /* * Initialize the VM. * * The JavaVM* is essentially per-process, and the JNIEnv* is per-thread. * If this call succeeds, the VM is ready, and we can start issuing * JNI calls. */ if (JNI_CreateJavaVM(pJavaVM, pEnv, &initArgs) < 0) { ALOGE("JNI_CreateJavaVM failed\n"); goto bail; } result = 0; bail: return result; }
bool Field::hasAkaoListFile() const { return hasFile(AkaoList); }
const Common::ArchiveMemberPtr BaseCCArchive::getMember(const Common::String &name) const { if (!hasFile(name)) return Common::ArchiveMemberPtr(); return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); }
bool Field::hasMrtFile() const { return hasFile(Mrt); }