Bool CSVNodeData::UpdateCSVTable(GvNode* node, GvRun* run, GvCalc* calc) {
    BaseDocument* doc = node->GetDocument();
    if (m_initCsv) return TRUE;

    // Obtain data to update the CSV Table. If *all* of those
    // succeeded, the CSV table is updated.
    GvPortCalc pCalc(node, &m_values, run, calc);
    Bool header;
    LONG delimiter;
    Filename filename;

    GvPort* pHeader = pCalc.GetInPort(CSVNODE_HEADER);
    if (pHeader && pHeader->GetBool(&header, run)) ;
    else return TRUE;

    GvPort* pDelimiter = pCalc.GetInPort(CSVNODE_DELIMITER);
    if (pDelimiter && pDelimiter->GetInteger(&delimiter, run)) ;
    else return TRUE;

    Bool ok = FALSE;
    GvPort* pFilename = pCalc.GetInPort(CSVNODE_FILENAME);
    filename = GvGetPortGeData(node, pFilename, run, &ok).GetFilename();
    if (!ok) return TRUE;

    // We now initialize the CSV Table and want to prevent any
    // further initialization in the calculation cycle.
    m_initCsv = TRUE;

    // Validate and set the data to the CSV Table object.
    if (m_pHeader != header) {
        m_forceUpdate = TRUE;
    }
    m_pHeader = header;
    m_table.SetHasHeader(header);

    if (delimiter < 0 || delimiter > 255) {
        delimiter = CSVNODE_DELIMITER_COMMA;
    }
    if (m_pDelimiter != delimiter) {
        m_forceUpdate = TRUE;
    }
    m_pDelimiter = delimiter;
    m_table.SetDelimiter((CHAR) delimiter);

    // Make the CSV Filename relative to the node's document if the file
    // does not exist.
    if (doc && filename.Content() && !GeFExist(filename)) {
        filename = doc->GetDocumentPath() + filename;
    }

    // Update the CSV Table.
    Bool updated = FALSE;
    Bool success = m_table.Init(filename, m_forceUpdate, &updated);
    m_forceUpdate = FALSE;

    return success;
}
Ejemplo n.º 2
0
Bool AssertPathExists(const Filename &fn)
{
	if (GeFExist(fn, true))
		return true;

	CFilenameArray pfnDir;
	Filename fnDir = fn;
	Bool bRet = false;
	Int32 a;
	Filename** ppfn;

	while (!GeFExist(fnDir, true))
	{
		Filename* pfn = pfnDir.InsertAt(0);
		if (!pfn)
			goto _error;
		*pfn = fnDir.GetFile();
		fnDir = fnDir.GetDirectory();
		if (!fnDir.Content())
		{
			return false;
		}
	}

	ppfn = pfnDir.GetArray()->GetArray();
	for (a = 0; a < pfnDir.GetElementCount(); a++)
	{
		fnDir += fnDir + *(ppfn[a]);
		if (GeFExist(fnDir, true))
			continue;
		if (!GeFCreateDir(fnDir))
			goto _error;
	}

	bRet = true;
_error:
	return bRet;
}
Ejemplo n.º 3
0
Bool DiffDistriDialog::Command(Int32 id, const BaseContainer &msg)
{
	switch (id)
	{
	case IDC_DIFF_DISTRI_NEW_BTN:
		{
			Filename fn;
			if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, GeLoadString(IDS_DIFF_DISTRI_CHOOSE)))
			{
				if (!fn.CheckSuffix("zip"))
				{
					GeOutString(GeLoadString(IDS_DIFF_DISTRI_INVALID_SUFFIX), GEMB_OK | GEMB_ICONSTOP);
				}
				else
				{
					g_pResEditPrefs->arOldFiles.AddFilename(fn);
					m_pTreeView->Refresh();
				}
			}
		}
		break;

	case IDC_DIFF_DISTRI_REMOVE_BTN:
		if (m_fnSelection.Content())
		{
			g_pResEditPrefs->arOldFiles.RemoveFilename(m_fnSelection);
			m_fnSelection = Filename();
			m_pTreeView->Refresh();
		}
		break;

	case IDC_DIFF_DISTRI_NEWZIP_EDIT:
		g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename();
		break;

	case IDC_DIFF_DISTRI_DESTPATH_EDIT:
		{
			Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename();
			g_pResEditPrefs->fnDestZip = fnDestZip;
			g_pResEditPrefs->fnDestZip.SetSuffix("zip");
			if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip)
				m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip));
		}
		break;

	case IDC_OK:
		{
			GeData d;
			String strPassword;
			Int32 lLen = 0;
			char* pchPassword = nullptr;

			Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename();
			g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename();
			g_pResEditPrefs->fnDestZip = fnDestZip;
			g_pResEditPrefs->fnDestZip.SetSuffix("zip");
			if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip)
				m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip));
			GetString(IDC_DIFF_DISTRI_PASSWORD_EDIT, strPassword);

			lLen = strPassword.GetCStringLen(STRINGENCODING_8BIT);
			if (lLen)
			{
				pchPassword = NewMemClear(Char,lLen + 2);
				if (pchPassword)
					strPassword.GetCString(pchPassword, lLen + 1, STRINGENCODING_8BIT);
			}

			if (!g_pResEditPrefs->arOldFiles.GetElementCount())
			{
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_OLD), GEMB_ICONSTOP);
				DeleteMem(pchPassword);
				break;
			}
			if (!g_pResEditPrefs->fnNewZip.Content())
			{
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_NEW), GEMB_ICONSTOP);
				DeleteMem(pchPassword);
				break;
			}
			if (!g_pResEditPrefs->fnDestZip.Content())
			{
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_DEST), GEMB_ICONSTOP);
				DeleteMem(pchPassword);
				break;
			}

			if (!DiffZipFiles(g_pResEditPrefs->arOldFiles, g_pResEditPrefs->fnNewZip, g_pResEditPrefs->fnDestZip, pchPassword))
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_FAILED, g_pResEditPrefs->fnNewZip.GetString(), g_pResEditPrefs->fnDestZip.GetString()), GEMB_OK | GEMB_ICONEXCLAMATION);
			DeleteMem(pchPassword);
		}
		break;

	case IDC_CANCEL:
		Close();
		break;

	default:
		break;
	}

	return true;
}
Ejemplo n.º 4
0
/*********************************************************************\
	Function name    : CResEditBrowser::Command
	Description      :
	Created at       : 25.09.01, @ 22:33:39
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CResEditBrowser::Command(Int32 lID, const BaseContainer &msg)
{
	switch (lID)
	{
	case IDC_BROWSE_BUTTON: {
		Filename fn = m_strPath;
		AutoAlloc <BrowseFiles> pFiles;
		pFiles->Init(Filename("\\"), false);
		if (!m_strPath.Content())
			fn = GeGetStartupPath() + String("resource");
		if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, GeLoadString(IDS_SPECIFY_RES_PATH)))
		{
			m_strPath = fn;
			FillList();
		}
		break;
	}
	case IDC_DIRECTORY_TREE: {
		TreeViewItem* pSelItem = (TreeViewItem*)msg.GetVoid(TREEVIEW_MESSAGE_ITEM);
		Int32 lType = msg.GetInt32(TREEVIEW_MESSAGE_TYPE);
		if (!pSelItem) break;

		if (lType == TREEVIEW_DOUBLECLICK)
		{
			Filename fn = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
			if (fn.CheckSuffix("res"))
			{
				// open the resource file
				if (!g_bWasActive)
				{ CResEditMenu m; m.Execute(nullptr); }
				if (!g_pTreeDialog) break;
				g_pTreeDialog->OpenDialog(fn);
			}
			else if (fn.CheckSuffix("str"))
			{
				CDialogDoc tempDoc;
				tempDoc.LoadGlobalStringTable(m_strPath, pSelItem->GetData()->GetString(TREEVIEW_TEXT));
				CStringtableDialog dlg(&tempDoc, true);
				if (dlg.Open())
				{
					if (GeOutString(GeLoadString(IDS_SAVE_STRINGTABLE), GEMB_YESNO | GEMB_ICONQUESTION) == GEMB_R_YES)
					{
						tempDoc.SaveGlobalStringTable();
					}
				}
			}
			else if (fn.Content())
			{
				// open the file (it may be an image)
				GeExecuteFile(fn);
			}
			return true;
		}
		else if (lType == TREEVIEW_SELCHANGE)
		{
			m_dirText = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
		}

		break;
	}
	};
	return GeDialog::Command(lID, msg);
}
Ejemplo n.º 5
0
void AddFilename(Filename &fn, const Filename fnDest)
{
	if (!fnDest.Content())
		return;
	AddFilename1(fn, fnDest.GetDirectory(), fnDest.GetFile());
}
Ejemplo n.º 6
0
void AddFilename1(Filename &fn, const Filename fnDir, const Filename fnFile)
{
	if (fnDir.Content())
		AddFilename1(fn, fnDir.GetDirectory(), fnDir.GetFile());
	fn += fnFile;
}