mirror of
https://github.com/bobbimanners/ProDOS-Utils.git
synced 2024-09-27 02:54:23 +00:00
Fixed multi-level sort (buildsorttable() can now update existing table.)
This commit is contained in:
parent
f102a7723a
commit
ae8d47bd45
22
sortdir.c
22
sortdir.c
@ -27,6 +27,7 @@
|
|||||||
* v0.59 Moved creation of filelist[] into buildsorttable(). More bugfix.
|
* v0.59 Moved creation of filelist[] into buildsorttable(). More bugfix.
|
||||||
* v0.60 Modified fileent to be a union. Build it for each subsort. Saves RAM.
|
* v0.60 Modified fileent to be a union. Build it for each subsort. Saves RAM.
|
||||||
* v0.61 Squeezed fileent to be a few bytes smaller. Fixed folder sort.
|
* v0.61 Squeezed fileent to be a few bytes smaller. Fixed folder sort.
|
||||||
|
* v0.62 Modified buildsorttable() to update existing filelist[].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#pragma debug 9
|
//#pragma debug 9
|
||||||
@ -249,7 +250,7 @@ int subdirblocks(uchar device, uint keyblk, struct pd_dirent *ent,
|
|||||||
void enqueuesubdir(uint blocknum, uint subdiridx);
|
void enqueuesubdir(uint blocknum, uint subdiridx);
|
||||||
int readdir(uint device, uint blocknum);
|
int readdir(uint device, uint blocknum);
|
||||||
#ifdef SORT
|
#ifdef SORT
|
||||||
void buildsorttable(char s);
|
void buildsorttable(char s, uchar callidx);
|
||||||
int cmp_name_asc(const void *a, const void *b);
|
int cmp_name_asc(const void *a, const void *b);
|
||||||
int cmp_name_desc(const void *a, const void *b);
|
int cmp_name_desc(const void *a, const void *b);
|
||||||
int cmp_name_asc_ci(const void *a, const void *b);
|
int cmp_name_asc_ci(const void *a, const void *b);
|
||||||
@ -1361,8 +1362,11 @@ int readdir(uint device, uint blocknum) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Build filelist[], the table used by the sorting algorithm.
|
* Build filelist[], the table used by the sorting algorithm.
|
||||||
|
* s - character representing the sorting mode
|
||||||
|
* callidx - if 0, the routine populates the table, otherwise it updates
|
||||||
|
* and existing table
|
||||||
*/
|
*/
|
||||||
void buildsorttable(char s) {
|
void buildsorttable(char s, uchar callidx) {
|
||||||
static char namebuf[NMLEN+1];
|
static char namebuf[NMLEN+1];
|
||||||
uint off;
|
uint off;
|
||||||
uchar entry, i;
|
uchar entry, i;
|
||||||
@ -1385,8 +1389,17 @@ void buildsorttable(char s) {
|
|||||||
|
|
||||||
if (ent->typ_len != 0) {
|
if (ent->typ_len != 0) {
|
||||||
|
|
||||||
|
if (callidx == 0) {
|
||||||
|
/* Build filelist[] on first call for each dir */
|
||||||
filelist[idx].blockidx = blkidx;
|
filelist[idx].blockidx = blkidx;
|
||||||
filelist[idx].entrynum = entry;
|
filelist[idx].entrynum = entry;
|
||||||
|
} else {
|
||||||
|
/* On subsequent calls Find existing entry in list and update it */
|
||||||
|
for (idx = 0; idx < numfiles; ++idx)
|
||||||
|
if ((filelist[idx].blockidx == blkidx) &&
|
||||||
|
(filelist[idx].entrynum == entry))
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (tolower(s)) {
|
switch (tolower(s)) {
|
||||||
case 'n':
|
case 'n':
|
||||||
case 'i':
|
case 'i':
|
||||||
@ -1421,6 +1434,7 @@ void buildsorttable(char s) {
|
|||||||
++blkidx;
|
++blkidx;
|
||||||
firstent = 1;
|
firstent = 1;
|
||||||
}
|
}
|
||||||
|
if (callidx == 0)
|
||||||
numfiles = idx;
|
numfiles = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1823,7 +1837,7 @@ void interactive(void) {
|
|||||||
|
|
||||||
doverbose = 1;
|
doverbose = 1;
|
||||||
|
|
||||||
puts("S O R T D I R v0.61 alpha Use ^ to return to previous question");
|
puts("S O R T D I R v0.62 alpha Use ^ to return to previous question");
|
||||||
|
|
||||||
q1:
|
q1:
|
||||||
fputs("\nEnter path (e.g.: /H1) of starting directory> ", stdout);
|
fputs("\nEnter path (e.g.: /H1) of starting directory> ", stdout);
|
||||||
@ -1953,7 +1967,7 @@ void processdir(uint device, uint blocknum) {
|
|||||||
for (i = 0; i < strlen(sortopts); ++i) {
|
for (i = 0; i < strlen(sortopts); ++i) {
|
||||||
if (doverbose)
|
if (doverbose)
|
||||||
printf("[%c] ", sortopts[i]);
|
printf("[%c] ", sortopts[i]);
|
||||||
buildsorttable(sortopts[i]);
|
buildsorttable(sortopts[i], i);
|
||||||
sortlist(sortopts[i]);
|
sortlist(sortopts[i]);
|
||||||
sortblocks(device);
|
sortblocks(device);
|
||||||
}
|
}
|
||||||
|
BIN
sortdir.po
BIN
sortdir.po
Binary file not shown.
Loading…
Reference in New Issue
Block a user