stringlistinit(&list);
listdirectory(&list, "", dir);
- stringlistsort(&list);
+ stringlistsort(&list, false);
// add any PAK package in the directory
for (i = 0;i < list.numstrings;i++)
stringlistinit(&list);
listdirectory(&list, va("%s/", fs_basedir), "");
listdirectory(&list, va("%s/", fs_userdir), "");
- stringlistsort(&list);
+ stringlistsort(&list, false);
stringlistinit(&list2);
for(i = 0; i < list.numstrings; ++i)
#ifdef DP_FS_BASEDIR
strlcpy(fs_basedir, DP_FS_BASEDIR, sizeof(fs_basedir));
#elif defined(MACOSX)
- // FIXME: is there a better way to find the directory outside the .app?
- // FIXME: check if game data is inside .app bundle
+ // FIXME: is there a better way to find the directory outside the .app, without using Objective-C?
if (strstr(com_argv[0], ".app/"))
{
char *split;
split = strstr(fs_basedir, ".app/");
if (split)
{
- while (split > fs_basedir && *split != '/')
- split--;
- *split = 0;
+ struct stat statresult;
+ // truncate to just after the .app/
+ split[5] = 0;
+ // see if gamedir exists in Resources
+ if (stat(va("%s/Contents/Resources/%s", fs_basedir, gamedirname1), &statresult) == 0)
+ {
+ // found gamedir inside Resources, use it
+ strlcat(fs_basedir, "Contents/Resources/", sizeof(fs_basedir));
+ }
+ else
+ {
+ // no gamedir found in Resources, gamedir is probably
+ // outside the .app, remove .app part of path
+ while (split > fs_basedir && *split != '/')
+ split--;
+ *split = 0;
+ }
}
}
#endif
if (resultlist.numstrings)
{
- stringlistsort(&resultlist);
+ stringlistsort(&resultlist, true);
numfiles = resultlist.numstrings;
numchars = 0;
for (resultlistindex = 0;resultlistindex < resultlist.numstrings;resultlistindex++)
static void FS_ListDirectoryCmd (const char* cmdname, int oneperline)
{
const char *pattern;
- if (Cmd_Argc() > 3)
+ if (Cmd_Argc() >= 3)
{
Con_Printf("usage:\n%s [path/pattern]\n", cmdname);
return;