Beispiel #1
0
        public PackageFileSourceInfo Add(PackageHeirarchyItem parent, string filePath)
        {
            PackageFileSourceInfo newItem = null;

            if (System.IO.File.Exists(filePath))
            {
                newItem = AddFile(parent, filePath);
            }
            else if (System.IO.Directory.Exists(filePath))
            {
                newItem = AddFolder(parent, filePath);
            }

            return(newItem);
        }
Beispiel #2
0
        private PackageFileSourceInfo AddFile(PackageHeirarchyItem parent, string filePath)
        {
            PackageFileSourceInfo newItem = null;

            var name = System.IO.Path.GetFileName(filePath);

            if (parent != null && !Contains(parent, name))
            {
                newItem        = new PackageFileSourceInfo(filePath);
                newItem.Name   = name;
                newItem.Parent = parent;

                parent.Children.Add(newItem);
            }

            return(newItem);
        }
Beispiel #3
0
        /// <summary>
        /// Adds item and its content (file or folder) to package.
        /// </summary>
        /// <param name="pPkg">Package being created.</param>
        /// <param name="item">Item to be added.</param>
        /// <returns>True is there was no error during the operation, false otherwise.</returns>
        public static bool AddItemToPackage(TraceLab.Core.PackageSystem.Package pkg, PackageFileSourceInfo item, bool isExperimentPackage)
        {
            bool noError = true;

            string targetPath = System.IO.Path.Combine(pkg.Location, item.GetPath());

            PackageHeirarchyItem dir = item as PackageHeirarchyItem;

            if (dir != null)
            {
                if (item.Parent != null)
                {
                    System.IO.Directory.CreateDirectory(targetPath);
                }

                foreach (PackageFileSourceInfo child in dir.Children)
                {
                    noError = noError && AddItemToPackage(pkg, child, isExperimentPackage);
                }

                if (dir.HasComponents)
                {
                    pkg.SetDirectoryHasComponents(dir.GetPath(), true);
                }
                if (dir.HasTypes)
                {
                    pkg.SetDirectoryHasTypes(dir.GetPath(), true);
                }
            }
            else
            {
                System.IO.File.Copy(item.SourceFilePath, targetPath);
                //Add reference to this created package to all experiments and composite components
                if (isExperimentPackage && targetPath.EndsWith(".teml") || targetPath.EndsWith(".tcml"))
                {
                    noError = noError && AddPkgRefToExperiment(pkg, targetPath);
                }
                System.IO.File.SetAttributes(targetPath, System.IO.File.GetAttributes(targetPath) & ~System.IO.FileAttributes.ReadOnly);
                pkg.AddFile(targetPath);
            }

            return(noError);
        }
Beispiel #4
0
        /// <summary>
        /// Adds item and its content (file or folder) to package.
        /// </summary>
        /// <param name="pPkg">Package being created.</param>
        /// <param name="item">Item to be added.</param>
        /// <returns>True is there was no error during the operation, false otherwise.</returns>
        public static bool AddItemToPackage(TraceLab.Core.PackageSystem.Package pkg, PackageFileSourceInfo item, bool isExperimentPackage)
        {
            bool noError = true;

            string targetPath = System.IO.Path.Combine(pkg.Location, item.GetPath());

            PackageHeirarchyItem dir = item as PackageHeirarchyItem;
            if (dir != null)
            {
                if (item.Parent != null)
                {
                    System.IO.Directory.CreateDirectory(targetPath);
                }

                foreach (PackageFileSourceInfo child in dir.Children)
                {
                    noError = noError && AddItemToPackage(pkg, child, isExperimentPackage);
                }

                if (dir.HasComponents)
                {
                    pkg.SetDirectoryHasComponents(dir.GetPath(), true);
                }
                if (dir.HasTypes)
                {
                    pkg.SetDirectoryHasTypes(dir.GetPath(), true);
                }
            }
            else
            {
                System.IO.File.Copy(item.SourceFilePath, targetPath);
                //Add reference to this created package to all experiments and composite components
                if (isExperimentPackage && targetPath.EndsWith(".teml") || targetPath.EndsWith(".tcml"))
                {
                    noError = noError && AddPkgRefToExperiment(pkg, targetPath);
                }
                System.IO.File.SetAttributes(targetPath, System.IO.File.GetAttributes(targetPath) & ~System.IO.FileAttributes.ReadOnly);
                pkg.AddFile(targetPath);
            }

            return noError;
        }
        private PackageFileSourceInfo AddFile(PackageHeirarchyItem parent, string filePath)
        {
            PackageFileSourceInfo newItem = null;

            var name = System.IO.Path.GetFileName(filePath);
            if (parent != null && !Contains(parent, name))
            {
                newItem = new PackageFileSourceInfo(filePath);
                newItem.Name = name;
                newItem.Parent = parent;

                parent.Children.Add(newItem);
            }

            return newItem;
        }
        private void AddNodeToTreeModel(PackageFileSourceInfo node, TreeIter parentNode)
        {
            parentNode = m_packageContentStore.AppendValues(parentNode, node);

            PackageHeirarchyItem hierarchyItem = node as PackageHeirarchyItem;
            if(hierarchyItem != null)
            {
                foreach (PackageFileSourceInfo childNode in hierarchyItem.Children)
                {
                    AddNodeToTreeModel(childNode, parentNode);
                }
            }
        }