www.pudn.com > Ftpwork > LocalHdr.cpp
/***************************************************************************
LocalHdr.cpp - description
-------------------
begin : Mon Nov 11 2002
copyright : (C) 2002 by Wang jiangong
email : sduwangjiangong@hotmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "LocalHdr.h"
#include
#include
#include
#include
LocalHdr::LocalHdr(){
}
LocalHdr::~LocalHdr(){
}
/** No descriptions */
void LocalHdr::LocalCommand(Monitor * pmonitor){
char tempbuf[512];
String command;
CmdParseResult *presult;
while(1)
{
getcwd(tempbuf,512);
pmonitor->Display("\n[Local ");
pmonitor->Display(tempbuf);
pmonitor->Display("] ");
fgets(tempbuf, 512, stdin);
//replace last \n with \0
tempbuf[strlen(tempbuf)-1] = '\0';
command=tempbuf;
presult= cmdparserobj.ParseCommand(&command);
switch(presult->GetCmdType())
{
case CMD_CD:
if(chdir(presult->GetCmdArgv(0)->buffer())==-1)
{
pmonitor->Display("No such directory!\n");
}
break;
case CMD_MD:
if(mkdir(presult->GetCmdArgv(0)->buffer(),S_IRWXU | S_IRWXG )==-1)
{
pmonitor->Display("Can not create the directory!\n");
}
break;
case CMD_LIST:
system("ls --color=auto");
break;
case CMD_RETURN:
return;
}
}
}