Example #1
0
        private static void CopyFiles(String targetDirectory, String sourceDirectory, String extensions)
        {
            if (FsHelper.IsSamePaths(sourceDirectory, targetDirectory))
            {
                Console.WriteLine("Copying skipped because source and target folders have a same path.");
                return;
            }

            foreach (String sourceFile in Directory.EnumerateFiles(sourceDirectory, extensions, SearchOption.AllDirectories))
            {
                DateTime sourceFileTime = File.GetCreationTimeUtc(sourceFile);
                String   targetFile     = targetDirectory + sourceFile.Substring(sourceDirectory.Length);
                if (File.Exists(targetFile) && File.GetCreationTimeUtc(targetFile) == sourceFileTime)
                {
                    continue;
                }

                String directoryName = Path.GetDirectoryName(targetFile);
                Directory.CreateDirectory(directoryName);

                File.Copy(sourceFile, targetFile, true);
                File.SetCreationTimeUtc(targetFile, sourceFileTime);
                Console.WriteLine("Copied: " + targetFile.Substring(targetDirectory.Length));
            }
        }
Example #2
0
        private static void ReplaceDebugger(GameLocationInfo gameLocation)
        {
            String sourceDirectory = Path.GetFullPath("Debugger");

            if (!Directory.Exists(sourceDirectory))
            {
                throw new DirectoryNotFoundException("Debugger's directory was not found: " + sourceDirectory);
            }

            Console.WriteLine("Copy a debugger...");

            String targetDirectory = Path.Combine(gameLocation.RootDirectory, "Debugger");

            Directory.CreateDirectory(targetDirectory);

            if (FsHelper.IsSamePaths(sourceDirectory, targetDirectory))
            {
                Console.WriteLine("Copying skipped because source and target folders have a same path.");
                return;
            }

            foreach (String sourcePath in Directory.EnumerateFileSystemEntries(sourceDirectory, "*", SearchOption.AllDirectories))
            {
                if (!sourcePath.StartsWith(sourceDirectory))
                {
                    throw new InvalidDataException(sourcePath);
                }

                String relativePath = sourcePath.Substring(sourceDirectory.Length);
                String targetPath   = targetDirectory + relativePath;

                if ((File.GetAttributes(sourcePath) & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    Directory.CreateDirectory(targetPath);
                }
                else
                {
                    File.Copy(sourcePath, targetPath, true);
                    Console.WriteLine("Copied: " + targetPath.Substring(targetDirectory.Length));
                }
            }
            Console.WriteLine("The debugger was copied!");
        }