コード例 #1
0
void CParsedPath::ParsePath(const UString &path)
{
    int curPos = 0;
    switch (NPathType::GetPathType(path))
    {
    case NPathType::kLocal:
    {
        int posDiskDelimiter = path.Find(kDiskDelimiter);
        if(posDiskDelimiter >= 0)
        {
            curPos = posDiskDelimiter + 1;
            if (path.Length() > curPos)
                if(path[curPos] == kDirDelimiter)
                    curPos++;
        }
        break;
    }
    case NPathType::kUNC:
    {
        int curPos = path.Find(kDirDelimiter, 2);
        if(curPos < 0)
            curPos = path.Length();
        else
            curPos++;
    }
    }
    Prefix = path.Left(curPos);
    SplitPathToParts(path.Mid(curPos), PathParts);
}
コード例 #2
0
ファイル: Wildcard.cpp プロジェクト: OPSF/uClinux
void CCensorNode::AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir)
{
  CItem item;
  SplitPathToParts(path, item.PathParts);
  item.Recursive = recursive;
  item.ForFile = forFile;
  item.ForDir = forDir;
  AddItem(include, item);
}
コード例 #3
0
ファイル: Wildcard.cpp プロジェクト: OPSF/uClinux
void CCensor::AddItem(bool include, const UString &path, bool recursive)
{
  UStringVector pathParts;
  SplitPathToParts(path, pathParts);
  bool forFile = true;
  if (pathParts.Back().IsEmpty())
  {
    forFile = false;
    pathParts.DeleteBack();
  }
  const UString &front = pathParts.Front();
  bool isAbs = false;
  if (front.IsEmpty())
    isAbs = true;
  else if (front.Length() == 2 && front[1] == L':')
    isAbs = true;
  else
  {
    for (int i = 0; i < pathParts.Size(); i++)
    {
      const UString &part = pathParts[i];
      if (part == L".." || part == L".")
      {
        isAbs = true;
        break;
      }
    }
  }
  int numAbsParts = 0;
  if (isAbs)
    if (pathParts.Size() > 1)
      numAbsParts = pathParts.Size() - 1;
    else
      numAbsParts = 1;
  UString prefix;
  for (int i = 0; i < numAbsParts; i++)
  {
    const UString &front = pathParts.Front();
    if (DoesNameContainWildCard(front))
      break;
    prefix += front;
    prefix += WCHAR_PATH_SEPARATOR;
    pathParts.Delete(0);
  }
  int index = FindPrefix(prefix);
  if (index < 0)
    index = Pairs.Add(CPair(prefix));

  CItem item;
  item.PathParts = pathParts;
  item.ForDir = true;
  item.ForFile = forFile;
  item.Recursive = recursive;
  Pairs[index].Head.AddItem(include, item);
}
コード例 #4
0
UString GetCorrectFullFsPath(const UString &path)
{
  UStringVector parts;
  SplitPathToParts(path, parts);
  for (int i = 0; i < parts.Size(); i++)
  {
    UString &s = parts[i];
    #ifdef _WIN32
    while (!s.IsEmpty() && s[s.Length() - 1] == '.')
      s.Delete(s.Length() - 1);
    if (!IsSupportedName(s))
      s = (UString)L"_" + s;
    #endif
  }
  return MakePathNameFromParts(parts);
}
コード例 #5
0
ファイル: Wildcard.cpp プロジェクト: OPSF/uClinux
bool CCensorNode::CheckPath(const UString &path, bool isFile, bool &include) const
{
  UStringVector pathParts; 
  SplitPathToParts(path, pathParts);
  return CheckPath(pathParts, isFile, include);
}