|
1 // cat.h |
|
2 // |
|
3 // Copyright (c) 2005 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <fshell/ioutils.h> |
|
14 #include "file_reader.h" |
|
15 #include "character_converter.h" |
|
16 #include <fshell/descriptorutils.h> |
|
17 |
|
18 using namespace IoUtils; |
|
19 |
|
20 class CCmdCat : public CCommandBase, public MFileReaderObserver |
|
21 { |
|
22 public: |
|
23 static CCommandBase* NewLC(); |
|
24 ~CCmdCat(); |
|
25 private: |
|
26 CCmdCat(); |
|
27 void ConstructL(); |
|
28 void ReadNextFile(); |
|
29 void RemoveCurrentFileName(); |
|
30 void WriteChunkToConsoleL(const TDesC8& aData, TReadType aType); |
|
31 private: // From CCommandBase. |
|
32 virtual const TDesC& Name() const; |
|
33 virtual void DoRunL(); |
|
34 virtual void OptionsL(RCommandOptionList& aOptions); |
|
35 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
36 private: // From MFileReaderObserver. |
|
37 virtual CCommandBase& Command(); |
|
38 virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue); |
|
39 virtual void HandleFileReadError(TInt aError); |
|
40 private: |
|
41 RArray<TFileName2> iFiles; |
|
42 CCharacterConverter* iCharacterConverter; |
|
43 CFileReader* iFileReader; |
|
44 TBool iForce; |
|
45 TBool iBinary; |
|
46 LtkUtils::RLtkBuf16 iBuf16; |
|
47 enum TEncoding |
|
48 { |
|
49 EAuto, |
|
50 EBinary, |
|
51 EUtf8, |
|
52 ELatin1, |
|
53 ELtkUtf8, |
|
54 }; |
|
55 TEncoding iEncoding; |
|
56 TInt iBlockSize; |
|
57 }; |