English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 16 August 2014, 20:45   #41
alkis
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.
alkis is offline  
Old 16 August 2014, 20:50   #42
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
Reallocating would mean to copy all current contents, doesn't it?
AGS is offline  
Old 16 August 2014, 21:12   #43
alkis
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.
alkis is offline  
Old 16 August 2014, 21:14   #44
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
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)
AGS is offline  
Old 16 August 2014, 21:37   #45
Thorham
Computer Nerd
 
Thorham's Avatar
 
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
Thorham is offline  
Old 16 August 2014, 21:41   #46
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
Perfect idea, thanks.

What I need is some current-position pointer or such.
AGS is offline  
Old 16 August 2014, 21:53   #47
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
Quote:
Originally Posted by AGS View Post
What I need is some current-position pointer or such.
Yes, a current pointer is fine, especially because you can just use something simple like move.l d0,(a0)+.
Thorham is offline  
Old 16 August 2014, 21:58   #48
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
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.
AGS is offline  
Old 16 August 2014, 22:08   #49
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
Quote:
Originally Posted by AGS View Post
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.
Yes, nothing but a simple for loop, really.
Thorham is offline  
Old 16 August 2014, 22:10   #50
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
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.
AGS is offline  
Old 16 August 2014, 22:13   #51
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,796
Quote:
Originally Posted by AGS View Post
And i am going to keep a pointer to the start of the current array to store the pointer to the next one there.
Yes, very simple stuff
Thorham is offline  
Old 16 August 2014, 22:29   #52
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
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.
AGS is offline  
Old 16 August 2014, 23:10   #53
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Quote:
Originally Posted by Thorham View Post
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
Well, having the pointers to the array in a continuous block in memory makes certain things easier. Like sorting. ;-)

But, here in this case, sorting might not be needed, so yeah...
alkis is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:02.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09305 seconds with 13 queries