Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pack from search results: TC passes items multiple times
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Total Commander Forum Index -> TC Fixed bugs Printable version
View previous topic :: View next topic  
Author Message
white
Power Member
Power Member


Joined: 19 Nov 2003
Posts: 1304
Location: Netherlands

PostPosted: Thu Jul 26, 2012 6:04 am    Post subject: Reply with quote

Valentino wrote:
(although this optimization is so easy that I would just make it instead of talking about it Smile )?

Cool. How would you do it then? And how would it effect speed and memory usage?
_________________
#16626 Personal licence
Back to top
View user's profile Send private message Send e-mail
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4532
Location: Russian Federation

PostPosted: Thu Jul 26, 2012 6:55 am    Post subject: Reply with quote

white wrote:
Cool. How would you do it then? And how would it effect speed and memory usage?

Temporary string array or pointer array (if folders are already in some array). Sort, then check if file starts with path from that array using binary search, it is very fast. Binary search allows to compare up to 10 strings (up to first different character) if we have 1000 selected folders.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24602
Location: Switzerland

PostPosted: Thu Jul 26, 2012 7:10 am    Post subject: Reply with quote

OK, I have added some code now to filter out the duplicates when packing to ZIP, TAR and plugins. Unfortunately it cannot be done with external packers (EXE, e.g. RAR) because TC just passes the directories to them and tells them to recurse. But RAR seems to filter out duplicatss by itself.

Currently when packing tu ZIP, just choose "overwrite all".
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Valentino
Power Member
Power Member


Joined: 06 Feb 2003
Posts: 665
Location: Ukraine

PostPosted: Fri Jul 27, 2012 7:25 am    Post subject: Reply with quote

MVV wrote:
white wrote:
Cool. How would you do it then? And how would it effect speed and memory usage?
Temporary string array or pointer array (if folders are already in some array). Sort, then check if file starts with path from that array using binary search, it is very fast. Binary search allows to compare up to 10 strings (up to first different character) if we have 1000 selected folders.

I don't know how to make it in Delphi, and I don't know what structures TC uses to collect files/folders, but in C++ we can use std::set which stores its items sorted, for example:
Code:
typedef std::set<std::string> StringSet;
StringSet col;
col.insert("F:\\TEMP\\_tc1\\111\\222\\333\\bbb.txt");
col.insert("F:\\TEMP\\_tc1\\111\\222\\333");
col.insert("F:\\TEMP\\_tc1\\111\\222");
col.insert("F:\\TEMP\\_tc1\\111\\222\\444\\ccc.txt");
col.insert("F:\\TEMP\\_tc1\\111\\222\\333\\aaa.txt");

std::cout << "Before:\n\n";
boost::copy(col, std::ostream_iterator<std::string>(std::cout, "\n"));

if (col.size() > 1)
{
   for (StringSet::const_iterator itEnd = col.end(), it = itEnd; --it != col.begin(); )
   {
      if (col.find(GetPath(*it)) != itEnd)
         it = col.erase(it);
   }
}

std::cout << "\nAfter:\n\n";
boost::copy(col, std::ostream_iterator<std::string>(std::cout, "\n"));


Last edited by Valentino on Fri Jul 27, 2012 8:47 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24602
Location: Switzerland

PostPosted: Fri Jul 27, 2012 8:01 am    Post subject: Reply with quote

I was already using a list of objects for the previous items when an archive was modified, so adding this change wasn't too difficult. Please try it!
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4532
Location: Russian Federation

PostPosted: Fri Jul 27, 2012 9:31 am    Post subject: Reply with quote

Seems to be working, thanks! Smile
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24602
Location: Switzerland

PostPosted: Mon Jul 30, 2012 7:05 am    Post subject: Reply with quote

Could you try it both with ZIP and a plugin like 7zip, please?
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4532
Location: Russian Federation

PostPosted: Mon Jul 30, 2012 11:18 am    Post subject: Reply with quote

I tried it with my CopyTree, working. But people say that TC now creates list much slower in case of thousands of files.

Tested it with Windows XP system folder (~6k files), from search results TC takes about 5 seconds to generate filelist. I've used DiskDirExtended plugin for tests and then synced archives, also CopyTree (and compared directories).
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
white
Power Member
Power Member


Joined: 19 Nov 2003
Posts: 1304
Location: Netherlands

PostPosted: Tue Jul 31, 2012 9:30 am    Post subject: Reply with quote

I tested using TC 8.01rc5 32-bit, Windows XP 32-bit, 10000 files of 2k, using internal ZIP.

I created a file list with duplicates. Searched the file list and fed the results to listbox. Then I packed all entries in the listbox.

I did not detect any difference in speed. Packed results are the same as when using TC 8.01rc4.

The removal of duplicates does not always work. It looks like there is a initialization error somewhere.

Sometimes I get overwrite dialogs. Usually only the the first time after I started TC and only one per file.
_________________
#16626 Personal licence
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24602
Location: Switzerland

PostPosted: Thu Aug 02, 2012 7:05 am    Post subject: Reply with quote

Quote:
The removal of duplicates does not always work. It looks like there is a initialization error somewhere.

Sorry, I cannot help you without any details.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC Fixed bugs All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group