sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #include "POSIXIF.H" sl@0: #include sl@0: #include sl@0: sl@0: #ifdef __WINS__ sl@0: sl@0: // Largely default STDLIB file descriptor for accessing Win32 streams sl@0: // We could in principle widen the RWin32Stream interface to allow for sl@0: // things like stat, but that can wait until it seems to be necessary! sl@0: sl@0: class CW32StreamDesc : public CFileDescBase sl@0: { sl@0: public: sl@0: TInt Attach(TInt aStream); sl@0: virtual void Read(TDes8& aDesc, TRequestStatus& aStatus); sl@0: virtual void Write(TDes8& aDesc, TRequestStatus& aStatus); sl@0: virtual void Flush(TRequestStatus& aStatus); sl@0: protected: sl@0: virtual TInt FinalClose(); sl@0: private: sl@0: RWin32Stream iStream; sl@0: }; sl@0: sl@0: TInt CW32StreamDesc::Attach(TInt aStream) sl@0: { sl@0: return iStream.Open(aStream); sl@0: } sl@0: sl@0: void CW32StreamDesc::Read(TDes8& aDesc, TRequestStatus& aStatus) sl@0: { sl@0: iStream.Read(aStatus, aDesc); sl@0: } sl@0: sl@0: void CW32StreamDesc::Write(TDes8& aDesc, TRequestStatus& aStatus) sl@0: { sl@0: iStream.Write(aStatus, aDesc); sl@0: } sl@0: sl@0: void CW32StreamDesc::Flush(TRequestStatus& aStatus) sl@0: { sl@0: iStream.Flush(aStatus); sl@0: } sl@0: sl@0: TInt CW32StreamDesc::FinalClose() sl@0: { sl@0: iStream.Close(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: #endif sl@0: sl@0: void CPosixServer::DefaultConsoleL() sl@0: { sl@0: #ifdef __WINS__ sl@0: // Try to attach Win32 stdin/stdout/stderr sl@0: TInt i; sl@0: for (i=0; i<3; i++) sl@0: { sl@0: CW32StreamDesc* stream=new(ELeave) CW32StreamDesc; sl@0: if (stream->Attach(i)==KErrNone) sl@0: iFids.Attach(i, stream); sl@0: else sl@0: delete stream; sl@0: } sl@0: #endif sl@0: // set up default fids sl@0: CRedirDesc* redirector = new(ELeave) CRedirDesc; sl@0: // redirector->Connect(); sl@0: iFids.Default(redirector); sl@0: redirector->Close(); sl@0: } sl@0: sl@0: