bool IE_Exp_Text_Sniffer::getDlgLabels(const char ** pszDesc, const char ** pszSuffixList, IEFileType * ft) { *pszDesc = "Text (.txt, .text)"; *pszSuffixList = "*.txt; *.text"; *ft = getFileType(); return true; }
bool IE_Imp_PalmDoc_Sniffer::getDlgLabels(const char ** pszDesc, const char ** pszSuffixList, IEFileType * ft) { *pszDesc = "Palm Document (.pdb)"; *pszSuffixList = "*.pdb"; *ft = getFileType(); return true; }
bool IE_Exp_WordPerfect_Sniffer::getDlgLabels (const char ** pszDesc, const char ** pszSuffixList, IEFileType * ft) { *pszDesc = "WordPerfect 6/7/8/9 (.wpd)"; *pszSuffixList = "*.wpd"; *ft = getFileType(); return true; }
ReadFile* ReadFile::makeInvertedReadFile(string filename, float countFactor){ FileType fileType = getFileType(filename); ReadFile* rf; if (fileType == FASTQFILE){ rf = new ReadFileFastqSingle(true,filename,ReadFileFastqSingle::fastqSystem,countFactor); } else if (fileType == PRICEQFILE){ rf = new ReadFilePriceqSingle(true,filename); } else if (fileType == FASTAFILE){ rf = new ReadFileFastaSingle(filename,countFactor,true); } else if (fileType == ILLUMINAFILE){ rf = new ReadFileFastqSingle(true,filename,ReadFileFastqSingle::illuminaSystem,countFactor); } else { throw AssemblyException::ArgError("read file is of an inappropriate type."); } return rf; }
/** * Get the dialog labels * */ bool IE_Imp_OpenDocument_Sniffer::getDlgLabels (const char ** szDesc, const char ** szSuffixList, IEFileType * ft) { *szDesc = "OpenDocument (.odt, .ott)"; *szSuffixList = "*.odt; *.ott"; *ft = getFileType(); return true; }
bool IE_Imp_MSWrite_Sniffer::getDlgLabels (const char **szDesc, const char **szSuffixList, IEFileType *ft) { *szDesc = "Microsoft Write (.wri)"; *szSuffixList = "*.wri"; *ft = getFileType(); return true; }
void SceneFileHandlerBase::pushOptions(const std::string &suffix, bool copyTop) { SceneFileType *type = getFileType(suffix.c_str()); if(type != NULL) { type->pushOptions(copyTop); } }
void ResourceManager::addResources(const Common::FileList &files, ChangeID &change, uint32 priority) { for (Common::FileList::const_iterator file = files.begin(); file != files.end(); ++file) { Resource res; res.priority = priority; res.source = kSourceFile; res.path = *file; res.type = getFileType(*file); addResource(res, Common::FilePath::getStem(*file), change); } }
UInt64 ImageFileHandlerBase::store(Image const *pImage, Char8 const *mimeType, UChar8 *buffer, Int32 memSize ) { ImageFileType *type; type = mimeType ? getFileType(mimeType) : getDefaultType(); return type->store(pImage, buffer, memSize); }
static int format_Options(struct ALN_Options * op) { int len; char * ptr; if(op->spt == NULL || op->read == NULL) return -1; ptr = op->spt + strlen(op->spt) - 3; if(strcmp(ptr, "spt") != 0) { fprintf(stderr, "File type not supported: %s\r\n", op->spt); return -2; } ptr = getFileType(op->read); if(strcmp(ptr, "fa") != 0 && strcmp(ptr, "fasta") != 0) { fprintf(stderr, "File type not supported: %s\r\n", op->read); return -2; } if(op->prefix == NULL) return -1; len = 0; if(op->dir != NULL) len = strlen(op->dir); len += strlen(op->prefix); op->pac = (char *)malloc(len + 6); op->si = (char *)malloc(len + 6); if(op->dir != NULL) { strcpy(op->pac, op->dir); strcpy(op->si, op->dir); strcat(op->pac, op->prefix); strcat(op->si, op->prefix); } else { strcpy(op->pac, op->prefix); strcpy(op->si, op->prefix); } strcat(op->pac, ".pac"); strcat(op->si, ".si"); op->hash = (char *)malloc(strlen(op->spt) + 5); strcpy(op->hash, op->spt); strcat(op->hash, ".hsh"); if(op->verbose & 0x80) op->verbose = 0x80; return 0; }
const Char8 *SceneFileHandler::getOptions(const Char8 *suffix) { if(suffix == NULL) return NULL; SceneFileType *type = getFileType(suffix); if(type == NULL) return NULL; return type->getOptions(); }
FCFileHandlerBase::FCPtrStore FCFileHandlerBase::read(const BoostPath& FilePath) { FCPtrStore Result; //Determine if the file exists if(!boost::filesystem::exists(FilePath)) { SWARNING << "FCFileHandlerBase::read(): " << FilePath.string() << " does not exists." << std::endl; return Result; } std::string filename = initPathHandler(FilePath.string().c_str()); //Determine the file extension std::string Extension(boost::filesystem::extension(FilePath)); boost::algorithm::trim_if(Extension,boost::is_any_of(".")); //Get the Parent Directory Path of the file _RootFilePath = FilePath; _RootFilePath.remove_leaf(); //Get the FileType for this extension FCFileTypeP TheFileType(getFileType(Extension, FCFileType::OSG_READ_SUPPORTED)); //Is that extension supported for reading if(TheFileType == NULL) { SWARNING << "FCFileHandlerBase::read(): Cannot read Field Container file: " << FilePath.string() << ", because no File types support " << Extension << " extension." << std::endl; return Result; } else { //Open up the input stream of the file std::ifstream InputStream(FilePath.string().c_str(), std::ios::binary); if(!InputStream) { SWARNING << "FCFileHandlerBase::read(): Couldn't open input stream for file " << FilePath.string() << std::endl; return Result; } else { //Read from the input stream startReadProgressThread(InputStream); Result = TheFileType->read(InputStream, FilePath.string()); stopReadProgressThread(); InputStream.close(); } } return Result; }
bool SceneFileHandler::setOptions(const Char8 *suffix, const Char8 *options) { if(suffix == NULL) return false; SceneFileType *type = getFileType(suffix); if(type == NULL) return false; type->setOptions(options); return true; }
TableDOMTransitPtr TableFileHandlerBase::forceRead(const BoostPath& FilePath) { TableDOMRefPtr Result; //Determine if the file exists if(!boost::filesystem::exists(FilePath)) { SWARNING << "TableFileHandlerBase::read(): " << FilePath.string() << " does not exists." << std::endl; return TableDOMTransitPtr(NULL); } //Determine the file extension std::string Extension(boost::filesystem::extension(FilePath)); boost::algorithm::trim_if(Extension,boost::is_any_of(".")); //Get the Parent Directory Path of the file _RootFilePath = FilePath; _RootFilePath.remove_leaf(); //Get the FileType of a "txt" file (Forcing the document to be opened as a txt file) TableFileTypeP TheFileType(getFileType("csv", TableFileType::OSG_READ_SUPPORTED)); //Is that extension supported for reading if(TheFileType == NULL) { SWARNING << "TableFileHandlerBase::read(): Cannot read Field Container file: " << FilePath.string() << ", because no File types support " << Extension << " extension." << std::endl; return TableDOMTransitPtr(NULL); } else { //Open up the input stream of the file std::ifstream InputStream(FilePath.string().c_str(), std::ios::binary); if(!InputStream) { SWARNING << "TableFileHandlerBase::read(): Couldn't open input stream for file " << FilePath.string() << std::endl; return TableDOMTransitPtr(NULL); } else { //Read from the input stream startReadProgressThread(InputStream); Result = TheFileType->read(InputStream, FilePath.string()); stopReadProgressThread(); InputStream.close(); } } return TableDOMTransitPtr(Result); }
TEST(TBDv2, Platform_tvOS) { static const char tbd_v1_platform_tvos[] = "--- !tapi-tbd-v2\n" "archs: [ arm64 ]\n" "platform: tvos\n" "install-name: Test.dylib\n" "...\n"; auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd"); auto Result = TextAPIReader::get(std::move(Buffer)); EXPECT_TRUE(!!Result); auto File = std::move(Result.get()); EXPECT_EQ(FileType::TBD_V2, File->getFileType()); EXPECT_EQ(PlatformKind::tvOS, File->getPlatform()); }
void ZIPFile::load() { const Common::ZipFile::FileList &files = _zipFile->getFiles(); for (Common::ZipFile::FileList::const_iterator file = files.begin(); file != files.end(); ++file) { Resource res; res.name = Common::FilePath::getStem(file->name); res.type = getFileType(file->name); res.index = file->index; _resources.push_back(res); } _zipFile->clear(); }
bool SceneFileHandlerBase::write(Node * const node, std::ostream &os, Char8 const *fileNameOrExtension, bool compress ) { bool retCode = false; SceneFileType *type = getFileType(fileNameOrExtension); if(type != NULL) { updateWriteProgress(0); SINFO << "try to write stream as " << type->getName() << std::endl; if(_writeFP != NULL) { retCode = _writeFP(type, node, os, fileNameOrExtension, compress); } else { if(compress == true) { #ifdef OSG_WITH_ZLIB SINFO << "writing compressed stream." << std::endl; zip_ostream zipper(os, true); retCode = type->write(node, zipper, fileNameOrExtension); zipper.zflush(); #else SFATAL << "Compressed streams are not supported! Build " << "with zlib= options." << std::endl; #endif } else { retCode = type->write(node, os, fileNameOrExtension); } } } else { SWARNING << "can't write stream unknown scene format" << std::endl; } return retCode; }
int main(int argc, char** argv) { int filetype; int size; int startblock; int blocksize; char *name = new char[DIRECTORY_MAX_NAME_LENGTH]; FILE *fp; if (argv[2] == 0){ printf("File not found\n"); free(name); return 0; } if ((fp=fopen(argv[1],"r"))) { currentFile = getRootDirStart(fp)*512; while (1){ fseek(fp, currentFile,SEEK_SET); filetype = getFileType(fp); if (filetype == 3){ //printf("F "); } else if (filetype == 5){ //printf("D "); } else { printf("File not found\n"); break; } size = getSize(fp); startblock = getStartBlock(fp); blocksize = getBlockSize(fp); printf("%d\n",blocksize); getName(fp,name); currentFile+=64; if (strcmp(argv[2],name) == 0){ //printf("found!\n"); copyFile(fp,startblock,size,name); break; } } } else printf("File not found\n"); free(name); fclose(fp); return 0; }
//------------------------------------------------------ void DatabaseService::mergeLoad(const std::string &filename, uint32_t loadMask) { FileGroupPtr db = getDBFileNamed(filename); uint32_t ft = getFileType(db); LOG_DEBUG("DatabaseService::mergeLoad - Merge load of file %s", filename.c_str()); mLoadingStatus.reset(); mLoadingStatus.totalCoarse += mListeners.size(); broadcastOnDBLoad(db, ft & loadMask); LOG_DEBUG("DatabaseService::mergeLoad - end()"); }
/*! Removes the option \a name from the ImageFileType that handles files with the given \a suffix. If the option is not present \c false is returned, \c true otherwise. \param[in] suffix File extension to choose the image file type this option applies to. \param[in] name Name of the option. \return Whether the option was successfully removed. */ bool ImageFileHandlerBase::unsetOption( const std::string &suffix, const std::string &name ) { bool retVal = false; ImageFileType *type = getFileType(suffix.c_str()); if(type != NULL) { retVal = type->unsetOption(name); } return retVal; }
TEST(TBDv2, Swift_99) { static const char tbd_v1_swift_99[] = "--- !tapi-tbd-v2\n" "archs: [ arm64 ]\n" "platform: ios\n" "install-name: Test.dylib\n" "swift-version: 99\n" "...\n"; auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd"); auto Result = TextAPIReader::get(std::move(Buffer)); EXPECT_TRUE(!!Result); auto File = std::move(Result.get()); EXPECT_EQ(FileType::TBD_V2, File->getFileType()); EXPECT_EQ(99U, File->getSwiftABIVersion()); }
void *processRequest(void* pConnfd){ printf("%ld\n",(long)pthread_self()); printf("Processing Request...\n"); int connfd = *(int*) pConnfd; while(1){ pthread_mutex_lock(&mutex); //m char buffer[1501]; ssize_t count; int hostCheck = 0; char *fileName = NULL; char *fileType = NULL; char *fileBuffer = NULL; count = read(connfd, buffer, 1500); if(count == -1){ InternalServiceError(connfd); } if(count==0){ printf("Closing\n"); close(connfd); break; } buffer[count] = '\0'; // printf("%s\n",buffer); fileName = getFileName(buffer); hostCheck = checkHostHeader(buffer); if(fileName && hostCheck){ fileType = getFileType(fileName); fileBuffer = getFileBuffer(fileName); if(fileBuffer){ printf("File: %s\n", fileName); OKResponse(fileType,fileName,fileBuffer,connfd); } else NotFoundError(connfd); } else BadRequestError(connfd); pthread_mutex_unlock(&mutex); //m } close(connfd); pthread_exit(NULL); //m }
TEST(TBDv2, ReadFile2) { static const char tbd_v2_file2[] = "--- !tapi-tbd-v2\n" "archs: [ armv7, armv7s, armv7k, arm64 ]\n" "platform: ios\n" "flags: [ flat_namespace, not_app_extension_safe ]\n" "install-name: Test.dylib\n" "swift-version: 1.1\n" "exports:\n" " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" " symbols: [ _sym1, _sym2, _sym3, _sym4, $ld$hide$os9.0$_sym1 ]\n" " objc-classes: [ _class1, _class2 ]\n" " objc-ivars: [ _class1._ivar1, _class1._ivar2 ]\n" " weak-def-symbols: [ _weak1, _weak2 ]\n" " thread-local-symbols: [ _tlv1, _tlv2 ]\n" " - archs: [ armv7, armv7s, armv7k ]\n" " symbols: [ _sym5 ]\n" " objc-classes: [ _class3 ]\n" " objc-ivars: [ _class1._ivar3 ]\n" " weak-def-symbols: [ _weak3 ]\n" " thread-local-symbols: [ _tlv3 ]\n" "undefineds:\n" " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" " symbols: [ _undefSym1, _undefSym2, _undefSym3 ]\n" " objc-classes: [ _undefClass1, _undefClass2 ]\n" " objc-ivars: [ _undefClass1._ivar1, _undefClass1._ivar2 ]\n" " weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n" "...\n"; auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file2, "Test.tbd"); auto Result = TextAPIReader::get(std::move(Buffer)); EXPECT_TRUE(!!Result); auto File = std::move(Result.get()); EXPECT_EQ(FileType::TBD_V2, File->getFileType()); auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64; EXPECT_EQ(Archs, File->getArchitectures()); EXPECT_EQ(PlatformKind::iOS, File->getPlatform()); EXPECT_EQ(std::string("Test.dylib"), File->getInstallName()); EXPECT_EQ(PackedVersion(1, 0, 0), File->getCurrentVersion()); EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion()); EXPECT_EQ(2U, File->getSwiftABIVersion()); EXPECT_EQ(ObjCConstraintType::Retain_Release, File->getObjCConstraint()); EXPECT_FALSE(File->isTwoLevelNamespace()); EXPECT_FALSE(File->isApplicationExtensionSafe()); EXPECT_FALSE(File->isInstallAPI()); EXPECT_EQ(0U, File->allowableClients().size()); EXPECT_EQ(0U, File->reexportedLibraries().size()); }
/*! Retrieves the option \a name from the SceneFileType that handles files with the given \a suffix and stores its value in \a value. Returns \c true if successful, \c false otherwise in which case \a value has an undefined value. \param[in] suffix File extension to choose the scene file type this option applies to. \param[in] name Name of the option. \param[out] value Value the option. \return Whether the option is present for the given SceneFileType. */ bool SceneFileHandlerBase::getOption( const std::string &suffix, const std::string &name, std::string &value ) { bool retVal = false; SceneFileType *type = getFileType(suffix.c_str()); if(type != NULL) { retVal = type->getOption(name, value); } return retVal; }
int Shape::loadASCIIVRML(std::string filename) { if(getFileType(filename) != VRML) { cerr << _("No VRML file file passed to loadASCIIVRML") << endl; return -1; } triangles.clear(); Min.x = Min.y = Min.z = numeric_limits<double>::infinity(); Max.x = Max.y = Max.z = -numeric_limits<double>::infinity(); //#ifndef HAVE_OPENVRML #if 1 ifstream file; file.open(filename.c_str()); if(file.fail()) { cerr << _("Error: Unable to open vrml file - ") << filename << endl; return -1; } string word; std::vector<float> vertices; std::vector<int> indices; bool finished = false; while(!file.eof() && !finished) { // while (word!="Shape" && !file.eof()) // file >> word; // while (word!="Appearance" && !file.eof()) // file >> word; // while (word!="Coordinate" && !file.eof()) // file >> word; while (word!="point" && !file.eof()) file >> word; file >> word; if (word=="[") { float f; while (word!="]" && !file.eof()){ file >> word; if (word!="]") if (word.find("#")!=0) { std::istringstream iss(word); iss >> f; vertices.push_back(f); //cerr << f << ", "; } } //cerr << endl; }
/** * Opens a PE file. The return type is either PeFile32 or PeFile64 object. If an error occurs the return * value is 0. * @param strFilename Name of a file. * @return Either a PeFile32 object, a PeFil64 object or 0. **/ PeFile* openPeFile(const std::string& strFilename) { unsigned int type = getFileType(strFilename); if (type == PEFILE32) { return new PeFile32(strFilename); } else if (type == PEFILE64) { return new PeFile64(strFilename); } else { return 0; } }
int main(int argc, char **argv) { char *p; char buf[1024]; int i; fileType *ft; if (argc!=2) return -1; ft = getFileType(argv[1]); if (ft == NULL) { perror(argv[1]); exit(1); } else { printf("type = %x\nauxtype = %lx\n",ft->type,ft->auxtype); } return 0; }
std::wstring File::getFileTypeAsString() { switch (getFileType()) { case 1 : return L"F"; break; case 2 : return L"C"; break; case 3 : return L"STD"; break; default : return L"Error"; break; } }
bool getPrevSong() { int fType = UNKNOWN; int tmpCur = getCursor(); while(fType != SOUNDFILE) { tmpCur = prevFile(getFileName()); if(tmpCur == -1) return false; fType = getFileType(getFileName()); } moveCursorAbsolute(tmpCur); return true; }
bool getNextSong() { int fType = UNKNOWN; int tmpCur = getCursor(); while(fType != SOUNDFILE) { tmpCur = nextFile(getFileName(), getBrowserEntries()); if(tmpCur == -1) return false; fType = getFileType(getFileName()); } moveCursorAbsolute(tmpCur); return true; }