--- a/src/fios.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/fios.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -57,7 +57,7 @@
/**
* Compare two FiosItem's. Used with qsort when sorting the file list.
* @param a A pointer to the first FiosItem to compare.
- * @param a A pointer to the second FiosItem to compare.
+ * @param b A pointer to the second FiosItem to compare.
* @return -1, 0 or 1, depending on how the two items should be sorted.
*/
int CDECL compare_FiosItems(const void *a, const void *b)
@@ -114,10 +114,12 @@
case FIOS_TYPE_PARENT:
/* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */
- if ((s = strrchr(path, PATHSEPCHAR)) != NULL) {
- s[1] = '\0'; // go up a directory
- if (!FiosIsRoot(path)) s[0] = '\0';
+ s = strrchr(path, PATHSEPCHAR);
+ if (s != NULL && s != path) {
+ s[0] = '\0'; // Remove last path separator character, so we can go up one level.
}
+ s = strrchr(path, PATHSEPCHAR);
+ if (s != NULL) s[1] = '\0'; // go up a directory
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
else if ((s = strrchr(path, ':')) != NULL) s[1] = '\0';
@@ -125,14 +127,12 @@
break;
case FIOS_TYPE_DIR:
- if (!FiosIsRoot(path)) strcat(path, PATHSEP);
strcat(path, item->name);
+ strcat(path, PATHSEP);
break;
case FIOS_TYPE_DIRECT:
- sprintf(path, "%s" PATHSEP, item->name);
- s = strrchr(path, PATHSEPCHAR);
- if (s != NULL && s[1] == '\0') s[0] = '\0'; // strip trailing slash
+ sprintf(path, "%s", item->name);
break;
case FIOS_TYPE_FILE:
@@ -150,7 +150,7 @@
snprintf(str_buffr, lengthof(str_buffr), "%s:%s", path, item->name);
} else // XXX - only next line!
#endif
- snprintf(str_buffr, lengthof(str_buffr), "%s" PATHSEP "%s", path, item->name);
+ snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name);
return str_buffr;
}
@@ -200,9 +200,8 @@
typedef byte fios_getlist_callback_proc(int mode, const char *filename, const char *ext, char *title);
/** Create a list of the files in a directory, according to some arbitrary rule.
- * @param num Will be filled with the amount of items.
* @param mode The mode we are in. Some modes don't allow 'parent'.
- * @param callback The function that is called where you need to do the filtering.
+ * @param callback_proc The function that is called where you need to do the filtering.
* @return Return the list of files. */
static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_proc)
{