StripWorkDir() public static method

Strip work dir and return normalized repository path
public static StripWorkDir ( FileSystemInfo workDir, FileSystemInfo file ) : string
workDir FileSystemInfo Work directory
file FileSystemInfo File whose path shall be stripp off it's workdir
return string
Exemplo n.º 1
0
        private byte[] MakeKey(FileSystemInfo wd, FileSystemInfo f)
        {
            if (!string.IsNullOrEmpty(f.DirectoryName()) &&
                wd.IsDirectory() && wd.Exists &&
                !f.DirectoryName().StartsWith(wd.DirectoryName()))
            {
                throw new Exception("Path is not in working dir");
            }

            string relName = Repository.StripWorkDir(wd, f);

            return(Core.Repository.GitInternalSlash(Constants.encode(relName)));
        }
Exemplo n.º 2
0
        private byte[] MakeKey(FileSystemInfo wd, FileSystemInfo f)
        {
            if (!string.IsNullOrEmpty(f.DirectoryName()) &&
                wd.IsDirectory() && wd.Exists &&
                !f.DirectoryName().StartsWith(wd.DirectoryName()))
            {
                throw new Exception("Path is not in working dir");
            }

            string relName = Repository.StripWorkDir(wd, f);

            return(FilenameEncoding.GetBytes(relName));
        }
Exemplo n.º 3
0
 private void ListFiles(FileSystemInfo dir, ICollection <string> list)
 {
     foreach (FileInfo f in dir.ListFiles())
     {
         if (f.IsDirectory())
         {
             ListFiles(f, list);
         }
         else
         {
             list.Add(Repository.StripWorkDir(_root, new FileInfo(f.FullName)));
         }
     }
 }
Exemplo n.º 4
0
        private void CheckConflictsWithFile(FileSystemInfo file)
        {
            if (file.IsDirectory())
            {
                List <string> childFiles = ListFiles(file);
                Conflicts.AddRange(childFiles);
            }
            else
            {
                FileSystemInfo parent = Directory.GetParent(file.FullName);
                if (parent == null)
                {
                    return;
                }

                while (!parent.Equals(_root))
                {
                    if (parent.IsDirectory())
                    {
                        break;
                    }

                    if (parent.IsFile())
                    {
                        Conflicts.Add(Repository.StripWorkDir(_root, parent));
                        break;
                    }

                    parent = Directory.GetParent(parent.FullName);
                    if (parent == null)
                    {
                        return;
                    }
                }
            }
        }