WIP: Porting to Nim.
This commit is contained in:
		
							
								
								
									
										12
									
								
								treediff.nim
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								treediff.nim
									
									
									
									
									
								
							@@ -1,5 +1,17 @@
 | 
				
			|||||||
import os, docopt, tables, md5, iterutils, re
 | 
					import os, docopt, tables, md5, iterutils, re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type
 | 
				
			||||||
 | 
					  FileEntry* = tuple[relPath: string, checksum: string]
 | 
				
			||||||
 | 
					  DirAnalysis* = tuple[allEntries: seq[FileEntry],
 | 
				
			||||||
 | 
					                      byRelPath: Table[string, FileEntry],
 | 
				
			||||||
 | 
					                      byChecksum: Table[string, FileEntry]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					proc analyzeDir(root: string): DirAnalysis =
 | 
				
			||||||
 | 
					  let fileCount = countFiles(root)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					proc countFiles(root: string): int =
 | 
				
			||||||
 | 
					  # TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc studyDir(root: string, ignore: Iterable[string]): TableRef[string, string] =
 | 
					proc studyDir(root: string, ignore: Iterable[string]): TableRef[string, string] =
 | 
				
			||||||
    result = newTable[string, string]()
 | 
					    result = newTable[string, string]()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								treediff.pseudocode
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								treediff.pseudocode
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					analyzeDir (tail call optimizable?)
 | 
				
			||||||
 | 
					  count total # of files
 | 
				
			||||||
 | 
					  for all files in directory
 | 
				
			||||||
 | 
					    compute md5 checksum
 | 
				
			||||||
 | 
					    create file entry: file obj, relative path, checksum
 | 
				
			||||||
 | 
					    add entry to dictionary indexed by relative path
 | 
				
			||||||
 | 
					    add entry to dictionary indexed by checksum
 | 
				
			||||||
 | 
					    add entry to list of all entries
 | 
				
			||||||
 | 
					    for each subdirectory, analyzeDir
 | 
				
			||||||
 | 
					    return analysis
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								worklog.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								worklog.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					Current Task
 | 
				
			||||||
 | 
					========================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Currently implementing `countFiles` in
 | 
				
			||||||
 | 
					treediff.nim
 | 
				
			||||||
		Reference in New Issue
	
	Block a user