16 August 2014, 20:45 | #41 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
An array that is able to double its length (with realloc) works best here.
My 'ls' works like that, starting with 100 length. |
16 August 2014, 20:50 | #42 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Reallocating would mean to copy all current contents, doesn't it?
|
16 August 2014, 21:12 | #43 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
means AllocDoubleMem/CopyMem/FreeOldMem yeah
But it's a win speedwise, I've tested when I was fiddling with an 'ls' kind of program. |
16 August 2014, 21:14 | #44 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Ok. I am going to use an array. For 10 bytes of content per object an overhead of 8 further bytes for the minnode structure is too much.
Now this is the plan so far: - when user clicks on "cut" or "copy", the list of selected filenames and the source dir path are temporary stored in the base structure of the filemanager class - selecting other files and another click on these two buttons replaces the temporary list - when user clicks "paste" that list is stepped through with Examine() - each encountered file is shared-locked and stored in the array - each dir encountered is also stored and locked, but triggers the ExAll() recursively on its contents - any file or directory object found by that ExAll()s is locked and stored in the array - each directory level of ExAll() gets it's own ExAllControl structure and ExAllBuffer, while that Buffer is allocated depending on free memory - pointer to that structure, the current dir lock and the buffer pointer are stored on the stack (12 bytes per level) |
16 August 2014, 21:37 | #45 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
|
Reallocating an array and then copying it's contents isn't necessary. You can just allocate extra arrays as needed. The first long word in each array simply links to the next array. These link pointers are also used for freeing the arrays when they're no longer needed.
Easy |
16 August 2014, 21:41 | #46 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Perfect idea, thanks.
What I need is some current-position pointer or such. |
16 August 2014, 21:53 | #47 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
|
|
16 August 2014, 21:58 | #48 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
And make each part of the array the same size and substract 1 from max items until the end is reached. then allocate next one.
|
16 August 2014, 22:08 | #49 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
|
|
16 August 2014, 22:10 | #50 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
And i am going to keep a pointer to the start of the current array to store the pointer to the next one there.
|
16 August 2014, 22:13 | #51 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
|
|
16 August 2014, 22:29 | #52 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Implementing drag and drop would be the next step after this... yet not so easy but I did it once and it can only become better as I learned from that.
|
16 August 2014, 23:10 | #53 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
But, here in this case, sorting might not be needed, so yeah... |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copy file from PC filesystem to WinUAE harddisk | Raizor | support.WinUAE | 2 | 10 January 2011 20:44 |
Copy CF card file to ram:, insert other CF card, copy over? | Photon | support.Hardware | 16 | 21 July 2009 22:05 |
Very slow file copy? | DDNI | support.WinUAE | 4 | 16 March 2009 22:16 |
Copy file containing control codes to printer? | Photon | support.Apps | 1 | 10 December 2006 02:36 |
Problems with massive file copy & JIT | jotd | support.WinUAE | 1 | 15 November 2006 19:16 |
|
|