diff --git a/JShim/Java/NIO/File/Files.cs b/JShim/Java/NIO/File/Files.cs index af90156..2986b45 100644 --- a/JShim/Java/NIO/File/Files.cs +++ b/JShim/Java/NIO/File/Files.cs @@ -116,11 +116,6 @@ private static FileVisitResult VisitDirectory(DirectoryInfo dir, FileVisitor vis return result; return result; - - // TODO: Shift processing logic to FileVisitor -// DateTime? creation, lastWrite, lastAccess; -// Extract(dir, out creation, out lastWrite, out lastAccess); -// Correct(dir, creation, lastWrite, lastAccess); } private static FileVisitResult VisitFile(FileInfo file, FileVisitor visitor) @@ -135,37 +130,6 @@ private static FileVisitResult VisitFile(FileInfo file, FileVisitor visitor) result = visitor.VisitFile(file); return result; - - // TODO: Shift processing logic to FileVisitor - /* - DateTime? creation, lastWrite, lastAccess; - IEnumerator e = this.parsers.Values.GetEnumerator(); - while(e.MoveNext()) - { - IFileDateable parser = e.Current; - try - { - parser.GetDateTimes(file, out creation, out lastWrite, out lastAccess); - } - catch(ApplicationException ex) - { - creation = lastWrite = lastAccess = null; - log.Error(ex); - } - - if(creation.HasValue || lastWrite.HasValue || lastAccess.HasValue) - { - // Backup and restore Read-Only attribute prior to updating any - // timestamps. - bool readOnly = file.IsReadOnly; - file.IsReadOnly = false; - Correct(file, creation, lastWrite, lastAccess); - file.IsReadOnly = readOnly; - } - - creation = lastWrite = lastAccess = null; - } - */ } } } \ No newline at end of file diff --git a/JShim/Javax/Swing/SwingWorker.cs b/JShim/Javax/Swing/SwingWorker.cs index a44920c..8999608 100644 --- a/JShim/Javax/Swing/SwingWorker.cs +++ b/JShim/Javax/Swing/SwingWorker.cs @@ -353,7 +353,7 @@ public void Publish(params V[] chunks) { foreach(V chunk in chunks) { - // FIXME: Calculate the progress percentage. + // Progress percentage is updated in derived classes' Process. backgroundWorker.ReportProgress(progress, chunk); } } @@ -380,7 +380,6 @@ public void RemovePropertyChangeListener(PropertyChangeListener listener) /// public void Run() { - // TODO: Need to check difference between Execute() and Run(). if(!cancelled) result = DoInBackground(); } diff --git a/Wreck/IO/Reader/Fs/DirectoryReader.cs b/Wreck/IO/Reader/Fs/DirectoryReader.cs index 2720fe2..b933f76 100644 --- a/Wreck/IO/Reader/Fs/DirectoryReader.cs +++ b/Wreck/IO/Reader/Fs/DirectoryReader.cs @@ -40,7 +40,7 @@ public override string[] Accessed() return LATEST; } - // FIXME: Somehow using DirectoryInfo as key always fail to get. So using full path name string. + // HACK: get always fail with DirectoryInfo as key. Using full path name string as substitute. private readonly IDictionary> fileTimes = new Dictionary>(); public void Add(DirectoryInfo dir, IDictionary suggestions) diff --git a/Wreck/Service/PreviewService.cs b/Wreck/Service/PreviewService.cs index ceefd48..0a05075 100644 --- a/Wreck/Service/PreviewService.cs +++ b/Wreck/Service/PreviewService.cs @@ -61,10 +61,6 @@ public ITask Run( throw new ArgumentException("Unknown correction mode"); } - // TODO: To update factory method to instantiate ProgressWorker sub-class implementations -// ProgressWorker pw = new ProgressWorker(task, startPath); -// pw.addPropertyChangeListener(pcl); // Belongs to Java Beans -// pw.execute(); // Belongs to Java SwingWorker return task; } } diff --git a/Wreck/Wreck.cs b/Wreck/Wreck.cs index e64e814..dfb3cc8 100644 --- a/Wreck/Wreck.cs +++ b/Wreck/Wreck.cs @@ -16,271 +16,9 @@ namespace Wreck /// /// Description of Wreck. /// - public class Wreck : IDisposable + public class Wreck //: IDisposable { public const string NAME = "WRECK.NET"; public const string VERSION = "1.00a"; - - private static readonly ILog log = LogManager.GetLogger(typeof(Wreck)); - - private ILogger logger; - - private Statistics stats; - public enum FileInfoTools { - ExifTool, - MediaInfo, - SevenZip - }; - private Dictionary parsers; - private ICorrector corrector; - - public Wreck(ILogger logger, ICorrector corrector) - { - this.logger = logger; - this.stats = new Statistics(); - - this.parsers = new Dictionary(); - - try - { - this.parsers.Add(FileInfoTools.ExifTool, new ExifToolParser()); - } - catch(ApplicationException ex) - { - log.Error(ex); - } - - this.parsers.Add(FileInfoTools.MediaInfo, new MediaInfoParser()); - this.parsers.Add(FileInfoTools.SevenZip, new SevenZipParser()); - - this.corrector = corrector; - } - - public void Dispose() - { - IFileDateable exifToolParser; - if(this.parsers.TryGetValue(FileInfoTools.ExifTool, out exifToolParser)) - { - ((ExifToolParser) exifToolParser).Dispose(); - } - - GC.SuppressFinalize(this); - } - - public Statistics GetStatistics() - { - return stats; - } - - public void Walk(string startingPath) - { - FileSystemInfo start; - - if(Directory.Exists(startingPath)) - start = new DirectoryInfo(startingPath); - else if(File.Exists(startingPath)) - start = new FileInfo(startingPath); - else - throw new IOException(startingPath + " is neither directory or file."); - - // TODO: Migrate to using PreviewService and ProgressWorker - FileVisitor visitor = new Wreck.EchoFileVisitor(this); - Files.WalkFileTree(start, visitor); - } - - // HACK: To be replaced by actual implementation. - public class EchoFileVisitor : SimpleFileVisitor - { - private Wreck outer; - - public EchoFileVisitor(Wreck outer) - { - this.outer = outer; - } - - public override FileVisitResult PreVisitDirectory(DirectoryInfo dir) - { - log.InfoFormat("PreVisitDirectory: {0}", dir.FullName); - - outer.logger.CurrentDirectory(dir); - - return base.PreVisitDirectory(dir); - } - - public override FileVisitResult VisitFile(FileInfo file) - { - log.InfoFormat("VisitFile: {0}", file.Name); - - outer.logger.CurrentFile(file); - outer.stats.Count(file); - - return base.VisitFile(file); - } - - public override FileVisitResult VisitFileFailed(FileSystemInfo file, IOException exc) - { - log.ErrorFormat("VisitFileFailed: {0}, Exception: {1}", file.FullName, exc.Message); - - if(file is FileInfo) - { - outer.stats.Skip((FileInfo) file); - outer.logger.SkipReparsePoint((FileInfo) file); - } - else if(file is DirectoryInfo) - { - outer.stats.Skip((DirectoryInfo) file); - outer.logger.SkipReparsePoint((DirectoryInfo) file); - } - else - outer.logger.UnknownPathType(file.FullName); - - return base.VisitFileFailed(file, exc); - } - - public override FileVisitResult PostVisitDirectory(DirectoryInfo dir, IOException exc) - { - log.InfoFormat("PostVisitDirectory: {0}", dir.FullName); - - outer.stats.Count(dir); - - return base.PostVisitDirectory(dir, exc); - } - } - - /// - /// Extract metadata by piping a file or directory through the - /// appropriate third party tool(s) e.g. exiftool, mediainfo. - /// - /// Extracted metadata time are returned in creation, lastWrite and - /// lastAccess passed by reference. Null value reflects absence of - /// usable metadata date time tag or value. - /// - /// FileSystemInfo object representing a file or directory - /// Metadata creation time - /// Metadata modification time - /// Metadata access time - public void Extract( - FileSystemInfo fsi, - out DateTime? creation, - out DateTime? lastWrite, - out DateTime? lastAccess) - { - // TODO: To be updated with real metadata extraction calls - DateTime test = new DateTime(1980, 1, 1, 0, 0, 0); - creation = test; - lastWrite = test; - lastAccess = test; - } - - /// - /// Correct the creation, last write and last access file time according - /// to precedence order: embedded metadata, or relative to last write - /// time. - /// - /// Creation time will be reset to last write time if it is a copy that - /// reflects the copying date time. - /// - /// Last Access time will be reset to last write time as a conservative - /// estimate of the active time period of use, rather than some sporadic - /// random access reset by ad-hoc document retrievals. - /// - /// FileSystemInfo object representing a file or directory - /// Metadata creation time - /// Metadata modification time - /// Metadata access time - public void Correct( - FileSystemInfo fsi, - DateTime? creation, - DateTime? lastWrite, - DateTime? lastAccess) - { - // Fix modification time. - try - { - if (lastWrite.HasValue && !fsi.LastWriteTime.Equals(lastWrite.Value)) - { - corrector.ByLastWriteMetadata(fsi, lastWrite.Value); - logger.CorrectedByLastWriteMetadata(fsi, lastWrite.Value); - } - } - catch(UnauthorizedAccessException ex) - { - logger.UnauthorizedAccessException(ex); - } - - - // Fix creation time using specified time, - try - { - if (creation.HasValue && !fsi.CreationTime.Equals(creation.Value)) - { - corrector.ByCreationMetadata(fsi, creation.Value); - logger.CorrectedByCreationMetadata(fsi, creation.Value); - } - } - catch(UnauthorizedAccessException ex) - { - logger.UnauthorizedAccessException(ex); - } - - // Fix access time using specified time, or from modified time. - try - { - if (lastAccess.HasValue && !fsi.LastAccessTime.Equals(lastAccess.Value)) - { - corrector.ByLastAccessMetadata(fsi, lastAccess.Value); - logger.CorrectedByLastAccessMetadata(fsi, lastAccess.Value); - } - } - catch(UnauthorizedAccessException ex) - { - logger.UnauthorizedAccessException(ex); - } - - // Fix creation time from modified time. - // Creation time will always be earlier than modification time. - /* - try - { - if (fsi.CreationTime.CompareTo(fsi.LastWriteTime) > 0) - { - corrector.ByLastWriteTime(fsi, fsi.CreationTime); - logger.CorrectedByLastWriteTime(fsi, fsi.CreationTime); - } - - } - catch(UnauthorizedAccessException ex) - { - logger.UnauthorizedAccessException(ex); - } - */ - // Fix last access time from modified time. - // Last access time will always be earlier than modification time. - /* - try - { - if(fsi.LastAccessTime.CompareTo(fsi.LastWriteTime) > 0) - { - corrector.ByLastWriteTime(fsi, fsi.LastAccessTime); - logger.CorrectedByLastWriteTime(fsi, fsi.LastAccessTime); - } - } - catch(UnauthorizedAccessException ex) - { - logger.UnauthorizedAccessException(ex); - } - */ - } - - /// - /// Does nothing for now after the file system time stamps are corrected. - /// Perhaps for some future post-processing tasks like: - /// - packaging into a ZIP archive - /// - generating a file manifest or hash file like md5sum - /// - public void Keep() - { - - } } } \ No newline at end of file diff --git a/WreckCli/Controller/CliController.cs b/WreckCli/Controller/CliController.cs index 251fce7..c410a08 100644 --- a/WreckCli/Controller/CliController.cs +++ b/WreckCli/Controller/CliController.cs @@ -238,18 +238,15 @@ private void Run(CorrectionMode mode, string[] args) continue; } - // FIXME: More like MakeTask or CreateTask Dictionary sources = new Dictionary(); foreach(SourceEnum s in SourceEnum.Values) { - // FIXME: To check GUI control checkbox sources.Add(s, true); } Dictionary corrections = new Dictionary(); foreach(CorrectionEnum c in CorrectionEnum.Values) { - // FIXME: To check GUI control checkbox corrections.Add(c, true); } diff --git a/WreckGui/Controller/GuiController.cs b/WreckGui/Controller/GuiController.cs index 27dd8a8..1b97f81 100644 --- a/WreckGui/Controller/GuiController.cs +++ b/WreckGui/Controller/GuiController.cs @@ -139,23 +139,17 @@ public void UnknownPathType(string path) public void CurrentPath(string p) { - // TODO: Remove -// if(view.BackgroundWorker != null) -// view.BackgroundWorker.ReportProgress(0, p); + } public void CurrentFile(FileInfo f) { - // TODO: Remove -// if(view.BackgroundWorker != null) -// view.BackgroundWorker.ReportProgress(0, f); + } public void CurrentDirectory(DirectoryInfo d) { - // TODO: Remove -// if(view.BackgroundWorker != null) -// view.BackgroundWorker.ReportProgress(0, d); + } public void SkipReparsePoint(DirectoryInfo d) @@ -190,9 +184,7 @@ public void CorrectedByLastWriteTime(FileSystemInfo fsi, DateTime creationOrLast public void Statistics(Statistics stats) { - // TODO: Remove -// if(view.BackgroundWorker != null) -// view.BackgroundWorker.ReportProgress(0, stats); + } public void UnauthorizedAccessException(UnauthorizedAccessException ex) @@ -259,7 +251,6 @@ private void Run(CorrectionMode mode) continue; } - // FIXME: More like MakeTask or CreateTask Dictionary sources = new Dictionary(); foreach(SourceEnum s in SourceEnum.Values) { diff --git a/WreckGui/MainForm.cs b/WreckGui/MainForm.cs index 5fbba95..f3b719f 100644 --- a/WreckGui/MainForm.cs +++ b/WreckGui/MainForm.cs @@ -32,13 +32,6 @@ public partial class MainForm : Form private TreeNode dirNode; private TreeNode fileNode; - // TODO: Remove -// private BackgroundWorker backgroundWorker = null; -// public BackgroundWorker BackgroundWorker -// { -// get { return backgroundWorker; } -// } - // Based on the index assigned by imageList in Design mode. private enum TreeViewIcon { @@ -78,107 +71,13 @@ public MainForm() SetAppState(false); this.treeViewPaths.Nodes.Add(this.rootNode); - // TODO: Remove -// backgroundWorker = new BackgroundWorker(); - log.Debug("Initialized MainForm"); } - // TODO: Remove -// public void Run(string[] args) -// { -// using(Wreck wreck = new Wreck(logger, new Previewer())) -// { -// logger.Statistics(wreck.GetStatistics()); -// foreach(string p in args) -// { -// logger.CurrentPath(p); -// wreck.Walk(p); -// } -// logger.Statistics(wreck.GetStatistics()); -// } -// } - void BtnRunClick(object sender, EventArgs e) { ((GuiController) controller).Analyze(); - // TODO: Remove -// if(!backgroundWorker.IsBusy) -// { -// backgroundWorker.DoWork += new DoWorkEventHandler(DoWork); -// backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); -// backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); -// backgroundWorker.WorkerReportsProgress = true; -// backgroundWorker.WorkerSupportsCancellation = false; -// backgroundWorker.RunWorkerAsync(); -// SetAppState(true); -// } - } - - // TODO: Remove - /* - void DoWork(object sender, DoWorkEventArgs e) - { - log.Debug("DoWork"); - string[] args = Environment.GetCommandLineArgs(); - string[] dirs; - - if(args.Length > 1) - { - dirs = new string[args.Length-1]; - Array.Copy(args, 1, dirs, 0, args.Length-1); - } - else - { - dirs = new string[] - { - Directory.GetCurrentDirectory() - }; - } - - this.Run(dirs); - } - - void ProgressChanged(object sender, ProgressChangedEventArgs e) - { - //log.DebugFormat("Progress: {0} %", e.ProgressPercentage); - - if (e.UserState is String) - { - string p = (string) e.UserState; - CurrentPath(p); - } - else if(e.UserState is FileInfo) - { - FileInfo fi = (FileInfo) e.UserState; - CurrentFile(fi); - } - else if(e.UserState is DirectoryInfo) - { - DirectoryInfo di = (DirectoryInfo) e.UserState; - CurrentDirectory(di); - } - else if(e.UserState is Statistics) - { - Statistics stats = (Statistics) e.UserState; - Statistics(stats); - } - else - { - log.WarnFormat("{0}: {1}", e.UserState.GetType().FullName, e.UserState.ToString()); - Debug.Assert(false); - } - - } - - void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - //log.Debug("RunWorkerCompleted"); - SetCurrentFile(string.Empty); - SetAppState(false); - this.treeViewPaths.ExpandAll(); } - */ public void Version() {