/** Saves a file to the table item based on the @param fileData: */ QString TableItem::saveFile(QByteArray fileData, QString fileType) { if (getDirectory().isEmpty()) return ""; /* Create all the folders necessary if they don't exist: */ QDir dir; dir.mkpath(getDirectory()); /* Get the path name: */ int extension = getAvailableFileExtension(fileType); QString filePath = makeFilepath(getName(), getDirectory(), fileType, extension); /* Save the file into the folderpath location: */ QFile itemFile(filePath); if(!itemFile.open(QIODevice::WriteOnly)) return ""; /* Write data into the file: */ itemFile.write(fileData); itemFile.flush(); itemFile.close(); /* Set a hash for the file to identify it: */ setFileHash( QCryptographicHash::hash(fileData,QCryptographicHash::Md5) ); return filePath; }
String JavaVMSingleton::computeClassPath(const zorba::StaticContext* aStaticContext) { String cp; // get classpath from global Properties PropertiesGlobal * properties = Zorba::getInstance(NULL)->getPropertiesGlobal(); std::string globalClassPath; properties->getJVMClassPath(globalClassPath); cp += globalClassPath; std::vector<String> lCPV; aStaticContext->getFullLibPath(lCPV); for (std::vector<String>::iterator lIter = lCPV.begin(); lIter != lCPV.end(); ++lIter) { // verify it contains a jars dir String jarsDir( *lIter ); fs::append( jarsDir, "jars" ); if ( fs::get_type( jarsDir ) == fs::directory ) { fs::iterator itemIter( jarsDir ); while ( itemIter.next() ) { String itemFile( jarsDir ); fs::append( itemFile, itemIter->name ); if ( fs::get_type( itemFile ) == fs::file ) { std::string suffix = "-classpath.txt"; size_t found; found = itemFile.rfind(suffix); if (found!=std::string::npos && found + suffix.length() == itemFile.length() ) { std::auto_ptr<std::istream> pathFile; pathFile.reset(new std::ifstream (itemFile.c_str ())); if (!pathFile->good() || pathFile->eof() ) { std::cerr << "file {" << itemFile << "} not found or not readable." << std::endl; throw itemFile; } // read file char line[1024]; while( !pathFile->eof() && !pathFile->bad() && !pathFile->fail()) { pathFile->getline(line, sizeof(line)); std::string lineStr(line); if ( lineStr.size() > 0 ) { cp += fs::path_separator; cp += fs::normalize_path( lineStr, jarsDir ); } } } } } } } properties->setJVMClassPath(cp.str()); return cp; }