Example #1
0
static F2(jttclosure){A z;B b;I an,*av,c,d,i,wn,wr,wt,*wv,*zu,*zv,*zz;
 RZ(a&&w);
 wt=AT(w); wn=AN(w); wr=AR(w);
 if(B01&wt)RZ(w=cvt(INT,w)); wv=AV(w);
 av=AV(a); an=AN(a);
 RZ(z=exta(INT,1+wr,wn,20L)); 
 zv=AV(z); zz=zv+AN(z);
 if(1==wn){
  *zv++=c=*wv; d=1+c;
  while(c!=d){
   if(zv==zz){i=zv-AV(z); RZ(z=ext(0,z)); zv=AV(z)+i; zz=AV(z)+AN(z);}
   d=c; if(0>c)c+=an; ASSERT(0<=c&&c<an,EVINDEX); *zv++=c=av[c];
 }}else{
  ICPY(zv,wv,wn); zu=zv; zv+=wn;
  while(1){
   if(zv==zz){i=zv-AV(z); RZ(z=ext(0,z)); zv=AV(z)+i; zz=AV(z)+AN(z); zu=zv-wn;}
   b=1; DO(wn, d=c=*zu++; if(0>c)c+=an; ASSERT(0<=c&&c<an,EVINDEX); *zv++=c=av[c]; if(c!=d)b=0;);
   if(b)break;
 }}
void UnrestrictedModel::saveExtensionsToList(QStringList items, QString name)
{
    QFile ext(QString("/home/user/.status-menu/") + name);
    if (ext.open(QFile::WriteOnly | QFile::Text)) {
        QTextStream out(&ext);
        foreach (QString line, items)
            out << line << "\n";
        ext.close();
    }
}
Example #3
0
QString CanvasExporterPS::fileExtension() const
{
    QString format = outputFormat();
    int prefixLength = QString("PostScript (").length();
    int length = format.length() - prefixLength - 1;

    QStringRef ext(&format, prefixLength, length);

    return ext.toString().toLower();
}
Example #4
0
File: sl.c Project: bitemyapp/j
A jtstcreate(J jt,C k,I p,I n,C*u){A g,*pv,x,y;C s[20];I m,*nv;L*v;
 GA(g,SYMB,ptab[p],1,0); 
 RZ(v=symnew(AV(g))); v->flag|=LINFO; v->sn=jt->symindex++;
 switch(k){
  case 0:  /* named    locale */
   RZ(x=nfs(n,u));
   LOCNAME(g)=x; LOCPATH(g)=ra(1==n&&'z'==*u?vec(BOX,0L,0L):zpath);
   symbis(x,g,jt->stloc);
   break;
  case 1:  /* numbered locale */
   ASSERT(0<=jt->stmax,EVLOCALE);
   sprintf(s,FMTI,n); RZ(x=nfs(strlen(s),s));
   LOCNAME(g)=x; LOCPATH(g)=ra(zpath);
   ++jt->stused;
   m=AN(jt->stnum);
   if(m<jt->stused){
    x=ext(1,jt->stnum); y=ext(1,jt->stptr); RZ(x&&y); jt->stnum=x; jt->stptr=y;
    nv=m+AV(jt->stnum); pv=m+AAV(jt->stptr); DO(AN(x)-m, *nv++=-1; *pv++=0;); 
   }
Example #5
0
Raster* Raster::readRaster(std::string const& fname)
{
	std::string ext (BaseLib::getFileExtension(fname));
	std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
	if (ext.compare("asc") == 0)
		return getRasterFromASCFile(fname);
	if (ext.compare("grd") == 0)
		return getRasterFromSurferFile(fname);
	return nullptr;
}
Example #6
0
bool input_entry::g_is_supported_path(const char * p_path)
{
	service_ptr_t<input_entry> ptr;
	service_enum_t<input_entry> e;
	pfc::string_extension ext(p_path);
	while(e.next(ptr))
	{
		if (ptr->is_our_path(p_path,ext)) return true;
	}
	return false;
}
Example #7
0
void OSInterface::openFile(std::string &path){
    std::shared_ptr<Data> data_instance = Data::getInstance();
    std::string ext(getExtension(path));
    std::string app(data_instance->extern_programmes.at(ext));
    QString program(app.c_str());
    QStringList arguments;
    arguments << QString::fromStdString(path);

    QProcess *myProcess = new QProcess();
    myProcess->start(program, arguments);
}
Example #8
0
bool file_utils::add_default_extension(dynamic_string &path, const char *pExt)
{
    dynamic_string ext(path);
    get_extension(ext);
    if (ext.is_empty())
    {
        path.append(pExt);
        return true;
    }
    return false;
}
Example #9
0
bool FileList::FilterMatches(const QFileInfo &inf)
{
    if (inf.isFile()) {
        const QStringList filters = FileList::GetDefaultFilters();
        QString ext("*.");
        ext += inf.suffix();
        if (filters.contains(ext))
            return true;
    }
    return false;
}
Example #10
0
bool CStringExt::Split(LPCTSTR srcString,LPCTSTR splitString,BYTE nNum,CString*values)
{
	ASSERT(nNum && values);
	if(nNum==0 || values==NULL) return false;
	CStringExt ext(srcString,splitString);
	ext.BeginEnum();
	for(BYTE n=0;n<nNum;n++)
	{
		if(!ext.GetNext(values[n])) return false;
	}
	return true;
}
osgDB::ReaderWriter::WriteResult
ReaderWriterDAE::writeNode( const osg::Node& node,
        const std::string& fname, const osgDB::ReaderWriter::Options* options ) const
{
    SERIALIZER();

    bool bOwnDAE = false;
    DAE* pDAE = NULL;

    std::string ext( osgDB::getLowerCaseFileExtension(fname) );
    if( ! acceptsExtension(ext) ) return WriteResult::FILE_NOT_HANDLED;

    // Process options
    osgDAE::daeWriter::Options pluginOptions;
    std::string srcDirectory( osgDB::getFilePath(node.getName().empty() ? fname : node.getName()) );        // Base dir when relativising images paths
    if( options )
    {
        pDAE = (DAE*)options->getPluginData("DAE");

        const std::string & baseDir = options->getPluginStringData("baseImageDir");        // Rename "srcModelPath" (and call getFilePath() on it)?
        if (!baseDir.empty()) srcDirectory = baseDir;

        const std::string & relativiseImagesPathNbUpDirs = options->getPluginStringData("DAE-relativiseImagesPathNbUpDirs");
        if (!relativiseImagesPathNbUpDirs.empty()) {
            std::istringstream iss(relativiseImagesPathNbUpDirs);
            iss >> pluginOptions.relativiseImagesPathNbUpDirs;
        }

        // Sukender's note: I don't know why DAE seems to accept comma-sparated options instead of space-separated options as other ReaderWriters. However, to avoid breaking compatibility, here's a workaround:
        std::string optString( options->getOptionString() );
        for(std::string::iterator it=optString.begin(); it!=optString.end(); ++it) {
            if (*it == ' ') *it = ',';
        }
        std::istringstream iss( optString );
        std::string opt;

        //while (iss >> opt)
        while( std::getline( iss, opt, ',' ) )
        {
            if( opt == "polygon") pluginOptions.usePolygons = true;
            else if (opt == "GoogleMode") pluginOptions.googleMode = true;
            else if (opt == "NoExtras") pluginOptions.writeExtras = false;
            else if (opt == "daeEarthTex") pluginOptions.earthTex = true;
            else if (opt == "daeZUpAxis") {}    // Nothing (old option)
            else if (opt == "daeLinkOriginalTexturesNoForce") { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = false; }
            else if (opt == "daeLinkOriginalTexturesForce")   { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = true; }
            else if (opt == "daeNamesUseCodepage") pluginOptions.namesUseCodepage = true;
            else if (!opt.empty())
            {
                OSG_NOTICE << std::endl << "COLLADA dae plugin: unrecognized option \"" << opt <<  std::endl;
            }
        }
    }
QIcon FileIconProvider::getIconByExt(const QString &fileName)
{     
    QString ext(QFileInfo(fileName).suffix());

    if(!ext.isEmpty())
    {
        QFileInfo fileInfo(pathWithDot + ext);
        return icon(fileInfo);
    }

    return QIcon();
}
Example #13
0
char *FileName::removeExt(const char *str)
{
    const char *e = ext(str);
    if (e)
    {   size_t len = (e - str) - 1;
        char *n = (char *)mem.malloc(len + 1);
        memcpy(n, str, len);
        n[len] = 0;
        return n;
    }
    return mem.strdup(str);
}
Example #14
0
string externalTypeToClass(const string &name)
{
  string cls = name;
  string ext("external.");
  size_t index = cls.find(ext);
  if (index != string::npos)
    cls.erase(0, ext.length());

  replace(cls, ".", "::");

  return cls;
}
BOOL CChordEaseDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	if (gEngine.ReadSong(lpszPathName))	// read song
		AutoRecord(TRUE);	// start auto-recording if applicable
	CString	ext(PathFindExtension(lpszPathName));
	if (!ext.CompareNoCase(LEAD_SHEET_EXT))	// if lead sheet extension
		UpdateSongText();	// update song text from song's binary data
	// intentionally override read return code, so user can correct errors
	return TRUE;
}
Example #16
0
void
draw_confg_left (ALLEGRO_BITMAP *bitmap, struct pos *p,
                 enum em em, enum vm vm)
{
  enum carpet_design d;

  switch (fake (p)) {
  case NO_FLOOR: return;
  case FLOOR: draw_floor_left (bitmap, p, em, vm); break;
  case BROKEN_FLOOR: draw_broken_floor_left (bitmap, p, em, vm); break;
  case SKELETON_FLOOR: draw_skeleton_floor_left (bitmap, p, em, vm); break;
  case LOOSE_FLOOR: draw_loose_floor_left (bitmap, p, em, vm); break;
  case SPIKES_FLOOR: draw_spikes_floor_left (bitmap, p, em, vm); break;
  case OPENER_FLOOR: draw_opener_floor_left (bitmap, p, em, vm); break;
  case CLOSER_FLOOR: draw_closer_floor_left (bitmap, p, em, vm); break;
  case STUCK_FLOOR: draw_pressed_closer_floor_left (bitmap, p, em, vm); break;
  case HIDDEN_FLOOR: return;
  case PILLAR: draw_pillar_left (bitmap, p, em, vm); break;
  case BIG_PILLAR_BOTTOM:
    draw_big_pillar_bottom_left (bitmap, p, em, vm); break;
  case BIG_PILLAR_TOP:
    draw_big_pillar_top_left (bitmap, p, em, vm); break;
  case WALL:
    if (con_caching) draw_wall_left (bitmap, p, em, vm);
    else draw_wall_left_cache (bitmap, p);
    break;
  case DOOR: draw_door_left (bitmap, p, em, vm); break;
  case LEVEL_DOOR: draw_level_door_left (bitmap, p, em, vm); break;
  case CHOPPER: draw_chopper_left (bitmap, p, em, vm); break;
  case ARCH_BOTTOM:
    draw_floor_left (bitmap, p, em, vm);
    draw_arch_bottom (bitmap, p, em, vm); break;
  case ARCH_TOP_MID: draw_arch_top_mid (bitmap, p, em, vm); break;
  case ARCH_TOP_SMALL: draw_arch_top_small (bitmap, p, em, vm); break;
  case ARCH_TOP_LEFT: draw_arch_top_left (bitmap, p, em, vm); break;
  case ARCH_TOP_RIGHT: draw_arch_top_right (bitmap, p, em, vm); break;
  case CARPET:
    draw_floor_left (bitmap, p, em, vm);
    draw_door_pole (bitmap, p, em, vm);
    break;
  case TCARPET:
    d = ext (p);
    if (d == ARCH_CARPET_RIGHT_00 || d == ARCH_CARPET_RIGHT_01)
      draw_arch_top_right_end (bitmap, p, em, vm);
    else draw_door_pole (bitmap, p, em, vm);
    break;
  case MIRROR:
    draw_floor_left (bitmap, p, em, vm);
    draw_mirror (bitmap, p, em, vm);
    break;
  default: assert (false); break;
  }
}
Example #17
0
void CSpectrumFrame::SaveBmp()
{
	FILE *out;
	BITMAPFILEHEADER BmpHeader;
	/////////диалог сохранения файла
	char Tmp_File_Name[256];
	// Создаем объект блока диалога
	CFileDialog fileDlg(FALSE);
	fileDlg.m_ofn.lpstrInitialDir="NULL";
	// Определяем расширение, которое будет присваиваться
	// имени файла по умолчанию
	CString ext("bmp");
	fileDlg.m_ofn.lpstrDefExt = ext;
	//устанавливаю фильтры на файлы
	CString str("Bmp файлы (*.bmp)"); str += (TCHAR)NULL;
	str += "*.bmp"; str += (TCHAR)NULL;
	
	fileDlg.m_ofn.lpstrFilter = str;
	fileDlg.m_ofn.nFilterIndex=1;
	//имя по умолчанию
	Tmp_File_Name[0] ='\0' ;
	strcpy(Tmp_File_Name,"CrazyLayers.bmp");
	fileDlg.m_ofn.lpstrFile	= Tmp_File_Name;
	// Заголовок блока диалога
	TCHAR title[] = "Сохранить BMP файл";
	fileDlg.m_ofn.lpstrTitle = title;
	// Задаем вывод флажка "Только для чтения" (Read Only) и
	// снимаем режим Проводник (Explorer)
	//fileDlg.m_ofn.Flags &= ~(OFN_HIDEREADONLY  | OFN_EXPLORER);
	
	// Выводим блок диалога на экран
	if(fileDlg.DoModal() == IDOK)
	{
		
		out=fopen(fileDlg.m_ofn.lpstrFile,"wb");
		///////////////////////
		BmpHeader.bfType = 0x4D42;
		BmpHeader.bfSize = 0x10436L;
		BmpHeader.bfReserved1 =
			BmpHeader.bfReserved2 = 0;
		BmpHeader.bfOffBits = 0x436;
		
		fwrite(&BmpHeader, sizeof(BITMAPFILEHEADER),1,out);
		fwrite(Pallete, sizeof(BITMAPINFO) + sizeof(RGBQUAD)*255,1,out);
		for(int i=0; i<m_iDem*m_iDem; i++)
			fwrite(&m_bArroy[i], 1,1,out);
		///////////////////////
		fclose(out);
		
	}
	
}
Example #18
0
void JObjectTree::Traverse( TraverseCallback callback, void* pContext ) const
{
    if (!m_pRoot) return;
    float nodeW    = m_NodeWidth;
    float nodeVisH = m_NodeHeight;
    Frame ext( m_RootPos.x, m_RootPos.y, nodeW, nodeVisH );

    //  find node path for tree expansion
    static std::vector<int> nodePath;
    nodePath.clear();
    JObject* pCurObj = m_pExpanded;
    if (pCurObj) nodePath.push_back( 0 );
    while (pCurObj && pCurObj != m_pRoot)
    {
        JObject* pParent = pCurObj->GetParent();
        if (!pParent) break;
        nodePath.push_back( pParent->GetChildIndex( pCurObj ) );
        pCurObj = pParent;
    }

    //  traverse root node (which is never collapsed)
    if ((this->*callback)( ext, m_pRoot, (m_pExpanded != NULL), pContext ) == false) return;

    //  traverse along expansion path
    pCurObj = m_pRoot;
    for (int i = nodePath.size() - 1; i >= 0; i--)
    {
        int childIdx = nodePath[i];
        if (!pCurObj) break;
        int nCh = pCurObj->GetNChildren();
        if (childIdx >= nCh) break;
        float blockH = float( nCh )*nodeVisH;
        ext.y = ext.y - blockH*0.5f + nodeVisH*0.5f;
        ext.x += nodeW;
        float cY = ext.y;
        for (int j = 0; j < nCh; j++)
        {
            JObject* pChild = pCurObj->GetChild( j );
            Frame chExt( ext );
            chExt.y = cY;
            bool bExpanded = (j == childIdx)&&(pCurObj != m_pExpanded);
            if ((this->*callback)( chExt, pChild, bExpanded, pContext ) == false)
            {
                return;
            }
            cY += nodeVisH;
        }
        pCurObj = pCurObj->GetChild( childIdx );
        ext.y += float( childIdx )*nodeVisH;
    }

} // JObjectTree::Traverse
Example #19
0
void
DPath::SetExtension(const char *string)
{
	BString ext(GetExtension());
	if (ext.CountChars() > 0)
		fFullPath.ReplaceLast(ext.String(), string);
	else
	{
		BString temp(fFullPath);
		temp << "." << string;
		SetTo(temp);
	}
}
Example #20
0
bool MItem::result( WFileName& fn )
{
    if( ismakeable() ) {
        fn.setFName( fName() );
        if( _isTarget ) {
            fn.setExt( ext() );
        } else {
            fn.setExt( rule()->resultExt() );
        }
        return( true );
    }
    return( false );
}
Example #21
0
static DF1(jtpowseqlim){PROLOG(0039);A x,y,z,*zv;I i,n;
 RZ(w);
 RZ(z=exta(BOX,1L,1L,20L)); zv=AAV(z); *zv++=x=w;
 i=1; n=AN(z);
 while(1){
  if(n==i){RZ(z=ext(0,z)); zv=i+AAV(z); n=AN(z);}
  RZ(*zv++=x=df1(y=x,self));
  if(equ(x,y)){AN(z)=*AS(z)=i; break;}
  ++i;
 }
 z=ope(z);
 EPILOG(z);
}    /* f^:(<_) w */
Example #22
0
long CDownload::retrieveLocalFile(const MYCHAR* _url,int _order,MyString& _path, MyString& _short)
{

	MyString url = _url;
	
	MyString ext(getext(url));	
	
	if (!ext.CompareNoCase("zip"))
	{
	
		if (!retrieveZippedFile(url,_order,_path,_short))
		{
			if (!unzipFile(url,url))
			{
				// unzip failed...
				outputInfo("unzip failed (%s)\n",_url);
				return 0;
			}
			if (!retrieveZippedFile(url,_order,_path,_short))
			{
				outputInfo("could not find zip (%s)\n",_url);
				return 0;
			}
		}
		
	}
	else
	{
		_path = url;
		
		_short = getfile(url);
	}



	FILE* f = fopen(_path.c_str(),"rb");
	if (f)
	{
		/*int err =*/ fseek(f,0,SEEK_END);
		long size = ftell(f);
		fclose(f);	
		return size;
	}
	else
	{
		outputInfo("could not find file (%s)\n",_url);
		::showStatus("Failed to load %s",getfile(_url));
		return 0;
	}

}
Example #23
0
	virtual result on_token(const char * token)
			{
		reset();
		if (!stricmp_utf8_partial(token,"/columnsui:"))
		{
			const char * ptr = strchr(token,':')+1;
			if (!stricmp_utf8(ptr,"help") || !stricmp_utf8(ptr,"?"))
			{
				HWND parent = core_api::get_main_window();
				if (parent) static_api_ptr_t<ui_control>()->activate();//SetActiveWindow(parent);
				uMessageBox(parent,g_help_text,"Columns UI commandline help",0);
				return RESULT_PROCESSED;
			}
			else if (!stricmp_utf8_partial(ptr,"import:"))
			{
				ptr += 7;
				if (*ptr && *ptr =='\"') ptr++;
				unsigned len = strlen(ptr);
				const char * end = strchr(ptr, '\"');
				if (end) len = end-ptr;

				pfc::string8 path(ptr, len);

				HWND parent = core_api::get_main_window();
				if (parent) static_api_ptr_t<ui_control>()->activate();
				if (uMessageBox(parent,uStringPrintf("Are you sure you want to import the %s configuration? Your current configuration will be lost.",pfc::string_filename(path).get_ptr()),"Import configuration?",MB_YESNO) == IDYES)
				{
					pfc::string_extension ext(path);
					if (!stricmp_utf8("fcl", ext))
						g_import_layout(core_api::get_main_window(), path);
					else if (!stricmp_utf8("fcs", ext))
						g_import(path);
				}
				return RESULT_PROCESSED;
			}
			/*else if (!stricmp_utf8_partial(ptr,"export:"))
			{
				ptr += 7;
				if (*ptr && *ptr =='\"') ptr++;
				unsigned len = strlen(ptr);
				const char * end = strchr(ptr, '\"');
				if (end) len = end-ptr;

				pfc::string8 path(ptr, len);
				g_export(path);

				return RESULT_PROCESSED;
			}*/
		}
		return RESULT_NOT_OURS;
	}
Example #24
0
OJString GetFileName(const OJString &path)
{
    OJString res(GetFullFileName(path));

    if (!res.empty())
    {
        OJString ext(GetFileExt(path));

        if (!ext.empty())
            res = res.substr(0, res.size() - ext.size());
    }

    return res;
}
Example #25
0
bool checkAssociation(const QString & extension)
{
    if(!isSupportAssociation()) return false;

#ifndef Q_WS_WIN
    return false;
#else

    /*! The HKEY_CLASSES_ROOT subtree is a view formed by merging
     *  HKEY_CURRENT_USER\Software\Classes and
     *  HKEY_LOCAL_MACHINE\Software\Classes
     */
    QSettings RegCR("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
    QSettings RegCU("HKEY_CURRENT_USER", QSettings::NativeFormat);

    QString ext("." + extension);
    QString ProgID = makeProgID(extension);

    QString fileName = QFileInfo(qApp->applicationFilePath()).fileName();
    QString FileExtsKey = QString("Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/") + ext;
    /// Windows 7:"/UserChoice/Progid" ;   XP: "/Progid"
    QString CurClassId = (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
            ? RegCU.value(FileExtsKey + "/UserChoice/Progid").toString()
            : RegCU.value(FileExtsKey + "/Progid").toString();
    QString CurAppId = RegCU.value(FileExtsKey + "/Application").toString(); /// Windows XP

    bool isRegistered = false;
    if (QSysInfo::WindowsVersion >= QSysInfo::WV_NT){
        if (!CurClassId.isEmpty()) {
            isRegistered = (CurClassId == ProgID) || (0 == CurClassId.compare(fileName, Qt::CaseInsensitive))
                    || (0 == CurClassId.compare(QString("Applications\\%1").arg(fileName), Qt::CaseInsensitive));
        }else if (!CurAppId.isEmpty()){
            //If user uses Open With..., explorer creates it's own ClassId under Application, like "smplayer.exe"
            isRegistered = (CurAppId == ProgID) || (0 == CurAppId.compare(fileName, Qt::CaseInsensitive));
        }else{
            //No classId means that no associations exists in Default Programs or Explorer
            //Check the default per-user association
            isRegistered = (RegCU.value("Software/Classes/" + ext + REG_DEFAULT).toString() == ProgID);
        }
    }

    //Finally, check the system-wide association
    //若CurClassId或CurAppId不为空,说明用户在“打开方式”中选择了其他程序,优先级高,会覆盖其他设置。
    if (!isRegistered && CurClassId.isEmpty() && CurAppId.isEmpty())
        isRegistered = (RegCR.value(ext + REG_DEFAULT).toString() == ProgID);

    return isRegistered && hasProgID(ProgID);

#endif  // Q_WS_WIN
}
Example #26
0
void CJobRunner::getAssociatedUrls(const KUrl &url, KUrl::List &list, bool afmAndPfm, QWidget *widget)
{
    QString ext(url.path());
    int     dotPos(ext.lastIndexOf('.'));
    bool    check(false);

    if(-1==dotPos) // Hmm, no extension - check anyway...
        check=true;
    else           // Cool, got an extension - see if it is a Type1 font...
    {
        ext=ext.mid(dotPos+1);
        check=0==ext.compare("pfa", Qt::CaseInsensitive) ||
              0==ext.compare("pfb", Qt::CaseInsensitive);
    }

    if(check)
    {
        const char *afm[]={"afm", "AFM", "Afm", NULL},
                   *pfm[]={"pfm", "PFM", "Pfm", NULL};
        bool       gotAfm(false),
                   localFile(url.isLocalFile());
        int        e;

        for(e=0; afm[e]; ++e)
        {
            KUrl          statUrl(url);
            KIO::UDSEntry uds;
            statUrl.setPath(Misc::changeExt(url.path(), afm[e]));
            if(localFile ? Misc::fExists(statUrl.toLocalFile()) : KIO::NetAccess::stat(statUrl, uds, widget))
            {
                list.append(statUrl);
                gotAfm=true;
                break;
            }
        }

        if(afmAndPfm || !gotAfm)
            for(e=0; pfm[e]; ++e)
            {
                KUrl          statUrl(url);
                KIO::UDSEntry uds;
                statUrl.setPath(Misc::changeExt(url.path(), pfm[e]));
                if(localFile ? Misc::fExists(statUrl.toLocalFile()) : KIO::NetAccess::stat(statUrl, uds, widget))
                {
                    list.append(statUrl);
                    break;
                }
            }
    }
}
Example #27
0
void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::string gameRegion, bool isSlotA)
{
	std::string ext("." + gameRegion + ".raw");
	if (memcardPath.empty())
	{
		// Use default memcard path if there is no user defined name
		std::string defaultFilename = isSlotA ? GC_MEMCARDA : GC_MEMCARDB;
		#ifdef _WIN32
			memcardPath = "." + File::GetUserPath(D_GCUSER_IDX).substr(File::GetExeDirectory().size()) + defaultFilename + ext;
		#else
			memcardPath = File::GetUserPath(D_GCUSER_IDX) + defaultFilename + ext;
		#endif
	}
	else
	{
		std::string filename = memcardPath;
		std::string region = filename.substr(filename.size()-7, 3);
		bool hasregion = false;
		hasregion |= region.compare(USA_DIR) == 0;
		hasregion |= region.compare(JAP_DIR) == 0;
		hasregion |= region.compare(EUR_DIR) == 0;
		if (!hasregion)
		{
			// filename doesn't have region in the extension
			if (File::Exists(filename))
			{
				// If the old file exists we are polite and ask if we should copy it
				std::string oldFilename = filename;
				filename.replace(filename.size()-4, 4, ext);
				if (PanicYesNoT("Memory Card filename in Slot %c is incorrect\n"
					"Region not specified\n\n"
					"Slot %c path was changed to\n"
					"%s\n"
					"Would you like to copy the old file to this new location?\n",
					isSlotA ? 'A':'B', isSlotA ? 'A':'B', filename.c_str()))
				{
					if (!File::Copy(oldFilename, filename))
						PanicAlertT("Copy failed");
				}
			}
			memcardPath = filename; // Always correct the path!
		}
		else if (region.compare(gameRegion) != 0)
		{
			// filename has region, but it's not == gameRegion
			// Just set the correct filename, the EXI Device will create it if it doesn't exist
			memcardPath = filename.replace(filename.size()-ext.size(), ext.size(), ext);;
		}
	}
}
Example #28
0
InputParameters validParams<GNUPlot>()
{
  // Get the parameters from the parent object
  InputParameters params = validParams<TableOutputter>();

  // Set an enum for the possible file extensions
  MooseEnum ext("png ps gif", "png", "GNU plot file extension");
  params.addParam<MooseEnum>("extension", ext, "GUN plot file extension");

  // Suppress unused parameters
  params.suppressParameter<unsigned int>("padding");

  return params;
}
Example #29
0
pascal Boolean CrossPlatformFilterCallback (
    AEDesc *theItem,
    void *info,
    void *callBackUD,
    NavFilterModes filterMode
)
{
    bool display = true;
    DialogData* data = (DialogData*)(callBackUD);
	
    if (filterMode == kNavFilteringBrowserList)
    {
        NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
        if ( !theInfo->isFolder )
        {
            /*
			if (theItem->descriptorType == typeFSS )
            {
                FSSpec    spec;
                memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
				std::cout << "unhandled" << std::endl;
			}
            else 
			*/
			if ( theItem->descriptorType == typeFSRef )
            {
                FSRef fsref ;
                memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;

                CFURLRef fullURLRef;
                fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref);
                CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
                CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
                ::CFRelease( fullURLRef ) ;
				char buffer[2048];
				
				if (CFStringGetCString(cfString, buffer, 2048, kCFStringEncodingUTF8)) {
					std::string filestr(buffer);
					std::string ext(osgDB::getFileExtension(filestr));
					display = (data->allowedExtensions.find(ext) != data->allowedExtensions.end());
					
				}
				::CFRelease( cfString );
				
			}
        }
    }

    return display;
}
void MainWindow::dropEvent(QDropEvent *event)
{
    QList<QUrl> urls = event->mimeData()->urls();
    if (urls.isEmpty())
        return;

    QString fileName = urls.first().toLocalFile();
    if (fileName.isEmpty())
        return;

    std::string ext(".bmp");
    if (hasEnding(fileName.toStdString(), ext))
        openSourceImage(fileName);
}