int EDirectory::FmChDir(const char *Name) { char Dir[256]; char CName[256] = ""; if (strcmp(Name, SSLASH) == 0) { JustRoot(Path, Dir, sizeof(Dir)); } else if (strcmp(Name, SDOT SDOT) == 0) { Slash(Path, 0); JustFileName(Path, CName, sizeof(CName)); JustDirectory(Path, Dir, sizeof(Dir)); } else { JustDirectory(Path, Dir, sizeof(Dir)); Slash(Dir, 1); strlcat(Dir, Name, sizeof(Dir)); } Slash(Dir, 1); free(Path); Path = strdup(Dir); Row = 0; RescanList(); if (CName[0] != 0) { for (int i = 0; i < FCount; i++) { if (filecmp(Files[i]->Name(), CName) == 0) { Row = i; break; } } } UpdateTitle(); return 1; }
int EList::ExecCommand(int Command, ExState &State) { int W = 1; int H = 1; if (View && View->MView && View->MView->Win) { View->MView->ConQuerySize(&W, &H); H--; } FixPos(); switch (Command) { case ExMoveLeft: return MoveLeft(); case ExMoveRight: return MoveRight(); case ExMoveUp: return MoveUp(); case ExMoveDown: return MoveDown(); case ExMovePageUp: return MovePageUp(); case ExMovePageDown: return MovePageDown(); case ExScrollLeft: return ScrollLeft(8); case ExScrollRight: return ScrollRight(8); case ExMovePageStart: return MovePageStart(); case ExMovePageEnd: return MovePageEnd(); case ExMoveFileStart: return MoveFileStart(); case ExMoveFileEnd: return MoveFileEnd(); case ExMoveLineStart: return MoveLineStart(); case ExMoveLineEnd: return MoveLineEnd(); case ExRescan: RescanList(); return ErOK; case ExActivate: return Activate(); case ExListMark: return Mark(); case ExListUnmark: return Unmark(); case ExListToggleMark: return ToggleMark(); case ExListMarkAll: return MarkAll(); case ExListUnmarkAll: return UnmarkAll(); case ExListToggleMarkAll: return ToggleMarkAll(); } return EModel::ExecCommand(Command, State); }
EDirectory::EDirectory(int createFlags, EModel **ARoot, char *aPath): EList(createFlags, ARoot, aPath) { char XPath[MAXPATH]; Files = 0; FCount = 0; SearchLen = 0; ExpandPath(aPath, XPath, sizeof(XPath)); Slash(XPath, 1); Path = strdup(XPath); RescanList(); }
int EDirectory::RescanDir() { char CName[256] = ""; if (Row >= 0 && Row < FCount) strcpy(CName, Files[Row]->Name()); Row = 0; RescanList(); if (CName[0] != 0) { for (int i = 0; i < FCount; i++) { if (filecmp(Files[i]->Name(), CName) == 0) { Row = i; break; } } } return 1; }