コード例 #1
0
        static void Start(string[] args)
        {
            var program = new FileInfo(Environment.GetCommandLineArgs()[0]);

            if (args.Length != 1)
            {
                Console.WriteLine("Usage: {0} <repository_to_convert>", program.Name);
                return;
            }

            var path = args[0];

            if (!File.GetAttributes(path).HasFlag(FileAttributes.Directory))
            {
                Console.WriteLine("{0} is not a directory.", path);
                return;
            }

            helper = new BinOrNotHelper("settings.json");
            try
            {
                foreach (var file in ListRepositoryFiles(path))
                {
                    WorkFile(file, helper);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while iterating over files: {0}", e);
            }
            finally
            {
                helper.Save();
            }
        }
コード例 #2
0
 private static void WorkFile(FileInfo file, BinOrNotHelper helper)
 {
     try
     {
         if (!file.Exists)
         {
             Console.WriteLine("{0} does not exist.", file.FullName);
             return;
         }
         if (helper.IsText(file))
         {
             CreateBackup(file);
             ConvertFile(file);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Error at file {0}:\n{1}", file.FullName, e);
     }
 }