コード例 #1
0
        public void CreateBasePaths(AliasService aliasService)
        {
            //_logger.Information("Creating output alias directories ...");
            Directory.CreateDirectory(OutputBasePath);
            foreach (var alias in aliasService.GetAliases())
            {
                var aliasPath       = aliasService.GetAliasPath(alias);
                var outputAliasPath = Path.Combine(OutputBasePath, aliasPath);
                _logger.Information("Alias [{Alias}] = [{OutputAliasPath}]", alias, outputAliasPath);
                Directory.CreateDirectory(outputAliasPath);
            }

            //_logger.Information("Create output alias directories done!");
        }
コード例 #2
0
        private static void BuildIt(IList <Config> configs)
        {
            foreach (var config in configs)
            {
                _logger.Information("");
                _logger.Information("Building from {SourcePath} to {TargetPath} ...", config.SourceBasePath, config.OutputBasePath);
                using (var outputFileHandler = FileHandlerFactory.Create(_logger, config.OutputBasePath))
                {
                    AliasService aliasService = new AliasService(config.Aliases);
                    outputFileHandler.CreateBasePaths(aliasService);

                    var syncList = BuildSyncList(outputFileHandler, config, aliasService);
                    if (config.UserStartup)
                    {
                        BuildUserStartup(configs, syncList);
                    }
                    SynchronizeV2(syncList, outputFileHandler);
                }
                //_logger.Information("Build done");
            }
        }
コード例 #3
0
 public void CreateBasePaths(AliasService aliasService)
 {
 }
コード例 #4
0
        private static void AddContentToSyncList(string sourceBasePath, IFileHandler outputFileHandler, IList <Package> packages,
                                                 string contentFolderName, SyncType syncType, List <Sync> syncList, AliasService aliasService)
        {
            int packageCnt = 0;

            foreach (var package in packages)
            {
                ProgressBar.DrawProgressBar($"AddContentToSyncList [{contentFolderName}]", packageCnt++, packages.Count);

                var packageContentFolderBasePath = _pathService.Combine(sourceBasePath, package.Path, contentFolderName);
                var packageContentLhaBasePath    = _pathService.Combine(sourceBasePath, package.Path, contentFolderName + ".lha");
                if (Directory.Exists(packageContentFolderBasePath) && File.Exists(packageContentLhaBasePath))
                {
                    throw new Exception($"Package [{package.Path}] has both [content] folder and [content.lha].");
                }

                string packageContentBasePath;
                if (File.Exists(packageContentLhaBasePath))
                {
                    packageContentBasePath = packageContentLhaBasePath;
                }
                else if (Directory.Exists(packageContentFolderBasePath))
                {
                    packageContentBasePath = packageContentFolderBasePath;
                }
                else
                {
                    continue;
                }

                using (var contentFileHandler = FileHandlerFactory.Create(_logger, packageContentBasePath))
                {
                    var packageOutputPath = "";
                    var sourcePath        = "";
                    var packageEntries    = contentFileHandler.DirectoryGetFileSystemEntriesRecursive(sourcePath);
                    foreach (var packageEntry in packageEntries)
                    {
                        var outputPath = aliasService.TargetAliasToOutputPath(packageEntry);

                        var packageEntryFileName = _pathService.GetFileName(outputPath);
                        if (ShouldContentReverseAll(packageEntryFileName))
                        {
                            var contentReversePackageEntryPath = _pathService.GetDirectoryName(outputPath);
                            var contentReversePackageSubPath   = RemoveRoot(sourcePath, contentReversePackageEntryPath);
                            var contentReverseFileOutputPath   = _pathService.Combine(packageOutputPath, contentReversePackageSubPath);
                            if (outputFileHandler.DirectoryExists(contentReverseFileOutputPath))
                            {
                                var innerContentReversePackageEntries = outputFileHandler.DirectoryGetFileSystemEntriesRecursive(contentReverseFileOutputPath);
                                foreach (var innerContentReversePackageEntry in innerContentReversePackageEntries)
                                {
                                    var innerContentReversePackageSubPath = RemoveRoot(packageOutputPath, innerContentReversePackageEntry);
                                    var innerContentReverseSourcePath     = _pathService.Combine(sourcePath, innerContentReversePackageSubPath);

                                    var innerSync = new Sync
                                    {
                                        PackageContentBasePath = packageContentBasePath,
                                        SourcePath             = innerContentReverseSourcePath,
                                        TargetPath             = innerContentReversePackageEntry,
                                        SyncType = syncType,
                                        FileType = outputFileHandler.GetFileType(innerContentReversePackageEntry)
                                    };

                                    syncList.Add(innerSync);
                                }
                            }
                        }
                        else
                        {
                            var packageSubPath = RemoveRoot(sourcePath, outputPath);
                            var fileOutputPath = _pathService.Combine(packageOutputPath, packageSubPath);
                            var sync           = new Sync
                            {
                                PackageContentBasePath = packageContentBasePath,
                                SourcePath             = packageEntry,
                                TargetPath             = fileOutputPath,
                                SyncType = syncType,
                                FileType = contentFileHandler.GetFileType(packageEntry)
                            };

                            syncList.Add(sync);
                        }
                    }
                }
            }
        }
コード例 #5
0
        private static IList <Sync> BuildSyncList(IFileHandler outputFileHandler, Config config, AliasService aliasService)
        {
            _logger.Information("Building sync list ...");

            var syncList = new List <Sync>();

            var packages = GetIncludedPackages(config);

            AddContentToSyncList(config.SourceBasePath, outputFileHandler, packages, "content", SyncType.SourceToTarget, syncList, aliasService: aliasService);
            AddDeleteToSyncList(outputFileHandler, syncList);
            var reverseSyncType = config.ReverseSync ? SyncType.TargetToSource : SyncType.SourceToTarget;

            AddContentToSyncList(config.SourceBasePath, outputFileHandler, packages, "content_reverse", reverseSyncType, syncList, aliasService: aliasService);


            BuildReadme(packages, syncList);

            ProgressBar.ClearProgressBar();

            //_logger.Information("Building sync list done!");

            return(syncList);
        }
コード例 #6
0
 public void CreateBasePaths(AliasService aliasService)
 {
     throw new NotImplementedException();
 }