Add new thing to cd.
Make cd pr* working
Modified: trunk/reactos/subsys/system/cmd/internal.c
_____
Modified: trunk/reactos/subsys/system/cmd/internal.c
--- trunk/reactos/subsys/system/cmd/internal.c 2005-05-20 10:55:55 UTC
(rev 15431)
+++ trunk/reactos/subsys/system/cmd/internal.c 2005-05-20 12:55:09 UTC
(rev 15432)
@@ -157,6 +157,11 @@
LPTSTR dir; /* pointer to the directory to change to
*/
LPTSTR lpOldPath;
size_t size, str_len;
+ WIN32_FIND_DATA FileData;
+ HANDLE hSearch;
+ DWORD dwAttrs;
+ BOOL fFinished = FALSE;
+
/*Should we better declare a variable containing _tsclen(dir) ?
It's used a few times,
but on the other hand paths are generally not very long*/
@@ -242,6 +247,49 @@
if (!SetCurrentDirectory (dir))
{
+
+ hSearch = FindFirstFile(dir, &FileData);
+ if (hSearch == INVALID_HANDLE_VALUE)
+ {
+ ConOutFormatMessage(GetLastError());
+ free (lpOldPath);
+ lpOldPath = NULL;
+ return 1;
+ }
+
+
+ while (!fFinished)
+ {
+ dwAttrs = GetFileAttributes(FileData.cFileName);
+#ifdef _DEBUG
+ DebugPrintf(_T("Search found folder
:%s\n"),FileData.cFileName);
+#endif
+ if ((dwAttrs & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ FindClose(hSearch);
+ // change folder
+ if (!SetCurrentDirectory (FileData.cFileName))
+ {
+ ConOutFormatMessage(GetLastError());
+ free (lpOldPath);
+ lpOldPath = NULL;
+ return 1;
+ }
+
+
+ return 0;
+ }
+
+ else if (!FindNextFile(hSearch, &FileData))
+ {
+ FindClose(hSearch);
+ ConOutFormatMessage(GetLastError());
+ free (lpOldPath);
+ lpOldPath = NULL;
+ return 1;
+ }
+ }
+
//ErrorMessage (GetLastError(), _T("CD"));
ConOutFormatMessage(GetLastError());
Show replies by date