+ void LoadComparedList()
+ {
+ int c/*, cmp*/ /*, smallest*/, icon;//, equalCount;
+ int count = comparedPaths ? comparedPaths.count : 0;
+ //bool allDone = false;
+ bool not;
+ FileStats stats;
+ char path[MAX_LOCATION];
+ //Array<ComparisonState> states { };
+ //Array<FileListing> listings { };
+ //Array<int> equals { };
+ //Array<MapNode<String, int>> mapNodes { };
+
+ //Array<Map<String, int>> lists { };
+ //Map<int, bool> equals{ };
+
+
+ MapNode<String, /*Map<int, */Array<int>> na;
+ //MapNode<int, int> nb;
+ Map<String, /*Map<int, */Array<int>> names { };
+ //Map<String, Array<bool>> names { };
+ //Map<String, bool[16]> names { }; // does not seem to be working
+ //Map<String, BoolArrayInt> names { };
+ {
+ for(c = 0; c < comparedPaths.count; c++)
+ {
+ FileListing listing { comparedPaths[c], extensions = extensions };
+ while(listing.Find())
+ {
+ /*Map<int, int>*/Array<int> m = names[listing.name];
+ if(!m)
+ m = { };
+ names[listing.name] = m;
+ /*/m[c] = */m.Add(c);
+ }
+ }
+ /* // compiles and should work but better solution?
+ for(c = 0; c < comparedPaths.count; c++)
+ {
+ FileListing listing { comparedPaths[c], extensions = extensions };
+ while(listing.Find())
+ {
+ Array<bool> a = names[listing.name];
+ if(!a)
+ a = { };
+ names[listing.name] = a;
+ a[c] = true;
+ }
+ }
+ */
+ /* // does not seem to be working
+ for(c = 0; c < comparedPaths.count; c++)
+ {
+ FileListing listing { comparedPaths[c], extensions = extensions };
+ while(listing.Find())
+ {
+ names[listing.name][c] = true;
+ }
+ }
+ */
+ /*
+ if(comparedPaths.count > 0)
+ {
+ FileListing listing { comparedPaths[0], extensions = extensions };
+ while(listing.Find())
+ {
+ // should be able to just do names[listing.name]._0 = true;
+ BoolArrayInt bai = names[listing.name];
+ bai._0 = true;
+ names[listing.name] = bai;
+ }
+ }
+ if(comparedPaths.count > 1)
+ {
+ FileListing listing { comparedPaths[1], extensions = extensions };
+ while(listing.Find())
+ {
+ // should be able to just do names[listing.name]._1 = true;
+ BoolArrayInt bai = names[listing.name];
+ bai._1 = true;
+ names[listing.name] = bai;
+ }
+ }
+ */
+ // and so on....
+ }
+
+ /*
+ for(dirPath : comparedPaths)
+ {
+ char * p = dirPath;
+ if(FileExists(dirPath).isDirectory)
+ {
+ FileListing listing { dirPath, extensions = extensions };
+ //MapNode<String, int> mn;
+ Map<String, int> list { };
+ //states.Add(listing.Find() == true ? matching : endOfListing);
+ while(listing.Find())
+ list[listing.name] = 0;
+ //for(mn = ; mn; mn = mn.next)
+ //mn = list.root.minimum;
+ mapNodes.Add(/-*mn*-/list.root.minimum);
+ lists.Add(list);
+ //PrintLn(dirPath, " -- .Find() -- ", states[states.count-1] == matching ? listing.name : "endOfListing*");
+ //listings.Add(listing);
+
+ {
+ MapNode<String, int> mn;
+ PrintLn("------------- DIR LISTING FOR ", dirPath);
+ for(mn = list.root.minimum; mn; mn = mn.next)
+ {
+ PrintLn(mn.key);
+ }
+ }
+ }
+ }
+ */
+
+ for(na = names.root.minimum; na; na = na.next)
+ {
+ /*Map<int, */Array<int> equals = na.value;
+ //MapNode<int, int> nb;
+ /*
+ while(!allDone)
+ {
+ smallest = 0;
+ equals.Add(0);
+ for(c = 1; c < count; c++)
+ {
+ //if(states[c] == endOfListing) continue;
+ if(!mapNodes[c]) continue;
+ // todo: use better comparison method
+ // it should compare file type (dir/file) before
+ // comparing file name.
+ // should also provide alternative methods
+ // of comparison including ones that consider
+ // date changes as differences of some kind.
+ // pethaps a OnCompare(a, b) to allow implementation
+ // of custom methods of comparison.
+ // note: this (or these) method(s) depend on files
+ // being listed in sorted order by FileListing.
+ // different comparison methods should have
+ // appropriatly different sorting in FileListing.
+ //
+ //cmp = strcmp(listings[smallest].name, listings[c].name);
+ cmp = fstrcmp(mapNodes[smallest].key, mapNodes[c].key);
+ PrintLn("COMPARING - ", mapNodes[smallest].key, " and ", mapNodes[c].key);
+ if(cmp == 0)
+ equals.Add(c);
+ //equals[c] = true;
+ else if(cmp > 0)
+ {
+ smallest = c;
+ equals.size = 0;
+ equals.Add(c);
+ }
+ }
+
+ */
+ if(equals.count == count) // all are equal, no diff icon
+ {
+ icon = 0;
+ not = false;
+ }
+ else if(equals.count == count-1) // all are equal but one, not-sign icon for singled out missing
+ {
+ int i;
+ /*
+ for(nb = equals.root.minimum, i = 0; nb; nb = nb.next, i++)
+ {
+ if(i != nb.key)
+ */
+ for(i = 0; i < equals.count; i++)
+ {
+ if(i != equals[i])
+ {
+ icon = i+1;
+ break;
+ }
+ }
+ //if(!nb)
+ if(i == equals.count)
+ icon = count;
+ not = true;
+ }
+ else if(equals.count == 1) // only one is present, all others missing, present-sign for singled out present
+ {
+ //icon = equals.root.minimum.key+1;
+ icon = equals[0]+1;
+ not = false;
+ }
+ else // mixed
+ {
+ icon = 0; // todo
+ not = true;
+ }
+#if 0
+ // or
+ if(equals.count == count) // all are equal, no diff icon
+ ;
+ else if(count/2 - equals.count < 0) // more than half are equal, use not-sign icons for all missing
+ ;
+ else // less than half are equal, use present-sign icons for all present
+ ;
+#endif
+
+ /*if((!bits.foldersOnly && !bits.filesOnly) ||
+ (bits.foldersOnly && listings[smallest].stats.attribs.isDirectory) ||
+ (bits.filesOnly && listings[smallest].stats.attribs.isFile))*/
+ strcpy(path, comparedPaths[/*smallest*/equals[0]]);
+ PathCat(path, /*mapNodes[smallest].key*/na.key);
+ FileGetStats(path, stats);
+ if((!bits.foldersOnly && !bits.filesOnly) ||
+ (bits.foldersOnly && stats.attribs.isDirectory) ||
+ (bits.filesOnly && stats.attribs.isFile))
+ {
+ FileSystemNode node =
+ MakeComparedFileSystemNode(
+ stats,
+ /*mapNodes[smallest].key*/na.key,
+ path,
+ false, bits.previewPictures,
+ icon, not, equals,
+ displaySystem);
+ AddNode(node);
+ }
+ /*
+ for(equal : equals)
+ {
+ mapNodes[equal] = mapNodes[equal].next;
+ //states[equal] = listings[equal].Find() == true ? matching : endOfListing;
+ //PrintLn(comparedPaths[equal], " -- .Find() -- ", states[equal] == matching ? listings[equal].name : "endOfListing*");
+ }
+ equals.size = 0;
+ //for(c = 0; c < count && states[c] == endOfListing; c++);
+ for(c = 0; c < count && !mapNodes[c]; c++);
+ if(c == count)
+ allDone = true;
+ */
+ }
+ list.Sort(nameField, 1);
+ }
+