3490 } |
3490 } |
3491 |
3491 |
3492 CCmdSource::~CCmdSource() |
3492 CCmdSource::~CCmdSource() |
3493 { |
3493 { |
3494 delete iArgs; |
3494 delete iArgs; |
3495 delete iScriptData; |
|
3496 delete iParser; |
3495 delete iParser; |
|
3496 if (iCloseScriptHandle) |
|
3497 { |
|
3498 iScriptHandle.Close(); |
|
3499 } |
3497 } |
3500 } |
3498 |
3501 |
3499 CCmdSource::CCmdSource() : CCommandBase(EManualComplete) |
3502 CCmdSource::CCmdSource() : CCommandBase(EManualComplete) |
3500 { |
3503 { |
3501 } |
3504 } |
3502 |
3505 |
3503 void CCmdSource::DoRunL() |
3506 void CCmdSource::DoRunL() |
3504 { |
3507 { |
3505 TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr()); |
3508 TBool abort(EFalse); |
3506 TBool helpPrinted; |
3509 |
3507 iScriptData = CShell::ReadScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted); |
3510 if (iFileName.Length() > 0) |
3508 |
3511 { |
3509 if (helpPrinted) |
3512 TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr()); |
|
3513 iScriptHandle = CShell::OpenScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, abort); |
|
3514 iCloseScriptHandle = ETrue; |
|
3515 } |
|
3516 else |
|
3517 { |
|
3518 iScriptHandle = Stdin(); |
|
3519 Env().SetLocalL(KScriptName); |
|
3520 Env().SetLocalL(KScriptPath); |
|
3521 Env().SetLocalL(KScriptLine); |
|
3522 Env().SetLocalL(_L("0")); |
|
3523 _LIT(KStdin, "STDIN"); |
|
3524 Env().SetL(KScriptName, KStdin); |
|
3525 Env().SetL(KScriptPath, KNullDesC); |
|
3526 Env().SetL(_L("0"), KStdin); |
|
3527 } |
|
3528 |
|
3529 if (abort) |
3510 { |
3530 { |
3511 Complete(); |
3531 Complete(); |
3512 } |
3532 } |
3513 else |
3533 else |
3514 { |
3534 { |
3515 TUint mode = CParser::EExportLineNumbers; |
3535 TUint mode = CParser::EExportLineNumbers; |
3516 if (iKeepGoing) |
3536 if (iKeepGoing) |
3517 { |
3537 { |
3518 mode |= CParser::EKeepGoing; |
3538 mode |= CParser::EKeepGoing; |
3519 } |
3539 } |
3520 iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this); |
3540 iParser = CParser::NewL(mode, iScriptHandle, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this); |
3521 iParser->Start(); |
3541 iParser->Start(); |
3522 } |
3542 } |
3523 } |
3543 } |
3524 |
3544 |
3525 const TDesC& CCmdSource::Name() const |
3545 const TDesC& CCmdSource::Name() const |
4038 return self; |
4058 return self; |
4039 } |
4059 } |
4040 |
4060 |
4041 CCmdDebug::~CCmdDebug() |
4061 CCmdDebug::~CCmdDebug() |
4042 { |
4062 { |
4043 delete iScriptData; |
|
4044 delete iParser; |
4063 delete iParser; |
4045 delete iArgs; |
4064 delete iArgs; |
|
4065 iScriptHandle.Close(); |
4046 } |
4066 } |
4047 |
4067 |
4048 CCmdDebug::CCmdDebug() : CCommandBase(EManualComplete) |
4068 CCmdDebug::CCmdDebug() : CCommandBase(EManualComplete) |
4049 { |
4069 { |
4050 } |
4070 } |
4051 |
4071 |
4052 void CCmdDebug::DoRunL() |
4072 void CCmdDebug::DoRunL() |
4053 { |
4073 { |
4054 TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr()); |
4074 TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr()); |
4055 TBool helpPrinted; |
4075 TBool helpPrinted; |
4056 iScriptData = CShell::ReadScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted); |
4076 iScriptHandle = CShell::OpenScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted); |
4057 if (helpPrinted) |
4077 if (helpPrinted) |
4058 { |
4078 { |
4059 Complete(); |
4079 Complete(); |
4060 } |
4080 } |
4061 else |
4081 else |
4063 TUint mode = CParser::EDebug | CParser::EExportLineNumbers; |
4083 TUint mode = CParser::EDebug | CParser::EExportLineNumbers; |
4064 if (iKeepGoing) |
4084 if (iKeepGoing) |
4065 { |
4085 { |
4066 mode |= CParser::EKeepGoing; |
4086 mode |= CParser::EKeepGoing; |
4067 } |
4087 } |
4068 iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this); |
4088 iParser = CParser::NewL(mode, iScriptHandle, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this); |
4069 iParser->Start(); |
4089 iParser->Start(); |
4070 } |
4090 } |
4071 } |
4091 } |
4072 |
4092 |
4073 const TDesC& CCmdDebug::Name() const |
4093 const TDesC& CCmdDebug::Name() const |
6103 extraArgs.AppendL(fileName.AllocLC()); |
6122 extraArgs.AppendL(fileName.AllocLC()); |
6104 CleanupStack::Pop(); // hbufc |
6123 CleanupStack::Pop(); // hbufc |
6105 |
6124 |
6106 TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr()); |
6125 TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr()); |
6107 TBool helpPrinted; |
6126 TBool helpPrinted; |
6108 iScriptData = CShell::ReadScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted, &extraArgs); |
6127 iScriptHandle = CShell::OpenScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted, &extraArgs); |
6109 CleanupStack::PopAndDestroy(&extraArgs); |
6128 CleanupStack::PopAndDestroy(&extraArgs); |
6110 if (helpPrinted) |
6129 if (helpPrinted) |
6111 { |
6130 { |
6112 Complete(); |
6131 Complete(); |
6113 } |
6132 } |
6116 TUint mode = CParser::EExportLineNumbers; |
6135 TUint mode = CParser::EExportLineNumbers; |
6117 if (iKeepGoing) |
6136 if (iKeepGoing) |
6118 { |
6137 { |
6119 mode |= CParser::EKeepGoing; |
6138 mode |= CParser::EKeepGoing; |
6120 } |
6139 } |
6121 iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this); |
6140 iParser = CParser::NewL(mode, iScriptHandle, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this); |
6122 iParser->Start(); |
6141 iParser->Start(); |
6123 } |
6142 } |
6124 } |
6143 } |
6125 } |
6144 } |
6126 |
6145 |
6136 if (!iDirName.IsDirL(FsL())) |
6155 if (!iDirName.IsDirL(FsL())) |
6137 { |
6156 { |
6138 LeaveIfErr(KErrArgument, _L("'%S' is not a directory"), &iDirName); |
6157 LeaveIfErr(KErrArgument, _L("'%S' is not a directory"), &iDirName); |
6139 } |
6158 } |
6140 LeaveIfErr(iDir.Open(FsL(), iDirName, KEntryAttNormal | KEntryAttDir), _L("Couldn't open directory '%S'"), &iDirName); |
6159 LeaveIfErr(iDir.Open(FsL(), iDirName, KEntryAttNormal | KEntryAttDir), _L("Couldn't open directory '%S'"), &iDirName); |
|
6160 |
|
6161 if (iFileName.Length() == 0) |
|
6162 { |
|
6163 LeaveIfErr(KErrArgument, _L("Invalid script file name")); |
|
6164 } |
6141 |
6165 |
6142 DoNextL(ETrue); |
6166 DoNextL(ETrue); |
6143 } |
6167 } |
6144 |
6168 |
6145 void CCmdForEach::ArgumentsL(RCommandArgumentList& aArguments) |
6169 void CCmdForEach::ArgumentsL(RCommandArgumentList& aArguments) |