Example #1
0
        private bool TryToTransformSingleFileSource(SingleFileSource source, FilesList filesList)
        {
            if (!transformations.ContainsKey(source.Id))
            {
                return(false);
            }

            CopyProcessorTransformation transformation = transformations[source.Id];

            if ((transformation.Options & CopyProcessorTransformationOptions.SingleFile) == 0)
            {
                return(false);
            }

            LocalPath destinationPath = transformation.DestinationPath;

            PackagedFileInfo sourceFile              = source.ListFiles().AsQueryable().First();
            FullPath         destinationFullPath     = destinationRootDir.CombineWith(destinationPath);
            FileFullPath     destinationFileFullPath = destinationFullPath.ToFileFullPath();

            filesList.AddFile(new PackagedFileInfo(destinationFileFullPath));
            copier.Copy(sourceFile.FileFullPath, destinationFileFullPath);

            return(true);
        }
Example #2
0
        private ICompositeFilesSource ProcessPrivate(
            ICompositeFilesSource compositeFilesSource,
            bool isRoot)
        {
            CompositeFilesSource transformedCompositeSource = isRoot
                                                                  ? new StandardPackageDef(compositeFilesSource.Id)
                                                                  : new CompositeFilesSource(compositeFilesSource.Id);

            foreach (IFilesSource filesSource in compositeFilesSource.ListChildSources())
            {
                if (filesSource is ICompositeFilesSource)
                {
                    throw new NotImplementedException("Child composites are currently not supported");
                }

                FilesList filesList = new FilesList(filesSource.Id);

                LocalPath destinationPath = FindDestinationPathForSource(filesSource.Id);

                foreach (PackagedFileInfo sourceFile in filesSource.ListFiles())
                {
                    if (false == LoggingHelper.LogIfFilteredOut(sourceFile.FullPath.ToString(), filter, logger))
                    {
                        continue;
                    }

                    FullPath destinationFileName = new FullPath(destinationRootDir);
                    destinationFileName = destinationFileName.CombineWith(destinationPath);

                    if (sourceFile.LocalPath != null)
                    {
                        destinationFileName = destinationFileName.CombineWith(sourceFile.LocalPath);
                    }
                    else
                    {
                        destinationFileName =
                            destinationFileName.CombineWith(new LocalPath(Path.GetFileName(
                                                                              sourceFile.FullPath.ToString())));
                    }

                    string destFile = Path.GetFileName(destinationFileName.ToString());
                    if (fileTransformations.ContainsKey(destFile))
                    {
                        destinationFileName = new FullPath(Path.Combine(
                                                               Path.GetDirectoryName(destinationFileName.ToString()),
                                                               fileTransformations[destFile]));
                    }

                    filesList.AddFile(new PackagedFileInfo(destinationFileName));

                    copier.Copy(sourceFile.FullPath.ToString(), destinationFileName.ToString());
                }

                transformedCompositeSource.AddFilesSource(filesList);
            }

            return(transformedCompositeSource);
        }
Example #3
0
        private void TransformSource(IFilesSource filesSource, FilesList filesList)
        {
            CopyProcessorTransformation transformation = FindTransformationForSource(filesSource.Id);
            bool flattenDirs = (transformation.Options & CopyProcessorTransformationOptions.FlattenDirStructure) != 0;

            LocalPath destinationPath = transformation.DestinationPath;

            foreach (PackagedFileInfo sourceFile in filesSource.ListFiles())
            {
                if (false ==
                    LoggingHelper.LogIfFilteredOut(sourceFile.FileFullPath.ToString(), filter, taskContext))
                {
                    continue;
                }

                FullPath destinationFullPath = destinationRootDir.CombineWith(destinationPath);

                if (sourceFile.LocalPath != null)
                {
                    LocalPath destLocalPath = sourceFile.LocalPath;
                    if (flattenDirs)
                    {
                        destLocalPath = destLocalPath.Flatten;
                    }

                    destinationFullPath = destinationFullPath.CombineWith(destLocalPath);
                }
                else
                {
                    destinationFullPath =
                        destinationFullPath.CombineWith(new LocalPath(sourceFile.FileFullPath.FileName));
                }

                string destFile = destinationFullPath.FileName;
                if (fileTransformations.ContainsKey(destFile))
                {
                    destinationFullPath = destinationFullPath.ParentPath.CombineWith(
                        fileTransformations[destFile]);
                }

                FileFullPath destinationFileFullPath = destinationFullPath.ToFileFullPath();
                filesList.AddFile(new PackagedFileInfo(destinationFileFullPath));

                copier.Copy(sourceFile.FileFullPath, destinationFileFullPath);
            }
        }