src/SyncTool.Git/main/FileSystem/DirectoryHelper.cs
/// <summary>
/// Gets the specified directory or creates it
/// </summary>
/// <remarks>Assumes that all <see cref="IDirectory"/> objects are instances of <see cref="Directory"/> </remarks>        
/// <remarks>       
/// This is intentionally not an extension method to prevent it from showing up in auto-completion, because this is not a general purpose method
/// (makes assumption about the directory object that will not always be true)
/// </remarks>
Gets the specified directory or creates it
Gets the specified directory or creates it
internal static Directory GetOrAddDirectory(Directory parent, string relativePath)
        {
            if (relativePath == "")
            {
                return parent;
            }
            if (parent.DirectoryExists(relativePath))
            {
                return (Directory)parent.GetDirectory(relativePath);
            }
            else
            {
                var name = PathParser.GetFileName(relativePath);
                var directParent = GetOrAddDirectory(parent, PathParser.GetDirectoryName(relativePath));
                return (Directory)directParent.Add(d => new Directory(d, name));
            }
        }
internal static Directory GetOrAddDirectory ( Directory parent , string relativePath ) { if ( relativePath == " " ) { return parent ; } if ( parent . DirectoryExists ( relativePath ) ) { return ( Directory ) parent . GetDirectory ( relativePath ) ; } else { var name = PathParser . GetFileName ( relativePath ) ; var directParent = GetOrAddDirectory ( parent , PathParser . GetDirectoryName ( relativePath ) ) ; return ( Directory ) directParent . Add ( d => new Directory ( d , name ) ) ; } }
Gets the specified directory or creates it
Gets the specified directory or creates it
parent
Directory
relativePath
string
remarks
Assumes that all
objects are instances of
Assumes that all objects are instances of
remarks
This is intentionally not an extension method to prevent it from showing up in auto-completion, because this is not a general purpose method
(makes assumption about the directory object that will not always be true)
This is intentionally not an extension method to prevent it from showing up in auto - completion because this is not a general purpose method ( makes assumption about the directory object that will not always be true )