Exemplo n.º 1
0
/*
 *
 * tests the suffix from filename
 * if it is an image
 *
 */
bool FileInfo::isImage(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "png" || s == "jpg" || s == "jpeg" || s == "gif" || s == "svg") {
		return true;
	}
	return false;
}
Exemplo n.º 2
0
OFile& OFile::open(const std::string&path) {
  plumed_assert(!cloned);
  eof=false;
  err=false;
  fp=NULL;
  gzfp=NULL;
  this->path=path;
  this->path=appendSuffix(path,getSuffix());
  if(checkRestart()) {
    fp=std::fopen(const_cast<char*>(this->path.c_str()),"a");
    mode="a";
    if(Tools::extension(this->path)=="gz") {
#ifdef __PLUMED_HAS_ZLIB
      gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"a9");
#else
      plumed_merror("file " + getPath() + ": trying to use a gz file without zlib being linked");
#endif
    }
  } else {
    backupFile( backstring, this->path );
    if(comm)comm->Barrier();
    fp=std::fopen(const_cast<char*>(this->path.c_str()),"w");
    mode="w";
    if(Tools::extension(this->path)=="gz") {
#ifdef __PLUMED_HAS_ZLIB
      gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"w9");
#else
      plumed_merror("file " + getPath() + ": trying to use a gz file without zlib being linked");
#endif
    }
  }
  if(plumed) plumed->insertFile(*this);
  return *this;
}
Exemplo n.º 3
0
/*
 *
 * tests the suffix from filename
 * if it is a video
 *
 */
bool FileInfo::isVideo(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "mp4" || s == "mov") {
		return true;
	}
	return false;
}
Exemplo n.º 4
0
/*
 *
 * tests the suffix from filename
 * if it is a book
 *
 */
bool FileInfo::isBook(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "epub") {
		return true;
	}
	return false;
}
Exemplo n.º 5
0
/*
 *
 * tests the suffix from filename
 * if it is a audio file
 *
 */
bool FileInfo::isAudio(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "m4a" || s == "mp3" || s == "ogg" || s == "wav") {
		return true;
	}
	return false;
}
Exemplo n.º 6
0
/*
 *
 * tests the suffix from filename
 * if it is a html file
 *
 */
bool FileInfo::isHtml(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "html" || s == "htm" || s == "xhtml") {
		return true;
	}
	return false;
}
Exemplo n.º 7
0
std::string Sequence::getCStylePattern() const
{
	if( getPadding() )
		return getPrefix() + "%0" + boost::lexical_cast<std::string > ( getPadding() ) + "d" + getSuffix();
	else
		return getPrefix() + "%d" + getSuffix();
}
Exemplo n.º 8
0
/*
 *
 * tests the suffix from filename
 * if it is a compressed document
 *
 */
bool FileInfo::isCompressed(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "tar" || s == "rar" || s == "gz" || s == "zip") {
		return true;
	}
	return false;
}
Exemplo n.º 9
0
XObjectPtr
FunctionGenerateID::execute(
			XPathExecutionContext&	executionContext,
			XalanNode*				context,
			const LocatorType*		locator) const
{
	if (context == 0)
	{
		executionContext.error(
				XalanMessageLoader::getMessage(XalanMessages::FunctionRequiresNonNullContextNode_1Param,"generate-id()"),
				context,
				locator);

		return XObjectPtr();
	}
	else
	{
		XPathExecutionContext::GetAndReleaseCachedString	theID(executionContext);

		theID.get() = XalanUnicode::charLetter_N;

		getSuffix(context, theID.get());

		return executionContext.getXObjectFactory().createString(theID);
	}
}
Exemplo n.º 10
0
InputPlugin * hasMusicSuffix(char * utf8file) {
        InputPlugin * ret = NULL;
        
        char * s = getSuffix(utf8file);
        if(s) ret = getInputPluginFromSuffix(s);

	return ret;
}
Exemplo n.º 11
0
void getSuffix(Node *node, int at) {
	if (node->minchild < 0) {
		suffix[at] = 0;
		return;
	}
	
	suffix[at] = ALPHA_BASE + node->minchild;
	getSuffix(node->children[node->minchild], at+1);
}
Exemplo n.º 12
0
bool compareSuffix2(const suffix2& s1, const suffix2& s2)
{
    char * kmer1, *kmer2;
    unsigned int nextPos1, nextPos2;
    bool result = true;
    
    kmer1 = getSuffix((suffix2*) &s1, &nextPos1);
    kmer2 = getSuffix((suffix2*) &s2, &nextPos2);
    
    int kmerComp = strncmp((const char*) kmer1, (const char*) kmer2, Data::kl);
    if (kmerComp < 0)
        result = true;
    else //if (kmerComp > 0)
        result = false;
       
    free(kmer1);
    free(kmer2);
    return result;
}
Exemplo n.º 13
0
/*
 *
 * tests the suffix from filename
 * if it is a document
 *
 */
bool FileInfo::isDocument(QString filePath) const {
	QString s = getSuffix(filePath);
	if (s == "doc" || s == "odt" || s == "ppt" || s == "pptx"
			|| s == "txt" || s == "rtf" || s == "ptx"
			|| s == "pdf" || s == "zip" || s == "tar"
			|| s == "rar" || s == "gz" || s == "html") {
		return true;
	}
	return false;
}
Exemplo n.º 14
0
FILE* PlumedMain::fopen(const char *path, const char *mode){
  std::string mmode(mode);
  std::string ppath(path);
  std::string suffix(getSuffix());
  std::string ppathsuf=ppath+suffix;
  FILE*fp=std::fopen(const_cast<char*>(ppathsuf.c_str()),const_cast<char*>(mmode.c_str()));
  if(!fp) fp=std::fopen(const_cast<char*>(ppath.c_str()),const_cast<char*>(mmode.c_str()));
  plumed_massert(fp,"file " + ppath + " cannot be found");
  return fp;
}
Exemplo n.º 15
0
    virtual cpp17::any data(const WModelIndex& index, ItemDataRole role = ItemDataRole::Display) const {
	if (!index.isValid())
	    return cpp17::any();

	Git::Object object = getObject(index);

	switch (index.column()) {
	case 0:
	    if (role == ItemDataRole::Display) {
		if (object.type == Git::Tree)
		    return object.name + '/';
		else
		    return object.name;
	    } else if (role == ItemDataRole::Decoration) {
		if (object.type == Git::Blob)
		    return std::string("icons/git-blob.png");
		else if (object.type == Git::Tree)
		    return std::string("icons/git-tree.png");
	    } else if (role == ContentsRole) {
		if (object.type == Git::Blob)
		    return git_.catFile(object.id);
	    }

	    break;
	case 1:
	    if (role == ItemDataRole::Display) {
		if (object.type == Git::Tree)
		    return std::string("Folder");
		else {
		    std::string suffix = getSuffix(object.name);

		    if (suffix == "C" || suffix == "cpp")
			return std::string("C++ Source");
		    else if (suffix == "h" || 
			     (suffix == "" && !topLevel(index)))
			return std::string("C++ Header");
		    else if (suffix == "css")
			return std::string("CSS Stylesheet");
		    else if (suffix == "js")
			return std::string("JavaScript Source");
		    else if (suffix == "md")
			return std::string("Markdown");
		    else if (suffix == "png" || suffix == "gif")
			return std::string("Image");
		    else if (suffix == "txt")
			return std::string("Text");
		    else
			return cpp17::any();
		}
	    }
	}

        return cpp17::any();
    }
Exemplo n.º 16
0
void Widget::example(){
    QString text = tr("example");
    if(isRename()){
        if(isNewName()){
            text = getNewName();
        }
        if(isPrependExifDate()){
            text.prepend(getDateTime("").toString(ui->exifLineEdit->text()));
        }
        if(isAppendExifDate()){
            text.append(getDateTime("").toString(ui->exifLineEdit->text()));
        }
        if(!(getPrefix().isEmpty() && getSuffix().isEmpty())){
            text.prepend(getPrefix());
            text.append(getSuffix());
        }
    }

    ui->exampleLabel->setText(text);
}
Exemplo n.º 17
0
string Jce2Php::toStrSuffix(const TypeIdPtr &pPtr) const
{
    ostringstream s;

    int i = getSuffix(pPtr);

    if(i >= 0)
    {
         s << "[" << i << "]";
    }
    return s.str();
}
Exemplo n.º 18
0
long_int multiply(long_int num1, long_int num2)
{
	int digits1 = numDigits(num1);
	int digits2 = numDigits(num2);
	if(digits1 == 1 || digits2 == 1)
	{
		return num1 * num2;
	}
	long_int a = rightShift(num1, (digits1/2));
	long_int c = rightShift(num2, (digits2/2));
	long_int b = getSuffix(num1, digits1/2);
	long_int d = getSuffix(num2, digits2/2);
	long_int ac = multiply(a, c);
	long_int bd = multiply(b, d);
	long_int aplusbtimescplusd = multiply(a + b, c + d);
	long_int cof1 = tenPower((digits1/2) + (digits2/2));
	long_int cof2 = tenPower(digits1/2);
	long_int sum_term_1 = cof1 * ac;
	long_int sum_term_2 = cof2 * (aplusbtimescplusd - ac - bd);
	return (sum_term_1 + bd + sum_term_2);

}
Exemplo n.º 19
0
string Item::getVisibleName(bool getPlural) const {
  string ret;
  if (!getPlural)
    ret = *attributes->name;
  else {
    if (attributes->plural)
      ret = *attributes->plural;
    else
      ret = *attributes->name + "s";
  }
  appendWithSpace(ret, getSuffix());
  return ret;
}
Exemplo n.º 20
0
void OFile::backupAllFiles( const std::string& str ) {
  if(str=="/dev/null") return;
  plumed_assert( backstring!="bck" && !checkRestart());
  size_t found=str.find_last_of("/\\");
  std::string filename = appendSuffix(str,getSuffix());
  std::string directory=filename.substr(0,found+1);
  std::string file=filename.substr(found+1);
  if( FileExist(filename) ) backupFile("bck", filename);
  for(int i=0;; i++) {
    std::string num; Tools::convert(i,num);
    std::string filestr = directory + backstring + "." + num + "." + file;
    if( !FileExist(filestr) ) break;
    backupFile( "bck", filestr);
  }
}
Exemplo n.º 21
0
bool FileBase::FileExist(const std::string& path){
  FILE *ff=NULL;
  bool do_exist=false;
  this->path=appendSuffix(path,getSuffix());
  mode="r";
  ff=std::fopen(const_cast<char*>(this->path.c_str()),"r");
  if(!ff){
    this->path=path;
    ff=std::fopen(const_cast<char*>(this->path.c_str()),"r");
    mode="r";
  }
  if(ff) {do_exist=true; fclose(ff);}
  if(comm) comm->Barrier();
  return do_exist; 
}
Exemplo n.º 22
0
// Print the suffix array
void SuffixArray::print(const ReadTable* pRT) const
{
    std::cout << "i\tSA(i)\n";
    for(size_t i = 0; i < m_data.size(); ++i)
    {
        SAElem id1 = m_data[i];
        std::string suffix = !id1.isEmpty() ? getSuffix(i, pRT) : "";
        int pos = id1.getPos();
        char b;
        if(pos == 0)
            b = '$';
        else
            b =  pRT->getRead(id1.getID()).seq.get(pos - 1);
        std::cout << i << "\t" << id1 << "\t" << b << "\t" << suffix << "\n";
    }
}
Exemplo n.º 23
0
string Item::getShortName(const Creature* owner, bool plural) const {
  PROFILE;
  if (owner && owner->isAffected(LastingEffect::BLIND) && attributes->blindName)
    return getBlindName(plural);
  if (attributes->artifactName)
    return *attributes->artifactName + " " + getModifiers(true);
  string name;
  if (!attributes->prefixes.empty())
    name = attributes->prefixes.back();
  else if (attributes->shortName) {
    name = *attributes->shortName;
    appendWithSpace(name, getSuffix());
  } else
    name = getVisibleName(plural);
  appendWithSpace(name, getModifiers(true));
  return name;
}
Exemplo n.º 24
0
bool Image4DSimple::saveImage(const char filename[])
{
    if (!data1d || !filename)
	{
		v3d_msg("This image data is empty or the file name is invalid. Nothing done.\n");
		return false;
	}
    
    V3DLONG mysz[4];
	mysz[0] = sz0;
	mysz[1] = sz1;
	mysz[2] = sz2;
	mysz[3] = sz3;

	int dt;
	switch (datatype)
	{
		case V3D_UINT8:  dt=1; break;
		case V3D_UINT16:  dt=2; break;
		case V3D_FLOAT32:  dt=4; break;
		default:
			v3d_msg("The data type is unsupported. Nothing done.\n");
			return false;
			break;
	}

    if (strlen(filename) > 5 ) {
        const char * suffix = getSuffix((char *)filename);
        if (suffix && (strcasecmp(suffix, "nrrd")==0 ||
                       strcasecmp(suffix, "nhdr")==0) )
        {
            float pxinfo[4];
            float spaceorigin[3];
            // use nrrd_write
            pxinfo[0] = rez_x;
            pxinfo[1] = rez_y;
            pxinfo[2] = rez_z;
            
            spaceorigin[0] = origin_x;
            spaceorigin[1] = origin_y;
            spaceorigin[2] = origin_z;
            return write_nrrd_with_pxinfo(filename, data1d, mysz, dt, pxinfo, spaceorigin);
        }
    }
    return ::saveImage(filename, data1d, mysz, dt);
}
Exemplo n.º 25
0
void Entry::onSizeHint(SizeHintEvent& ev)
{
  int trailing = font()->textLength(getSuffix());
  trailing = MAX(trailing, 2*theme()->getEntryCaretSize(this).w);

  int w =
    font()->textLength("w") * std::min(m_maxsize, 6) +
    + trailing
    + border().width();

  w = std::min(w, ui::display_w()/2);

  int h =
    + font()->height()
    + border().height();

  ev.setSizeHint(w, h);
}
Exemplo n.º 26
0
int main(int argc, char **argv) {
	int i, n;
	Node *root;
	while (scanf("%s", string) != EOF) {
		poolPos = 0;
		n = strlen(string);
		root = createNode();
		for (i = 0; i < n; i++)
			addToTrie(root, i, n);
		
		findSuffix(root);
		getSuffix(root, 0);
		printf("%s\n", suffix);
		
//		destroyNode(root);
	}
	
	return EXIT_SUCCESS;
}
Exemplo n.º 27
0
void PlumedMain::init() {
// check that initialization just happens once
  initialized=true;
  atoms.init();
  if(!log.isOpen()) log.link(stdout);
  log<<"PLUMED is starting\n";
  log<<"Version: "<<config::getVersionLong()<<" (git: "<<config::getVersionGit()<<") compiled on " __DATE__ " at " __TIME__ "\n";
  log<<"Please cite this paper when using PLUMED ";
  log<<cite("Tribello, Bonomi, Branduardi, Camilloni, and Bussi, Comput. Phys. Commun. 185, 604 (2014)");
  log<<"\n";
  log<<"For further information see the PLUMED web page at http://www.plumed.org\n";
  log<<"Root: "<<config::getPlumedRoot()<<"\n";
  log<<"For installed feature, see "<<config::getPlumedRoot() + "/src/config/config.txt\n";
  log.printf("Molecular dynamics engine: %s\n",MDEngine.c_str());
  log.printf("Precision of reals: %d\n",atoms.getRealPrecision());
  log.printf("Running over %d %s\n",comm.Get_size(),(comm.Get_size()>1?"nodes":"node"));
  log<<"Number of threads: "<<OpenMP::getNumThreads()<<"\n";
  log<<"Cache line size: "<<OpenMP::getCachelineSize()<<"\n";
  log.printf("Number of atoms: %d\n",atoms.getNatoms());
  if(grex) log.printf("GROMACS-like replica exchange is on\n");
  log.printf("File suffix: %s\n",getSuffix().c_str());
  if(plumedDat.length()>0) {
    readInputFile(plumedDat);
    plumedDat="";
  }
  atoms.updateUnits();
  log.printf("Timestep: %f\n",atoms.getTimeStep());
  if(atoms.getKbT()>0.0)
    log.printf("KbT: %f\n",atoms.getKbT());
  else {
    log.printf("KbT has not been set by the MD engine\n");
    log.printf("It should be set by hand where needed\n");
  }
  log<<"Relevant bibliography:\n";
  log<<citations;
  log<<"Please read and cite where appropriate!\n";
  log<<"Finished setup\n";
}
Exemplo n.º 28
0
void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
        int ret;
        InputStream inStream;
        InputPlugin * plugin = NULL;
        char * path;

        if(isRemoteUrl(pc->utf8url)) {
                path = utf8StrToLatin1Dup(pc->utf8url);
        }
	else path = strdup(rmp2amp(utf8ToFsCharset(pc->utf8url)));

	if(!path) {
		dc->error = DECODE_ERROR_FILE;
		dc->state = DECODE_STATE_STOP;
		dc->start = 0;
                return;
	}

	copyMpdTagToOutputBuffer(cb, NULL);

        strncpy(dc->utf8url, pc->utf8url, MAXPATHLEN);
	dc->utf8url[MAXPATHLEN] = '\0';

        if(openInputStream(&inStream, path) < 0) {
		dc->error = DECODE_ERROR_FILE;
		dc->state = DECODE_STATE_STOP;
		dc->start = 0;
		free(path);
                return;
        }

        dc->seekable = inStream.seekable;
        dc->state = DECODE_STATE_START;
	dc->start = 0;

        while(!inputStreamAtEOF(&inStream) && bufferInputStream(&inStream) < 0
                        && !dc->stop)
	{
		/* sleep so we don't consume 100% of the cpu */
//		fprintf(stderr,"In decode.c decodeParent decode start func\r\n");
	//	my_usleep(1000);
	}

        if(dc->stop) {
                dc->state = DECODE_STATE_STOP;
                dc->stop = 0;
		free(path);
                return;
        }

        /*if(inStream.metaName) {
		MpdTag * tag = newMpdTag();
		tag->name = strdup(inStream.metaName);
		copyMpdTagToOutputBuffer(cb, tag);
		freeMpdTag(tag);
        }*/

	/* reset Metadata in OutputBuffer */

        ret = DECODE_ERROR_UNKTYPE;
	if(isRemoteUrl(dc->utf8url)) {
		cb->acceptMetadata = 1;
		plugin = getInputPluginFromMimeType(inStream.mime);
                if(plugin == NULL) {
                        plugin = getInputPluginFromSuffix(
                                        getSuffix(dc->utf8url));
                }
                /* this is needed for bastard streams that don't have a suffix
                                or set the mimeType */
                if(plugin == NULL) {
                        plugin = getInputPluginFromName("mp3");
                }
                if(plugin && (plugin->streamTypes & INPUT_PLUGIN_STREAM_URL) &&
                                plugin->streamDecodeFunc) 
                {
                        ret = plugin->streamDecodeFunc(cb, dc, &inStream);
                }
	}
        else {
		cb->acceptMetadata = 0;
                plugin = getInputPluginFromSuffix(getSuffix(dc->utf8url));
                if(plugin && (plugin->streamTypes && INPUT_PLUGIN_STREAM_FILE))
                {
                        if(plugin->streamDecodeFunc) {
                                ret = plugin->streamDecodeFunc(cb, dc, 
                                                &inStream);
                        }
                        else if(plugin->fileDecodeFunc) {
                                closeInputStream(&inStream);
                                ret = plugin->fileDecodeFunc(cb, dc, path);
                        }
                }
        }

	if(ret<0 || ret == DECODE_ERROR_UNKTYPE) {
		strncpy(pc->erroredUrl, dc->utf8url, MAXPATHLEN);
		pc->erroredUrl[MAXPATHLEN] = '\0';
		if(ret != DECODE_ERROR_UNKTYPE) dc->error = DECODE_ERROR_FILE;
                else {
                        dc->error = DECODE_ERROR_UNKTYPE;
                        closeInputStream(&inStream);
                }
		dc->stop = 0;
		dc->state = DECODE_STATE_STOP;
	}

	free(path);
}
Exemplo n.º 29
0
bool Family::lastRepeatComplete() const {
  return last == getSuffix();
}
Exemplo n.º 30
0
 inline const char_pg* DefaultPseudoGenome<uint_read_len, uint_reads_cnt, uint_pg_len, ReadsListClass>::getSuffix(const uint_reads_cnt readsListIdx, const uint_read_len offset) {
     return getSuffix(this->readsList->getReadPosition(readsListIdx) + offset);
 }