void
JXFSBindingManager::SaveBinding
(
    const JCharacter*				fileName,
    const JCharacter*				cmd,
    const JFSBinding::CommandType	type,
    const JBoolean					singleFile
)
{
    JString root, suffix;
    if (JSplitRootAndSuffix(fileName, &root, &suffix))
    {
        JFSBindingList::CleanFileName(&suffix);		// ignore # and ~ on end
        suffix.PrependCharacter('.');

        itsBindingList->RevertIfModified();			// make sure we Save() latest
        itsBindingList->SetCommand(suffix, cmd, type, singleFile);
        itsBindingList->Save();						// ignore error:  no point in complaining

        if (itsEditDialog != NULL)
        {
            itsEditDialog->AddBinding(suffix, cmd, type, singleFile);
        }
    }
}
void
GMMIMEParser::AdjustAttachmentName
	(
	const GMIMEHeader&	header,
	JString*			name
	)
{
	JString root, suffix;
	if (!JSplitRootAndSuffix(*name, &root, &suffix))
		{
		suffix = header.GetSubType();
		*name = JCombineRootAndSuffix(root, suffix);
		}
}
void
SyGDuplicateProcess::ProcessNextFile()
{
	if (itsFullNameList.IsEmpty())
		{
		JXDeleteObjectTask<JBroadcaster>::Delete(this);
		return;
		}

	const JString* origName = itsFullNameList.FirstElement();
	JString path, name, root, suffix;
	JSplitPathAndName(*origName, &path, &name);
	if (JSplitRootAndSuffix(name, &root, &suffix))
		{
		suffix.PrependCharacter('.');
		}

	root += "_copy";
	name  = JGetUniqueDirEntryName(path, root, suffix);

	JSplitPathAndName(name, &path, &itsCurrentName);

	const JCharacter* argv[] = { "cp", "-Rdf", *origName, name, NULL };

	JVCSType type;
	if (JIsManagedByVCS(*origName, &type) && type == kJSVNType)
		{
		argv[0] = "svn";
		argv[1] = "cp";
		}

	const JError err = JSimpleProcess::Create(&itsProcess, argv, sizeof(argv));
	err.ReportIfError();
	itsFullNameList.DeleteElement(1);		// before ProcessNextFile()

	if (err.OK())
		{
		ListenTo(itsProcess);
		JThisProcess::Ignore(itsProcess);	// detach so it always finishes
		}
	else
		{
		itsProcess = NULL;
		itsNodeList.RemoveElement(1);
		ProcessNextFile();
		}
}
Esempio n. 4
0
void
JXSaveFileInput::HandleFocusEvent()
{
	JXInputField::HandleFocusEvent();

	JString root, suffix;
	if (JSplitRootAndSuffix(GetText(), &root, &suffix))
		{
		if (root.IsEmpty())
			{
			SetCaretLocation(1);
			}
		else
			{
			SetSelection(1, root.GetLength());
			}
		}
}
Esempio n. 5
0
void
XDLink::SetProgram
	(
	const JCharacter* fileName
	)
{
	Send("detach");

//	StopDebugger();		// avoid broadcasting DebuggerRestarted
//	StartDebugger();

	itsProgramConfigFileName.Clear();
	itsSourcePathList->DeleteAll();

	JString fullName;
	if (!JConvertToAbsolutePath(fileName, NULL, &fullName) ||
		!JFileReadable(fullName))
		{
		const JString error = JGetString("ConfigFileUnreadable::XDLink");
		Broadcast(UserOutput(error, kJTrue));
		return;
		}
	else if (CMMDIServer::IsBinary(fullName))
		{
		const JString error = JGetString("ConfigFileIsBinary::XDLink");
		Broadcast(UserOutput(error, kJTrue));
		return;
		}

	JString line;
	if (!CMMDIServer::GetLanguage(fullName, &line) ||
		JStringCompare(line, "php", kJFalse) != 0)
		{
		const JString error = JGetString("ConfigFileWrongLanguage::XDLink");
		Broadcast(UserOutput(error, kJTrue));
		return;
		}

	JString path, name, suffix;
	JSplitPathAndName(fullName, &path, &name);
	JSplitRootAndSuffix(name, &itsProgramName, &suffix);

	itsProgramConfigFileName = fullName;

	ifstream input(fullName);
	while (1)
		{
		line = JReadLine(input);
		line.TrimWhitespace();

		if (line.BeginsWith("source-path:"))
			{
			line.RemoveSubstring(1, 12);
			line.TrimWhitespace();

			name = JCombinePathAndName(path, line);
			itsSourcePathList->Append(name);
			}
		else if (!line.IsEmpty() && !line.BeginsWith("code-medic:"))
			{
			line.Prepend("Unknown option: ");
			line.AppendCharacter('\n');
			Broadcast(UserOutput(line, kJTrue));
			}

		if (!input.good())
			{
			break;
			}
		}

	XDSetProgramTask* task = new XDSetProgramTask();
	assert( task != NULL );
	task->Go();
}
JBoolean
CBNewProjectSaveFileDialog::OKToDeactivate()
{
	if (!JXSaveFileDialog::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	const CBBuildManager::MakefileMethod method = GetMakefileMethod();
	if (method == CBBuildManager::kManual)
		{
		return kJTrue;
		}

	// ask if OK to replace Make.files

	if (method == CBBuildManager::kMakemake)
		{
		const JString makeFilesName = CBBuildManager::GetMakeFilesName(GetPath());
		if (JFileExists(makeFilesName) &&
			!OKToReplaceFile(makeFilesName, JGetString("CBName")))
			{
			return kJFalse;
			}
		}

	// ask if OK to replace CMakeLists.txt

	if (method == CBBuildManager::kCMake)
		{
		JString projFileName, projRoot, projSuffix;
		GetFileName(&projFileName);
		JSplitRootAndSuffix(projFileName, &projRoot, &projSuffix);

		const JString cmakeInputName = CBBuildManager::GetCMakeInputName(GetPath(), projRoot);
		if (JFileExists(cmakeInputName) &&
			!OKToReplaceFile(cmakeInputName, JGetString("CBName")))
			{
			return kJFalse;
			}
		}

	// ask if OK to replace .pro

	if (method == CBBuildManager::kQMake)
		{
		JString projFileName, projRoot, projSuffix;
		GetFileName(&projFileName);
		JSplitRootAndSuffix(projFileName, &projRoot, &projSuffix);

		const JString qmakeInputName = CBBuildManager::GetQMakeInputName(GetPath(), projRoot);
		if (JFileExists(qmakeInputName) &&
			!OKToReplaceFile(qmakeInputName, JGetString("CBName")))
			{
			return kJFalse;
			}
		}

	// ask if OK to replace existing Makefile

	JPtrArray<JString> makefileList(JPtrArrayT::kDeleteAll);
	CBBuildManager::GetMakefileNames(GetPath(), &makefileList);

	const JSize count = makefileList.GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JString* fullName = makefileList.NthElement(i);
		if (JFileExists(*fullName) &&
			!OKToReplaceFile(*fullName, CBBuildManager::GetMakefileMethodName(GetMakefileMethod())))
			{
			return kJFalse;
			}
		}

	return kJTrue;
}