diff --git a/src/common/console/c_enginecmds.cpp b/src/common/console/c_enginecmds.cpp index 92b8cea53..6c914db66 100644 --- a/src/common/console/c_enginecmds.cpp +++ b/src/common/console/c_enginecmds.cpp @@ -176,81 +176,47 @@ UNSAFE_CCMD (crashout) #endif -// commented out because it's very poorly implemented (it should not abuse I_ChDir like this!) -#if 0 UNSAFE_CCMD (dir) { - FString dir, path; - const char *match; - findstate_t c_file; - void *file; - - FString curdir = I_GetCWD(); - if (curdir.IsEmpty()) - { - Printf ("Current path too long\n"); - return; - } + FString path; if (argv.argc() > 1) { path = NicePath(argv[1]); - if (!I_ChDir(path)) - { - match = path; - dir = ExtractFilePath(path); - if (dir[0] != '\0') - { - match += dir.Len(); - } - else - { - dir = "./"; - } - if (match[0] == '\0') - { - match = "*"; - } - if (!I_ChDir(dir)) - { - Printf ("%s not found\n", dir.GetChars()); - return; - } - } - else - { - match = "*"; - dir = path; - } } else { - match = "*"; - dir = curdir; + path = I_GetCWD();; } - if (dir[dir.Len()-1] != '/') + auto base = ExtractFileBase(path, true); + FString bpath; + if (base.IndexOfAny("*?") >= 0) { - dir += '/'; + bpath = ExtractFilePath(path); } - - if ( (file = I_FindFirst (match, &c_file)) == ((void *)(-1))) - Printf ("Nothing matching %s%s\n", dir.GetChars(), match); else { - Printf ("Listing of %s%s:\n", dir.GetChars(), match); - do - { - if (I_FindAttr (&c_file) & FA_DIREC) - Printf (PRINT_BOLD, "%s