|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #include "POSIXIF.H" |
|
18 #include <estw32.h> |
|
19 #include <redircli.h> |
|
20 |
|
21 #ifdef __WINS__ |
|
22 |
|
23 // Largely default STDLIB file descriptor for accessing Win32 streams |
|
24 // We could in principle widen the RWin32Stream interface to allow for |
|
25 // things like stat, but that can wait until it seems to be necessary! |
|
26 |
|
27 class CW32StreamDesc : public CFileDescBase |
|
28 { |
|
29 public: |
|
30 TInt Attach(TInt aStream); |
|
31 virtual void Read(TDes8& aDesc, TRequestStatus& aStatus); |
|
32 virtual void Write(TDes8& aDesc, TRequestStatus& aStatus); |
|
33 virtual void Flush(TRequestStatus& aStatus); |
|
34 protected: |
|
35 virtual TInt FinalClose(); |
|
36 private: |
|
37 RWin32Stream iStream; |
|
38 }; |
|
39 |
|
40 TInt CW32StreamDesc::Attach(TInt aStream) |
|
41 { |
|
42 return iStream.Open(aStream); |
|
43 } |
|
44 |
|
45 void CW32StreamDesc::Read(TDes8& aDesc, TRequestStatus& aStatus) |
|
46 { |
|
47 iStream.Read(aStatus, aDesc); |
|
48 } |
|
49 |
|
50 void CW32StreamDesc::Write(TDes8& aDesc, TRequestStatus& aStatus) |
|
51 { |
|
52 iStream.Write(aStatus, aDesc); |
|
53 } |
|
54 |
|
55 void CW32StreamDesc::Flush(TRequestStatus& aStatus) |
|
56 { |
|
57 iStream.Flush(aStatus); |
|
58 } |
|
59 |
|
60 TInt CW32StreamDesc::FinalClose() |
|
61 { |
|
62 iStream.Close(); |
|
63 return KErrNone; |
|
64 } |
|
65 |
|
66 #endif |
|
67 |
|
68 void CPosixServer::DefaultConsoleL() |
|
69 { |
|
70 #ifdef __WINS__ |
|
71 // Try to attach Win32 stdin/stdout/stderr |
|
72 TInt i; |
|
73 for (i=0; i<3; i++) |
|
74 { |
|
75 CW32StreamDesc* stream=new(ELeave) CW32StreamDesc; |
|
76 if (stream->Attach(i)==KErrNone) |
|
77 iFids.Attach(i, stream); |
|
78 else |
|
79 delete stream; |
|
80 } |
|
81 #endif |
|
82 // set up default fids |
|
83 CRedirDesc* redirector = new(ELeave) CRedirDesc; |
|
84 // redirector->Connect(); |
|
85 iFids.Default(redirector); |
|
86 redirector->Close(); |
|
87 } |
|
88 |
|
89 |