Ejemplo n.º 1
0
        /// <summary>
        /// Gets the file information for a path below the <see cref="Root"/>.
        /// Never return null: <see cref="NotFoundFileInfo"/> is returned when the file does not exist.
        /// </summary>
        /// <param name="subpath">The subordinated path.</param>
        /// <returns>The file info.</returns>
        public IFileInfo GetFileInfo(NormalizedPath sub)
        {
            sub = sub.ResolveDots().With(NormalizedPathRootKind.None);
            GitFolder g = GitFolders.FirstOrDefault(f => sub.StartsWith(f.SubPath, strict: false));

            return(g != null
                        ? g.GetFileInfo(sub.RemovePrefix(g.SubPath)) ?? new NotFoundFileInfo(sub.Path)
                        : PhysicalGetFileInfo(sub));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the directory content for a path below the <see cref="Root"/>.
        /// </summary>
        /// <param name="subpath">The subordinated path.</param>
        /// <returns>The directory content.</returns>
        public IDirectoryContents GetDirectoryContents(NormalizedPath sub)
        {
            sub = sub.ResolveDots().With(NormalizedPathRootKind.None);
            GitFolder g = GitFolders.FirstOrDefault(f => sub.StartsWith(f.SubPath, strict: false));

            return(g != null
                        ? g.GetDirectoryContents(sub.RemovePrefix(g.SubPath)) ?? NotFoundDirectoryContents.Singleton
                        : PhysicalGetDirectoryContents(sub));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ensures that the Git folder is loaded.
        /// The <see cref="ProtoGitFolder"/> must have been created first.
        /// </summary>
        /// <param name="folderPath">
        /// The folder path is a sub path of <see cref="Root"/> and contains the .git sub folder.
        /// </param>
        /// <returns>The <see cref="GitFolder"/> or null on error.</returns>
        public GitFolder EnsureGitFolder(IActivityMonitor m, ProtoGitFolder proto)
        {
            if (proto == null)
            {
                throw new ArgumentNullException(nameof(proto));
            }
            if (proto.FileSystem != this)
            {
                throw new ArgumentException("FileSystem mismatch.", nameof(proto));
            }
            GitFolder g = GitFolders.FirstOrDefault(f => f.ProtoGitFolder == proto);

            if (g == null)
            {
                g = proto.CreateGitFolder(m);
                // TODO: this SHOULD be done in ProtoGitFolder.EnsureWorkingFolder!
                if (g != null)
                {
                    _gits.Add(g);
                }
            }
            return(g);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Tries to find the <see cref="GitFolder"/> for a path below the <see cref="Root"/>.
 /// </summary>
 /// <param name="subPath">The path (<see cref="Root"/> based). Can be any path inside the Git folder.</param>
 /// <returns>The Git folder or null if not found.</returns>
 public GitFolder FindGitFolder(NormalizedPath subPath) => GitFolders.FirstOrDefault(f => subPath.StartsWith(f.SubPath, strict: false));