public static bool DivideLocationOneStep(string location, out string newLocation, out string newElem)
{
newLocation = location;
newElem = null;
int slashIdx = location.LastIndexOf('/');
if (slashIdx < 0) // no slashes found
{
if (IsLocationAllGeneric(location))
{
return false;
}
else
{
newElem = location;
newLocation = ".";
return true;
}
}
else // some slashes found
{
string preSlash = location.Substring(0, slashIdx);
string postSlash = location.Substring(slashIdx + 1);
if (IsLocationAllGeneric(postSlash))
{
return false;
}
else
{
newLocation = preSlash;
newElem = postSlash;
return true;
}
}
}