void JDirInfo::GoToClosest ( const JCharacter* origDirName ) { const JString dirName = JGetClosestDirectory(origDirName); const JError err = GoTo(dirName); assert_ok( err ); }
void JXPathInput::AdjustStylesBeforeRecalc ( const JString& buffer, JRunArray<Font>* styles, JIndexRange* recalcRange, JIndexRange* redrawRange, const JBoolean deletion ) { const JColormap* colormap = GetColormap(); const JSize totalLength = buffer.GetLength(); JString fullPath = buffer; if ((JIsRelativePath(buffer) && !HasBasePath()) || !JExpandHomeDirShortcut(buffer, &fullPath)) { fullPath.Clear(); } // Last clause because if JConvertToAbsolutePath() succeeds, we don't // want to further modify fullName. else if (JIsRelativePath(buffer) && !JConvertToAbsolutePath(buffer, itsBasePath, &fullPath)) { if (HasBasePath()) { fullPath = JCombinePathAndName(itsBasePath, buffer); } else { fullPath.Clear(); } } JSize errLength; if (fullPath.IsEmpty()) { errLength = totalLength; } else { const JString closestDir = JGetClosestDirectory(fullPath, itsRequireWriteFlag); if (fullPath.BeginsWith(closestDir)) { errLength = fullPath.GetLength() - closestDir.GetLength(); } else { errLength = totalLength; } } if (errLength > 0 && buffer.EndsWith(kThisDirSuffix)) { errLength++; // trailing . is trimmed } Font f = styles->GetFirstElement(); styles->RemoveAll(); if (errLength >= totalLength) { f.style.color = colormap->GetRedColor(); styles->AppendElements(f, totalLength); } else { f.style.color = colormap->GetBlackColor(); styles->AppendElements(f, totalLength - errLength); if (errLength > 0) { f.style.color = colormap->GetRedColor(); styles->AppendElements(f, errLength); } } *redrawRange += JIndexRange(1, totalLength); }