Ejemplo n.º 1
0
void Operator::ShowStat() const
{
	unsigned int OpSize = 12*numLines[0]*numLines[1]*numLines[2]*sizeof(FDTD_FLOAT);
	unsigned int FieldSize = 6*numLines[0]*numLines[1]*numLines[2]*sizeof(FDTD_FLOAT);
	double MBdiff = 1024*1024;

	cout << "------- Stat: FDTD Operator -------" << endl;
	cout << "Dimensions\t\t: " << numLines[0] << "x" << numLines[1] << "x" << numLines[2] << " = " <<  numLines[0]*numLines[1]*numLines[2] << " Cells (" << numLines[0]*numLines[1]*numLines[2]/1e6 << " MCells)" << endl;
	cout << "Size of Operator\t: " << OpSize << " Byte (" << (double)OpSize/MBdiff << " MiB) " << endl;
	cout << "Size of Field-Data\t: " << FieldSize << " Byte (" << (double)FieldSize/MBdiff << " MiB) " << endl;
	cout << "-----------------------------------" << endl;
	cout << "Number of PEC edges\t: " << m_Nr_PEC[0]+m_Nr_PEC[1]+m_Nr_PEC[2] << endl;
	cout << "in " << GetDirName(0) << " direction\t\t: " << m_Nr_PEC[0] << endl;
	cout << "in " << GetDirName(1) << " direction\t\t: " << m_Nr_PEC[1] << endl;
	cout << "in " << GetDirName(2) << " direction\t\t: " << m_Nr_PEC[2] << endl;
	cout << "-----------------------------------" << endl;
	cout << "Timestep (s)\t\t: " << dT ;
	if (opt_dT)
		cout <<"\t(" << opt_dT << ")";
	cout << endl;
	cout << "Timestep method name\t: " << m_Used_TS_Name << endl;
	cout << "Nyquist criteria (TS)\t: " << Exc->GetNyquistNum() << endl;
	cout << "Nyquist criteria (s)\t: " << Exc->GetNyquistNum()*dT << endl;
	cout << "-----------------------------------" << endl;
}
// XXX Although mailing lists could use the NotifyItemPropertyChanged
// mechanism here, it requires some rework on how we write/save data
// relating to mailing lists, so we're just using the old method of a
// local variable to store the mailing list name.
NS_IMETHODIMP nsAbDirProperty::SetDirName(const nsAString &aDirName)
{
  if (m_DirPrefId.IsEmpty())
  {
    m_ListDirName = aDirName;
    return NS_OK;
  }

  // Store the old value.
  nsString oldDirName;
  nsresult rv = GetDirName(oldDirName);
  NS_ENSURE_SUCCESS(rv, rv);

  // Save the new value
  rv = SetLocalizedStringValue("description", NS_ConvertUTF16toUTF8(aDirName));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID, &rv);

  if (NS_SUCCEEDED(rv))
    // We inherit from nsIAbDirectory, so this static cast should be safe.
    abManager->NotifyItemPropertyChanged(static_cast<nsIAbDirectory*>(this),
                                         "DirName", oldDirName.get(),
                                         nsString(aDirName).get());

  return NS_OK;
}
Ejemplo n.º 3
0
// Update the state of this collection.
void CDownloadCollection::UpdateDownloadState(IPathManager* pPathManager)
{
	// Try to read the dir file.
	CString csDirName = pPathManager->LocatePath(GetDirName());
	if (!csDirName.IsEmpty() && m_Dir.Read(csDirName))
	{
		// We have the directory!
		// To prevent myself from going insane trying to figure out all
		// the possible permutations of things, I am restricting the downloaded
		// files to live where the DIR file does.

		CString csDirectory;
		Util::SplitPath(csDirName, &csDirectory, NULL);

		m_nState = STATE_Downloaded;		// Assume so!

		// Check the state of each file.
		const CDownloadFileArray& Files = m_Dir.GetFiles();
		for (int n = 0; n < Files.GetSize(); n++)
		{
			if (!Files[n].CheckDownloadState(csDirectory))
			{
				// Not all files are downloaded.
				m_nState = STATE_PartiallyDownloaded;
				break;
			}
		}
	}
	else
	{
		// No valid DIR file.
		m_nState = STATE_NotDownloaded;
	}
}
Ejemplo n.º 4
0
string SkinDlg::DisplayDirList(const string& strCurrent)
{
    char pszPath[MAX_PATH + 1];
    strcpy(pszPath, GetDirName(strCurrent).c_str()) ;

    BROWSEINFO bi ;
    bi.hwndOwner		= m_hWnd;
    bi.pidlRoot		= NULL ;
    bi.pszDisplayName	= NULL ;
    bi.lpszTitle		= "フォルダを選択して下さい" ;
    bi.ulFlags		= 0x8000 ;//BIF_SHAREABLE ;
    bi.lpfn			= (BFFCALLBACK)BrowseProc ;
    bi.lParam		= (LPARAM)pszPath ;
    bi.iImage		= NULL ;

    LPITEMIDLIST idlist = SHBrowseForFolder( &bi);
    if( idlist)
    {
        char pszPath[MAX_PATH + 1];
        SHGetPathFromIDList( idlist, pszPath) ;
        CoTaskMemFree( idlist) ;

        string s = pszPath;
        return s + '\\';
    }

    return "";
}
Ejemplo n.º 5
0
std::string FileDialog::GetFileName(void)
{
    std::string fn(GetDirName());
    if(fn.length())
        fn += '/';
    fn += (_selFile ? _selFile->name() : tbFilename->getText());
    return fn;
}
Ejemplo n.º 6
0
BOOL ZipDlg::OnBrowseBtn( HWND hDlg, WPARAM wParam, LPARAM lParam)
{
	char pszZipPath[ MAX_PATH + 1] ;

	// 既に入力されているパスを取得
	GetDlgItemText( m_hWnd, IDC_ZIPPATH, pszZipPath, MAX_PATH) ;
	char pszPath[ MAX_PATH + 1];
	strcpy_s( pszPath, GetDirName( pszZipPath).c_str()) ;

	// 一曲目のパスを取得
	if( strcmp( pszPath, "") == 0 && vecFileList.size() != 0)
	{
		strcpy_s( pszPath, GetDirName( vecFileList[ 0]->GetFilePath()).c_str());
	}

	BROWSEINFO bi ;
	bi.hwndOwner		= hDlg ;
	bi.pidlRoot		= NULL ;
	bi.pszDisplayName	= NULL ;
	bi.lpszTitle		= "フォルダを選択して下さい" ;
	bi.ulFlags		= 0x8000 ;//BIF_SHAREABLE ;
	bi.lpfn			= (BFFCALLBACK)BrowseProc ;
	bi.lParam		= (LPARAM)pszPath ;
	bi.iImage		= NULL ;

	LPITEMIDLIST idlist = SHBrowseForFolder( &bi);
	if( idlist)
	{
		char pszPath[ MAX_PATH] ;
		SHGetPathFromIDList( idlist, pszPath) ;
		CoTaskMemFree( idlist) ;

		File file( pszPath) ;
		if( file.GetFileName() != "")
		{
			string s = string( pszPath) + "\\" ;
			SetDlgItemText( hDlg, IDC_ZIPPATH, s.c_str()) ;
		}
		else
		{
			SetDlgItemText( hDlg, IDC_ZIPPATH, pszPath) ;
		}
	}

	return TRUE ;
}
Ejemplo n.º 7
0
Stroka RealLocation(const Stroka& path) {
    if (isexist(~path))
        return RealPath(path);
    Stroka dirpath = GetDirName(path);
    if (isexist(~dirpath))
        return  RealPath(dirpath) + GetDirectorySeparatorS() + GetFileNameComponent(~path);
    ythrow TFileError() << "RealLocation failed \"" << path << "\"";
}
Ejemplo n.º 8
0
Stroka StripFileComponent(const Stroka& fileName)
{
    Stroka dir = IsDir(fileName) ? fileName : GetDirName(fileName);
    if (!dir.empty() && dir.back() != GetDirectorySeparator()) {
        dir.append(GetDirectorySeparator());
    }
    return dir;
}
Ejemplo n.º 9
0
void FileDialog::_Update(void)
{
    _curDir = NULL;
    std::string capt(_save ? "Save to..." : "Open file...");
    capt += " [";
    capt += GetDirName();
    capt += ']';
    gcn::Window::setCaption(capt);
}
Ejemplo n.º 10
0
string File::GetFileDir() const
{
	string strPath = zipheader.strFilename ;
	if( strPath == "")
	{
		return "" ;
	}

	return GetDirName( strPath) ;
}
Ejemplo n.º 11
0
/**
 * Provides the full path name to a given directory.
 */
static char* full_path_to(short vRefNum, long dirID)
{
	long parID;
	if (GetParentID(vRefNum, dirID, NULL, &parID) == noErr) {
		FSSpec dirSpec = { vRefNum, parID };
		if (GetDirName(vRefNum, dirID, dirSpec.name) == noErr) {
			return full_path_to(dirSpec);
		}
	}
	return NULL;
}
NS_IMETHODIMP nsAbDirProperty::GetUuid(nsACString &uuid)
{
  // XXX: not all directories have a dirPrefId...
  nsresult rv = GetDirPrefId(uuid);
  NS_ENSURE_SUCCESS(rv, rv);
  uuid.Append('&');
  nsString dirName;
  GetDirName(dirName);
  uuid.Append(NS_ConvertUTF16toUTF8(dirName));
  return rv;
}
Ejemplo n.º 13
0
	virtual	void FileProcess(const char *parentUrl,const char* url,const char* fileData,int dataLen)
	{
		CMyString lUrl=(char*)url;
		CMyString path=CUrl::GetUrlPath(lUrl);
		CMyString name=CUrl::GetFileName(lUrl);
		if(path!=""&&name!="")
		{
			GetDirName(path);
			m_TempStr=m_FilePath+m_TempStr;
			CMyFile::CreateDir(m_TempStr.GetBuffer());
			m_TempStr+="\\"+name;
		}
	}
Ejemplo n.º 14
0
void sBrowserApp::GetPath(sChar *buffer,sInt size)
{
  sInt i;

  GetDirName(buffer,size);
  i = sGetStringLen(buffer);
  buffer+=i;
  *buffer++ = '/';
  size-=i+1;
  GetFileName(buffer,size);
  if(*buffer==0)
    buffer[-1] = 0;
}
Ejemplo n.º 15
0
void CGameLauncher::setupDosExecDialog()
{
    const std::string dataDir = getDirectory( m_chosenGame );

    // TODO: fetch the List of available patch files
    // Get the list of ".pat" files
    DosExecListFiller dosExecList;
    FindFiles(dosExecList, dataDir, false, FM_REG);

    if( dosExecList.list.empty() )
    {
        mExecFilename = "";
        mDoneExecSelection=true;
        return;
    }

    // If the there are not at least 2 mods to select, do not create the patch selection dialog
    if( dosExecList.list.size() == 1 )
    {
        mExecFilename = *(dosExecList.list.begin());
        mDoneExecSelection=true;
        return;
    }

    mpDosExecDialog.reset(new CGUIDialog(GsRect<float>(0.1f, 0.1f, 0.8f, 0.85f), CGUIDialog::EXPAND)),
    mpDosExecDialog->initEmptyBackground();


    if(!mDosExecStrVec.empty())
        mDosExecStrVec.clear();

    mpDosExecSelList = new CGUITextSelectionList();


    for( auto &elem : dosExecList.list )
    {
        const std::string dirname = GetDirName(elem);
        std::string name = elem.substr(dirname.size()+1);
        mDosExecStrVec.push_back(elem);
        mpDosExecSelList->addText(name);
    }

    mpDosExecSelList->setConfirmButtonEvent(new GMDosExecSelected());
    mpDosExecSelList->setBackButtonEvent(new GMQuit());

    mpDosExecDialog->addControl(new CGUIText("Choose your executable:"), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
    mpDosExecDialog->addControl(mpDosExecSelList, GsRect<float>(0.01f, 0.07f, 0.49f, 0.87f));


    mpDosExecDialog->addControl(new GsButton( "Start >", new GMDosExecSelected() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );
}
Ejemplo n.º 16
0
t_instance_outcome cInstanceObject::TryToBecomeInstance(int inst) { // test instance, tries to become it
	_info("Trying instance inst="<<inst);

	const std::string igrp_name = std::string("instancegroup_") 
		+ m_program_name // testprogram
		+ ( (m_range==e_range_user) ? ("_user_n_"+cMyNamedMutex::EscapeMutexNameWithLen(GetUserName())) : ( "_user_ANY" ) ) // testprogram_alice  testprogram
		+ ( (m_range==e_range_maindir) ? ("_dir_n_"+cMyNamedMutex::EscapeMutexNameWithLen(GetDirName())) : ( "_dir_ANY" )   )
	;

	_info("igrp_name=" << igrp_name);

	boost::interprocess::permissions mutex_curr_perms;
	if (m_range==e_range_system) mutex_curr_perms.set_unrestricted(); // others users on same system need to synchronize with this

	std::ostringstream mutex_name_str; mutex_name_str << igrp_name << "_instM" << inst;
	std::string mutex_name = mutex_name_str.str();

	// mutex_name="name1foo1";
	_info("Will try to become instance as mutex_name="<<mutex_name);

	m_curr_mutex.reset( new cMyNamedMutex ( boost::interprocess::open_or_create, mutex_name.c_str(), mutex_curr_perms ) );
	// we created this mutex or it existed

	bool curr_locked = m_curr_mutex->try_lock_msg(str_to_vec("La"));// GetProcessIdentification() ) );
	if (curr_locked) { // we locked it! 
		_info("WE BECOME INSTANCE: Created and locked the Mc - we became the instance at inst="<<inst);
		m_curr_mutex->SetOwnership(true); // I own this mutex e.g. M5

		// I am probably the leader
		
		// ... TODO ... ping all lower numbers are they responding after all to ping ...


		_info("I will start responding to pings (curr)");
		m_pingable_curr.reset(new cInstancePingable( mutex_name, mutex_curr_perms )); // start responding to ping
		m_pingable_curr->Run();

		return e_instance_i_won; // we created and locked (or just locked - reclaimed) an instance
	}

	_info("Can not create/lock the Mc so we lost or it is dead. inst="<<inst);
	bool other_is_alive = PingInstance(mutex_name, mutex_curr_perms);

	if (! other_is_alive) {
		_info("The other instance is dead!");
		return e_instance_seems_dead;
	}
	
	return e_instance_i_lost;
}
Ejemplo n.º 17
0
bool try_save_config(const string& fname, GLEInterface* iface, bool isUser) {
	ConfigCollection* collection = iface->getConfig()->getRCFile();
	if (collection->allDefaults()) {
		return true;
	}
	if (fname == "") {
		return false;
	}
	if (IsAbsPath(fname)) {
		std::string dirname;
		GetDirName(fname, dirname);
		EnsureMkDir(dirname);
	}
	ofstream fout(fname.c_str());
	if (!fout.is_open()) {
		return false;
	}
	CmdLineOption* versionOption = collection->getSection(GLE_CONFIG_GLE)->getOption(GLE_CONFIG_GLE_VERSION);
	ostringstream out;
	out << "Save configuration to: '" << fname << "'";
	GLEOutputStream* output = iface->getOutput();
	output->println(out.str().c_str());
	for (int i = 0; i < collection->getNbSections(); i++) {
		ConfigSection* sec = collection->getSection(i);
		if (!sec->allDefaults()) {
			fout << "begin config " << sec->getName() << endl;
			for (int j = 0; j < sec->getNbOptions(); j++) {
				CmdLineOption* option = sec->getOption(j);
				if (!option->allDefaults() && (!isUser || option != versionOption)) {
					fout << "\t" << option->getName() << " = ";
					for (int k = 0; k < option->getMaxNbArgs(); k++) {
						if (k != 0) fout << " ";
						CmdLineOptionArg* arg = option->getArg(k);
						arg->write(fout);
					}
					fout << endl;
				}
			}
			fout << "end config" << endl << endl;
		}
	}
	fout.close();
	return true;
}
Ejemplo n.º 18
0
BOOL Controller::ExtractDetail( UINT ui, UINT uiMsg)
{
	if( pArchiveFile->GetStatus() != ArchiveFile::Status::UNCOMPRESSED)
	{
		return FALSE ;
	}

	string strOutPath ;

	if( uiMsg == IDM_EXTRACT_HERE)
	{
		strOutPath = GetDirName(pArchiveFile->GetChildFile(ui)->GetArchivePath()) ;
		strOutPath += pArchiveFile->GetChildFile(ui)->GetFileName() ;
	}
	else if( uiMsg == IDM_EXTRACT_SELECT)
	{
		OPENFILENAME	ofn ;
		char		pszFileBuf[ MAX_PATH + 1];
		strncpy(pszFileBuf,  pArchiveFile->GetChildFile(ui)->GetFileName().c_str(), MAX_PATH + 1);

		ZeroMemory( (LPVOID)&ofn, sizeof(OPENFILENAME));
		ofn.lStructSize = sizeof(OPENFILENAME);
		ofn.hwndOwner = pMainWnd->GetHwnd() ;
		ofn.lpstrFilter = "すべてのファイル\0*.*\0MP3(*.mp3)\0*.mp3\0\0";
		ofn.Flags = OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT ;
		ofn.lpstrFile = pszFileBuf;
		ofn.nMaxFile = MAX_PATH ;
		ofn.lpstrTitle = "保存するファイル名を入力してください" ;
		if( !GetSaveFileName( &ofn))
		{
			DWORD d = CommDlgExtendedError();
			return 0 ;
		}
		strOutPath = pszFileBuf ;
	}
	else if( uiMsg == IDM_EXTRACT_DESKTOP)
	{
		char pszBuf[ MAX_PATH] ;
		SHGetSpecialFolderPath( NULL, pszBuf, CSIDL_DESKTOP, 0) ;
		strOutPath = string( pszBuf) + "\\" + pArchiveFile->GetChildFile( ui)->GetFileName() ;
	}

	return Extract( ui, strOutPath) ;
}
Ejemplo n.º 19
0
void ZipDlg::ListSetFolder()
{
	// 初期値取得
	string str ;
	int intCount = ListView_GetItemCount( hwndList) ;
	int i ;
	for( i = 0; i < intCount; i++)
	{
		if( ListView_GetItemState( hwndList, i, LVIS_SELECTED))
		{
			str = GetDirName( vecFileList[ i]->GetSaveName()) ;
			break ;
		}
	}

	// 編集
	DialogBoxParam( hInstance, MAKEINTRESOURCE( IDD_FOLDERNAME), m_hWnd, FileNameDlgProc, (LPARAM)&str) ;
	if( str.size() > 0 && str[ str.size() - 1] != '\\')
	{
		str += "\\" ;
	}

	intCount = ListView_GetItemCount( hwndList) ;
	BOOL blnFocus = FALSE ;
	for( i = 0; i < intCount; i++)
	{
		// 選択されていた場合
		if( ListView_GetItemState( hwndList, i, LVIS_SELECTED))
		{
			// 削除
			string s = GetFileName( vecFileList[ i]->GetSaveName()) ;
			vecFileList[ i]->SetSaveName( str + s) ;
		}
	}

	ListReload( TRUE) ;
}
Ejemplo n.º 20
0
//-----------------------------------------------------------------------------
// SetExecutableName()
//   Set the script to execute and calculate the directory in which the
// executable is found as well as the exclusive (only for this executable) and
// shared zip file names.
//-----------------------------------------------------------------------------
static int SetExecutableName(
    const char *fileName)               // script to execute
{
    char temp[MAXPATHLEN + 12], *ptr;
    const char *tempStr = NULL;
    PyObject *encodedObj;
#ifndef MS_WINDOWS
    char linkData[MAXPATHLEN + 1];
    struct stat statData;
    size_t linkSize, i;
    PyObject *dirName;
#endif

    // store file name
    g_FileName = cxString_FromString(fileName);
    if (!g_FileName)
        return FatalError("cannot create string for file name");

#ifndef MS_WINDOWS
    for (i = 0; i < 25; i++) {
        if (cxString_ToString(g_FileName, &encodedObj, &fileName) < 0)
            return -1;
        if (lstat(fileName, &statData) < 0) {
            PyErr_SetFromErrnoWithFilename(PyExc_OSError, (char*) fileName);
            return FatalError("unable to stat file");
        }
        if (!S_ISLNK(statData.st_mode))
            break;
        linkSize = readlink(fileName, linkData, sizeof(linkData));
        if (linkSize < 0) {
            PyErr_SetFromErrnoWithFilename(PyExc_OSError, (char*) fileName);
            return FatalError("unable to stat file");
        }
        Py_DECREF(encodedObj);
        if (linkData[0] == '/') {
            Py_DECREF(g_FileName);
            g_FileName = cxString_FromStringAndSize(linkData, linkSize);
        } else {
            if (cxString_ToString(g_FileName, &encodedObj, &fileName) < 0)
                return -1;
            if (GetDirName(fileName, &dirName) < 0) {
                Py_DECREF(encodedObj);
                return -1;
            }
            Py_DECREF(encodedObj);
            if (cxString_ToString(dirName, &encodedObj, &tempStr) < 0)
                return -1;
            if (strlen(tempStr) + linkSize + 1 > MAXPATHLEN) {
                Py_DECREF(dirName);
                Py_DECREF(encodedObj);
                return FatalError("cannot dereference link, path too large");
            }
            strcpy(temp, tempStr);
            Py_DECREF(encodedObj);
            strcat(temp, "/");
            strncat(temp, linkData, linkSize);
            Py_DECREF(g_FileName);
            g_FileName = cxString_FromString(temp);
        }
        if (!g_FileName)
            return FatalError("cannot create string for linked file name");
    }
#endif

    // calculate and store directory name
    if (GetDirName(fileName, &g_DirName) < 0)
        return -1;

    // calculate and store exclusive zip file name
    strcpy(temp, fileName);
    ptr = temp + strlen(temp) - 1;
    while (ptr > temp && *ptr != SEP && *ptr != '.')
        ptr--;
    if (*ptr == '.')
        *ptr = '\0';
    strcat(temp, ".zip");
    g_ExclusiveZipFileName = cxString_FromString(temp);
    if (!g_ExclusiveZipFileName)
        return FatalError("cannot create string for exclusive zip file name");

    // calculate and store shared zip file name
    if (cxString_ToString(g_DirName, &encodedObj, &tempStr) < 0)
        return -1;
    strcpy(temp, tempStr);
    Py_DECREF(encodedObj);
    ptr = temp + strlen(temp);
    *ptr++ = SEP;
    strcpy(ptr, "library.zip");
    g_SharedZipFileName = cxString_FromString(temp);
    if (!g_SharedZipFileName)
        return FatalError("cannot create string for shared zip file name");

    return 0;
}
Ejemplo n.º 21
0
string File::GetFileDir() const
{
	return GetDirName(strFilePath) ;
}
Ejemplo n.º 22
0
bool do_load_config(const char* appname, char **argv, CmdLineObj& cmdline, ConfigCollection& coll) {
	// Set GLE_TOP
	// -> prefer environment var GLE_TOP
	// -> otherwise, locate relative to executable location
	string conf_name;
	bool has_top = false;
	bool has_config = false;
	const char* top = getenv("GLE_TOP");
	vector<string> triedLocations;
	if (top == NULL || top[0] == 0) {
		string exe_name;
		bool has_exe_name = GetExeName(appname, argv, exe_name);
		if (has_exe_name) {
			GetDirName(exe_name, GLE_BIN_DIR);
			StripDirSep(GLE_BIN_DIR);
			#ifdef GLETOP_CD
				// Try relative path
				GLE_TOP_DIR = GLEAddRelPath(exe_name, GLETOP_CD+1, GLETOP_REL);
				has_config = try_load_config_sub(conf_name, triedLocations);
				// Try one level higher as executable
				if (!has_config) {
					GLE_TOP_DIR = GLEAddRelPath(exe_name, 2, NULL);
					has_config = try_load_config_sub(conf_name, triedLocations);
				}
				// Try with absolute path
				if (!has_config) {
					GLE_TOP_DIR = GLETOP_ABS;
					has_config = try_load_config_sub(conf_name, triedLocations);
				}
			#else
				GLE_TOP_DIR = exe_name;
				StripPathComponents(&GLE_TOP_DIR, 2);
			#endif
		} else {
			// The user will see as error messege: "$GLE_TOP/some_file" not found.
			GLE_TOP_DIR = "$GLE_TOP";
		}
	} else {
		has_top = true;
		GLE_TOP_DIR = top;
	}
	StripDirSep(GLE_TOP_DIR);
	if (!has_config) {
		// Try load config file
		// -> first $GLE_TOP/glerc
		if (conf_name == "") {
			// Only update conf_name if it was not yet set
			// To make error message if glerc not found more interpretable
			conf_name = GLE_TOP_DIR + DIR_SEP + "glerc";
			if (std::find(triedLocations.begin(), triedLocations.end(), conf_name) == triedLocations.end()) {
				triedLocations.push_back(conf_name);
				has_config = try_load_config(conf_name);
			}
		}
	}
	if (!check_correct_version(conf_name, has_top, has_config, triedLocations, coll)) {
		return false;
	}
	GLEInterface* iface = GLEGetInterfacePointer();
	string uconf = iface->getUserConfigLocation();
	if (uconf != "") {
		// -> on Unix also $HOME/.glerc
		try_load_config(uconf);
	}
	// Set values for -v option
	init_installed_versions(cmdline, &coll);
	return has_config;
}
Ejemplo n.º 23
0
boolean RasterCode::Definition (ostream& out) {
    boolean ok = true;

    const char* sfile;
    IRasterComp* rastercomp = GetIRasterComp();
    RasterComp* target = (RasterComp*) rastercomp->GetTarget();
    RasterRect* raster = target->GetRasterRect();

    SubclassNameVar* cnamer = rastercomp->GetCClassNameVar();
    SubclassNameVar* gnamer = rastercomp->GetGClassNameVar();
    MemberNameVar* mnamer = rastercomp->GetMemberNameVar();

    const char* mname = mnamer->GetName();
    const char* cname = cnamer->GetName();
    const char* gname = gnamer->GetName();

    if (_emitInstanceDecls || _emitGraphicState) {
	ok = ok && GraphicCodeView::Definition(out);

    } else if (_emitInstanceInits) {
        static int raster_id;

        char substName[CHARBUFSIZE];
        sfile = target->GetFileName();
        Catalog* catalog = unidraw->GetCatalog();

        if (sfile == nil) {
            sprintf(substName, "raster%d.ps", raster_id++);
            sfile = substName;
        }
        if (!catalog->Exists(sfile)) {
            char orig[CHARBUFSIZE];
            const char* name = catalog->GetName(rastercomp->GetRoot());
            char* dir = GetDirName(name);
            char* index = strrchr(sfile, '/');
            if (index == nil) {
                strcpy(orig, sfile);
            } else {
                strcpy(orig, &index[1]);
            }
            strcpy(substName, dir);
            strcat(substName, orig);
            sfile = substName;
            if (!catalog->Exists(sfile)) {
                catalog->Save(target, sfile);
            }
        }
        out << "    {\n";
        out << "        RasterComp* " << mname << "_comp = (RasterComp*) ";
        out << "ImportCmd::Import(\"" << sfile << "\");\n"; 
        out << "        Raster* " << mname << "_raster = ";
        out << mname << "_comp->GetRasterRect()->GetOriginal();\n";
        if (_emitGraphicComp) {
           out << "        " << mname << "_gr";
        } else {
            out << "        " << mname;
        }
        out << " = new " << gname << "(" << mname << "_raster, ";
        out << mname << "_comp->GetGraphic());\n";
        out << "        delete " << mname << "_comp;\n";

        ok = WriteGraphicInits(raster, out);
        if (_emitGraphicComp) {
            out << "        " << mname << " = new " << cname << "(";
            out << mname << "_gr, \"" << sfile << "\");\n";
            out << "        " << mname << "->Update();\n";
        }
        out << "    }\n";

    } else if (_emitExpHeader) {
        ok = ok && GraphicCodeView::Definition(out);

        if (strcmp(gname, _classname) == 0) {
            if (!_namelist->Search("raster")) {
                _namelist->Append("raster");
                out << "#include <InterViews/raster.h> \n";
            }
        }
    } else {
        ok = ok && GraphicCodeView::Definition(out);
    }
    return ok && out.good();
}
NS_IMETHODIMP nsAbDirProperty::GenerateName(int32_t aGenerateFormat,
                                            nsIStringBundle *aBundle,
                                            nsAString &name)
{
  return GetDirName(name);
}