Exemple #1
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="original">
        /// The original object
        /// </param>
        /// <param name="parentDirectory">
        /// The parent directory
        /// </param>
        public ManifestDirectoryInfo(
            ManifestDirectoryInfo original,
            ManifestDirectoryInfo parentDirectory) :
            base(original.Name, parentDirectory)
        {
            Files      = new Dictionary <string, ManifestFileInfo>();
            filesStore = null;

            Subdirectories      = new Dictionary <string, ManifestDirectoryInfo>();
            subdirectoriesStore = null;

            foreach (String nextDirName in original.Subdirectories.Keys)
            {
                ManifestDirectoryInfo dirClone =
                    new ManifestDirectoryInfo(
                        original.Subdirectories[nextDirName],
                        this);

                Subdirectories.Add(nextDirName, dirClone);
            }

            foreach (String nextFileName in original.Files.Keys)
            {
                ManifestFileInfo fileClone =
                    new ManifestFileInfo(
                        original.Files[nextFileName],
                        this);

                Files.Add(nextFileName, fileClone);
            }
        }
Exemple #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">
 /// The file name
 /// </param>
 /// <param name="parentDirectory">
 /// The parent directory
 /// </param>
 public ManifestFileInfo(
     String name,
     ManifestDirectoryInfo parentDirectory) :
     base(name, parentDirectory)
 {
     FileHash = null;
 }
 /// <summary>
 /// Constructory
 /// </summary>
 /// <param name="name">
 /// Object name
 /// </param>
 /// <param name="parentDirectory">
 /// Parent directory
 /// </param>
 public ManifestObjectInfo(
     String name,
     ManifestDirectoryInfo parentDirectory)
 {
     Name            = name;
     ParentDirectory = parentDirectory;
 }
        /// <summary>
        /// Put an entry into this manifest corresponding to an entry in
        /// another manifest.  Will replace an existing entry.
        /// </summary>
        /// <param name="otherManifestFile">
        /// The other manifest file to be put into this manifest
        /// </param>
        /// <returns>
        /// The new file in this manifest
        /// </returns>
        public ManifestFileInfo PutFileFromOtherManifest(
            ManifestFileInfo otherManifestFile)
        {
            Stack <ManifestDirectoryInfo> stack =
                new Stack <ManifestDirectoryInfo>();

            ManifestDirectoryInfo nextParentOther =
                otherManifestFile.ParentDirectory;

            while (nextParentOther != null)
            {
                stack.Push(nextParentOther);
                nextParentOther = nextParentOther.ParentDirectory;
            }

            // Start in root directory
            ManifestDirectoryInfo currentParentThis = RootDirectory;

            // Pop the root directory since we're starting there
            stack.Pop();

            while (stack.Count > 0)
            {
                nextParentOther = stack.Pop();

                if (currentParentThis.Subdirectories.Keys.Contains(
                        nextParentOther.Name))
                {
                    currentParentThis = currentParentThis.Subdirectories[
                        nextParentOther.Name];
                }
                else
                {
                    ManifestDirectoryInfo newParent =
                        new ManifestDirectoryInfo(
                            nextParentOther.Name,
                            currentParentThis);

                    currentParentThis.Subdirectories[nextParentOther.Name] =
                        newParent;

                    currentParentThis = newParent;
                }
            }

            ManifestFileInfo newManifestFile =
                new ManifestFileInfo(
                    otherManifestFile,
                    currentParentThis);

            currentParentThis.Files[newManifestFile.Name] =
                newManifestFile;

            return(newManifestFile);
        }
Exemple #5
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="original">
        /// The original object
        /// </param>
        /// <param name="parentDirectory">
        /// The parent directory
        /// </param>
        public ManifestFileInfo(
            ManifestFileInfo original,
            ManifestDirectoryInfo parentDirectory) :
            base(original.Name, parentDirectory)
        {
            FileLength      = original.FileLength;
            LastModifiedUtc = original.LastModifiedUtc;
            RegisteredUtc   = original.RegisteredUtc;

            FileHash = original.FileHash;
        }
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="original">
        /// The original object
        /// </param>
        public Manifest(Manifest original)
        {
            Guid              = original.Guid;
            InceptionDateUtc  = original.InceptionDateUtc;
            LastUpdateDateUtc = original.LastUpdateDateUtc;

            RootDirectory = new ManifestDirectoryInfo(
                original.RootDirectory, null);

            CopyManifestInfoFrom(original);
        }
        /// <summary>
        /// Make a standard UNIX-style relative path, which will not vary
        /// across platforms.
        /// </summary>
        /// <param name="directoryInfo">
        /// The directory whose path will be generated
        /// </param>
        /// <returns>
        /// The path
        /// </returns>
        public static String MakeStandardPathString(ManifestDirectoryInfo directoryInfo)
        {
            String pathString = directoryInfo.Name + StandardPathDelimiterString;

            if (directoryInfo.ParentDirectory != null)
            {
                pathString = MakeStandardPathString(directoryInfo.ParentDirectory) + pathString;
            }

            return(pathString);
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public Manifest()
        {
            Guid             = Guid.NewGuid();
            RootDirectory    = new ManifestDirectoryInfo(".", null);
            IgnoreList       = new List <string>();
            InceptionDateUtc = DateTime.UtcNow;

            // TBD: Might consider actually setting this to something
            DefaultHashMethod = null;
            UseJSON           = true;
        }
Exemple #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">
        /// The name of this directory
        /// </param>
        /// <param name="parentDirectory">
        /// The parent directory
        /// </param>
        public ManifestDirectoryInfo(
            String name,
            ManifestDirectoryInfo parentDirectory) :
            base(name, parentDirectory)
        {
            Files      = new Dictionary <string, ManifestFileInfo>();
            filesStore = null;

            Subdirectories      = new Dictionary <string, ManifestDirectoryInfo>();
            subdirectoriesStore = null;
        }
        /// <summary>
        /// Recursive helper function to count the files
        /// </summary>
        /// <param name="currentDir">
        /// Current directory in the recursion
        /// </param>
        /// <returns>
        /// Number of files below the current directory
        /// </returns>
        protected Int64 CountFilesRecursive(ManifestDirectoryInfo currentDir)
        {
            Int64 fileCount = currentDir.Files.Count;

            foreach (ManifestDirectoryInfo nextDirInfo in
                     currentDir.Subdirectories.Values)
            {
                fileCount += CountFilesRecursive(nextDirInfo);
            }

            return(fileCount);
        }
        /// <summary>
        /// Make a platform-specific relative path
        /// </summary>
        /// <param name="directoryInfo">
        /// The directory whose path will be generated
        /// </param>
        /// <returns>
        /// The path
        /// </returns>
        public static String MakeNativePathString(ManifestDirectoryInfo directoryInfo)
        {
            String pathString = directoryInfo.Name;

            if (directoryInfo.ParentDirectory != null)
            {
                pathString = Path.Combine(
                    MakeNativePathString(directoryInfo.ParentDirectory),
                    pathString).Normalize();
            }

            return(pathString);
        }
        /// <summary>
        /// Recursive helper to count the number of bytes
        /// </summary>
        /// <param name="currentDir">
        /// Current directory in the recursion
        /// </param>
        /// <returns>
        /// The number of bytes stored in the current directory
        /// </returns>
        protected Int64 CountBytesRecursive(ManifestDirectoryInfo currentDir)
        {
            Int64 byteCount = 0;

            foreach (ManifestFileInfo nextFileInfo in
                     currentDir.Files.Values)
            {
                byteCount += nextFileInfo.FileLength;
            }

            foreach (ManifestDirectoryInfo nextDirInfo in
                     currentDir.Subdirectories.Values)
            {
                byteCount += CountBytesRecursive(nextDirInfo);
            }

            return(byteCount);
        }