Please bear with me, this is not easy for me to describe.
Sometimes (with some programs) a list of files, or the whole number of files of a directory, is accessed in descendant order instead of ascendant.
e.g. if I back up files with "backup" (os4depot), the files are read in in ascending order from a to z, but written to the backup medium in descending order (z to a).
A fellow coder has the same problem with his program.
He thinks it might be because MatchFirst() and MatchNext() on the lowest level (FS Handler?) could be pointing to the last entry and as such would turn around the sort (accessing) order.
Is there a way to prevent that and always use the same sort/accessing order? (Either a to z or a to a)
Thank you for explanations and workaround ideas
Filesystem entry sort order of file list
Filesystem entry sort order of file list
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
- colinw
- AmigaOS Core Developer
- Posts: 207
- Joined: Mon Aug 15, 2011 9:20 am
- Location: Brisbane, QLD. Australia.
Re: Filesystem entry sort order of file list
The order in which files appear depend on several things, but mainly the way the filesystem stores the information internally, for example, it may add new directory entries to the start, or the end, in the middle, sorted or unsorted,
reusing recently emptied space or new previously unused space, it is completely up to the writer to determine how they wish to do this.
The only requirement is that the full contents of a directory are eventually presented and complete and the correct return codes are presented to the caller, there are no other requirements.
If you require the contents of a directory to be presented on a certain order (say, in alphabetical order), then it is up to you to sort the output appropriately in your program, it is even easier now that utility.library provides a new built-in function called SortList(), to do that, if it is what you are after for your program.
Virtually no program (except ones that provides sorted output) will present the files in a fixed order, all the time.
The exact same content is also likely to be presented differently when using a different filesystem.
reusing recently emptied space or new previously unused space, it is completely up to the writer to determine how they wish to do this.
The only requirement is that the full contents of a directory are eventually presented and complete and the correct return codes are presented to the caller, there are no other requirements.
If you require the contents of a directory to be presented on a certain order (say, in alphabetical order), then it is up to you to sort the output appropriately in your program, it is even easier now that utility.library provides a new built-in function called SortList(), to do that, if it is what you are after for your program.
Virtually no program (except ones that provides sorted output) will present the files in a fixed order, all the time.
The exact same content is also likely to be presented differently when using a different filesystem.
Re: Filesystem entry sort order of file list
@colinw
Thank you
More questions may follow
Thank you
More questions may follow
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: Filesystem entry sort order of file list
I had forgotten about this one.
Just a couple of points of interest:
SFS and NGFS both sort the list internally so that you get the results in alphabetical order. It's not an additional step, it's just the way the directory contents are stored.
FFS and RAM-handler both present the list in reverse order, ie you get the last-created entries first when scanning the directory.
However, you must not depend on those observations as being "rules". As Colin said, there is no rule about it and what one FS does today with one directory could be quite different tomorrow with another.
C:List offers you the "sort name", "sort date", "sort size" and "reverse" options, as you know.
Just a couple of points of interest:
SFS and NGFS both sort the list internally so that you get the results in alphabetical order. It's not an additional step, it's just the way the directory contents are stored.
FFS and RAM-handler both present the list in reverse order, ie you get the last-created entries first when scanning the directory.
However, you must not depend on those observations as being "rules". As Colin said, there is no rule about it and what one FS does today with one directory could be quite different tomorrow with another.
C:List offers you the "sort name", "sort date", "sort size" and "reverse" options, as you know.
cheers
tony
tony
Re: Filesystem entry sort order of file list
@tonyw
Thank you.
I forgot about it too, have to find the reason for me asking again
Thank you.
I forgot about it too, have to find the reason for me asking again
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg