示例#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);
        }
示例#2
0
        /// <summary>
        /// Defines a transformation for <see cref="SingleFileSource"/> which copies the file to the destination
        /// and renames the file in the process.
        /// </summary>
        /// <param name="sourceId">ID of the <see cref="SingleFileSource"/>.</param>
        /// <param name="destinationFileName">The destination directory and file name (local path).</param>
        /// <returns>This same instance of the <see cref="CopyProcessor"/>.</returns>
        public CopyProcessor AddSingleFileTransformation(string sourceId, LocalPath destinationFileName)
        {
            CopyProcessorTransformation transformation = new CopyProcessorTransformation(
                sourceId, destinationFileName, CopyProcessorTransformationOptions.SingleFile);

            transformations.Add(sourceId, transformation);
            return(this);
        }
示例#3
0
        public CopyProcessor AddTransformationWithDirFlattening(string sourceId, LocalPath destinationDir)
        {
            CopyProcessorTransformation transformation = new CopyProcessorTransformation(
                sourceId, destinationDir, CopyProcessorTransformationOptions.FlattenDirStructure);

            transformations.Add(sourceId, transformation);
            return(this);
        }
示例#4
0
        public CopyProcessor AddTransformation(string sourceId, LocalPath destinationDir)
        {
            CopyProcessorTransformation transformation = new CopyProcessorTransformation(
                sourceId, destinationDir, CopyProcessorTransformationOptions.None);

            transformations.Add(sourceId, transformation);
            return(this);
        }
示例#5
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);
            }
        }