Esempio n. 1
0
JBoolean
CMLink::FindFile
	(
	const JCharacter*	fileName,
	JBoolean*			exists,
	JString*			fullName
	)
	const
{
	const JString* s = NULL;
	if (JIsAbsolutePath(fileName) && JFileExists(fileName))
		{
		*exists   = kJTrue;
		*fullName = fileName;
		return kJTrue;
		}
	else if (itsFileNameMap->GetElement(fileName, &s))
		{
		if (s == NULL)
			{
			*exists = kJFalse;
			fullName->Clear();
			}
		else
			{
			*exists   = kJTrue;
			*fullName = *s;
			}
		return kJTrue;
		}
	else
		{
		*exists = kJFalse;
		fullName->Clear();
		return kJFalse;
		}

/*	All search paths are unreliable.  See CMGetFullPath.cc for more info.

	if (JIsRelativePath(fileName))
		{
		const JSize count = itsPathList->GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			*fullName = JCombinePathAndName(*(itsPathList->NthElement(i)), fileName);
			if (JFileExists(*fullName))
				{
				return kJTrue;
				}
			}
		}
	else if (JFileExists(fileName))
		{
		*fullName = fileName;
		return kJTrue;
		}

	fullName->Clear();
	return kJFalse; */
}
Esempio n. 2
0
JBoolean
CMBreakpointManager::GetBreakpoints
	(
	const JCharacter*			fileName,
	JPtrArray<CMBreakpoint>*	list
	)
	const
{
	list->RemoveAll();
	list->SetCleanUpAction(JPtrArrayT::kForgetAll);

	if (JIsAbsolutePath(fileName) && JFileExists(fileName))
		{
		CMBreakpoint target(fileName, 1);
		JBoolean found;
		const JIndex startIndex =
			itsBPList->SearchSorted1(&target, JOrderedSetT::kFirstMatch, &found);

		const JSize count = itsBPList->GetElementCount();
		for (JIndex i=startIndex; i<=count; i++)
			{
			CMBreakpoint* bp = itsBPList->NthElement(i);
			if (bp->GetFileID() == target.GetFileID())
				{
				list->Append(bp);
				}
			else
				{
				break;
				}
			}
		}

	return !list->IsEmpty();
}
JColorIndex
JXPathInput::GetTextColor
	(
	const JCharacter*	path,
	const JCharacter*	base,
	const JBoolean		requireWrite,
	const JColormap*	colormap
	)
{
	if (JStringEmpty(path))
		{
		return colormap->GetBlackColor();
		}

	JString fullPath;
	if ((JIsAbsolutePath(path) || !JStringEmpty(base)) &&
		JConvertToAbsolutePath(path, base, &fullPath) &&
		JDirectoryReadable(fullPath) &&
		JCanEnterDirectory(fullPath) &&
		(!requireWrite || JDirectoryWritable(fullPath)))
		{
		return colormap->GetBlackColor();
		}
	else
		{
		return colormap->GetRedColor();
		}
}
CBCommand::CBCommand
	(
	const JString&		path,
	const JBoolean		refreshVCSStatusWhenFinished,
	const JBoolean		beepWhenFinished,
	CBProjectDocument*	projDoc
	)
	:
	itsProjDoc(projDoc),
	itsCmdPath(path),
	itsOutputDoc(NULL),
	itsBeepFlag(beepWhenFinished),
	itsRefreshVCSStatusFlag(refreshVCSStatusWhenFinished),
	itsUpdateSymbolDatabaseFlag(kJFalse),
	itsInQueueFlag(kJFalse),
	itsSuccessFlag(kJTrue),
	itsCancelledFlag(kJFalse),
	itsMakeDependCmd(NULL),
	itsBuildOutputDoc(NULL),
	itsRunOutputDoc(NULL),
	itsParent(NULL),
	itsCallParentProcessFinishedFlag(kJTrue)
{
	assert( JIsAbsolutePath(path) );

	itsCmdList = jnew JArray<CmdInfo>;
	assert( itsCmdList != NULL );

	if (itsProjDoc != NULL)
		{
		ClearWhenGoingAway(itsProjDoc, &itsProjDoc);
		}
}
JBoolean
JXPathInput::GetPath
	(
	JString* path
	)
	const
{
	const JString& text = GetText();
	return JI2B(!text.IsEmpty() &&
				(JIsAbsolutePath(text) || HasBasePath()) &&
				JConvertToAbsolutePath(text, itsBasePath, path) &&
				JDirectoryExists(*path) &&
				JDirectoryReadable(*path) &&
				JCanEnterDirectory(*path) &&
				(!itsRequireWriteFlag || JDirectoryWritable(*path)));
}
void
JXPathInput::SetBasePath
	(
	const JCharacter* path
	)
{
	if (JStringEmpty(path))
		{
		ClearBasePath();
		}
	else
		{
		assert( JIsAbsolutePath(path) );
		itsBasePath = path;
		RecalcAll(kJTrue);
		}
}
void
CBExecOutputDocument::ConvertSelectionToFullPath
	(
	JString* fileName
	)
	const
{
	if (JIsAbsolutePath(*fileName))
		{
		return;
		}

	const JString testName = JCombinePathAndName(itsPath, *fileName);
	if (JFileExists(testName))
		{
		*fileName = testName;
		}
	else
		{
		CBTextDocument::ConvertSelectionToFullPath(fileName);
		}
}
void
CBCompileDocument::ConvertSelectionToFullPath
	(
	JString* fileName
	)
	const
{
	(CBGetDocumentManager())->SetActiveListDocument(const_cast<CBCompileDocument*>(this));

	if (JIsAbsolutePath(*fileName))
		{
		return;
		}

	CBTextEditor* te       = GetTextEditor();
	const JString& text    = te->GetText();
	const JIndex caretChar = te->GetInsertionIndex();

	JArray<JIndexRange> matchList;
	JStack<JIndex, JArray<JIndex> > dirStack;

	JIndex i=1;
	while (dirMarkerPattern.MatchFrom(text, i, &matchList))
		{
		i = (matchList.GetElement(1)).last + 1;
		if (i >= caretChar)
			{
			break;
			}

		if (!(matchList.GetElement(3)).IsEmpty())					// Entering
			{
			dirStack.Push(i);
			}
		else														// Leaving
			{
			assert( !(matchList.GetElement(4)).IsEmpty() );
			JIndex j;
			dirStack.Pop(&j);
			}
		}

	JIndex startChar;
	if (dirStack.Peek(&startChar))
		{
		JIndex endChar = startChar;
		if (text.GetCharacter(endChar) != '\'' &&
			text.LocateNextSubstring("\'", &endChar))
			{
			endChar--;
			JString testName = text.GetSubstring(startChar, endChar);
			testName         = JCombinePathAndName(testName, *fileName);
			if (JFileExists(testName))
				{
				*fileName = testName;
				return;
				}
			}
		}

	CBExecOutputDocument::ConvertSelectionToFullPath(fileName);
}