/** @internalComponent */ void CPreModifierPlugin::FsFileWriteL(TFsPluginRequest& aRequest) { TInt err = KErrNone; TInt length = 0; TInt64 pos = 0; TFileName filename; TParse parse; TBuf<256> testfilename1; TBuf<256> testfilename2; //setting up test files testfilename1.Append(iDriveToTest); testfilename1.Append(_L(":\\Data\\test.txt")); testfilename2.Append(iDriveToTest); testfilename2.Append(_L(":\\Data\\createcreate3.txt")); err = aRequest.FileName(filename); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::ELength, length); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::EPosition, pos); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL parse.Set(filename, NULL, NULL); _LOG4(_L("CPreModifierPlugin::FsFileWriteL, file: %S, pos: %d, length: %d"), &filename, pos, length); if (aRequest.IsPostOperation()) { _LOG(_L("CPreModifierPlugin::FsFileWriteL, post intercept")); } else { User::Invariant(); } }
void CPreModifierPlugin::FsDirReadOneL(TFsPluginRequest& aRequest) { TFileName name; TInt err = aRequest.FileName(name); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL if (aRequest.IsPostOperation()) { _LOG(_L("CPreModifierPlugin::FsDirReadOneL, post intercept")); } else { User::Invariant(); } }
/** @internalComponent */ void CPreModifierPlugin::FsFileUnLockL(TFsPluginRequest& aRequest) { TInt length = 0; TInt64 pos = 0; TFileName filename; TParse parse; TInt err = aRequest.FileName(filename); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::ELength, length); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::EPosition, pos); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL parse.Set(filename, NULL, NULL); //TPtrC extension(parse.Ext()); _LOG4(_L("CPreModifierPlugin::FsFileUnLockL, file: %S, pos: %d, length: %d"), &filename, pos, length); if (aRequest.IsPostOperation()) { _LOG(_L("CPreModifierPlugin::FsFileUnLockL, post intercept")); } else { User::Invariant(); } }
/** @internalComponent */ void CPreModifierPlugin::FsFileSetSizeL(TFsPluginRequest& aRequest) { TFileName filename; TParse parse; TInt err = aRequest.FileName(filename); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL parse.Set(filename, NULL, NULL); _LOG2(_L("CPreModifierPlugin::FsFileSetSizeL, file: %S"), &filename); if (aRequest.IsPostOperation()) { _LOG(_L("CPreModifierPlugin::FsFileSetSizeL, post intercept")); } else { User::Invariant(); } }
/*Test to ensure that when a file has been opened for exclusive access, * i.e. readonly, that froma plugin we can still read from it */ TInt CExclusiveAccessPlugin::FsFileReadL(TFsPluginRequest& aRequest) { if(!aRequest.IsPostOperation()) // pre-operation { RFilePlugin file(aRequest); TInt err = file.AdoptFromClient(); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; TInt64 pos; err = aRequest.Read(TFsPluginRequest::EPosition, pos); // get pos iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; TInt length; err = aRequest.Read(TFsPluginRequest::ELength, length); //get length iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; if(length>265) length=256; //we should check that this file is in fact registered as read only? //if not.. User::Invariant()? TEntry entry; RFsPlugin rfsplugin(aRequest); err = rfsplugin.Connect(); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; TFileName fileName; err = aRequest.FileName(fileName); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; err = rfsplugin.Entry(fileName, entry); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; //can we read a readonly file? - should be fine. TBuf8<256> data; err = file.Read(pos,data,length); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) return err; file.Close(); rfsplugin.Close(); } return KErrNone; }
/** @internalComponent */ void CPreModifierPlugin::FsFileLockL(TFsPluginRequest& aRequest) { TInt length = 0; TInt64 pos = 0; TFileName filename; TParse parse; TInt err = aRequest.FileName(filename); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::ELength, length); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::EPosition, pos); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL parse.Set(filename, NULL, NULL); TPtrC extension(parse.Ext()); _LOG4(_L("CPreModifierPlugin::FsFileLockL, file: %S, pos: %d, length: %d"), &filename, pos, length); if (aRequest.IsPostOperation()) { _LOG(_L("CPreModifierPlugin::FsFileLockL, post intercept")); // Request read from post interception if (extension.CompareF(_L(".lockread")) == 0) { length = 10; HBufC8* tempBuf = HBufC8::NewMaxLC(length); TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length); _LOG(_L("CPreModifierPlugin::FsFileLockL , calling AdoptFromClient in post intercept")); RFilePlugin fileplugin(aRequest); TInt err = fileplugin.AdoptFromClient(); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL _LOG2(_L("CPreModifierPlugin::FsFileLockL, Adopt returned %d"), err); err = fileplugin.Read(pos, tempBufPtr, length); _LOG2(_L("CPreModifierPlugin::FsFileLockL, FileRead returned %d"), err); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL fileplugin.Close(); CleanupStack::PopAndDestroy(); } // Request close from post interception if(extension.CompareF(_L(".lockclose")) == 0) { _LOG(_L("CPreModifierPlugin::FsFileLockL, file = *.lockclose post intercept ")); RFilePlugin fileplugin(aRequest); TInt err = fileplugin.AdoptFromClient(); _LOG2(_L("CPreModifierPlugin::FsFileLockL ,Open %d"), err); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL fileplugin.Close(); _LOG(_L("CPreModifierPlugin::FsFileLockL, Close")); } } else { User::Invariant(); } }
/** @internalComponent */ void CStacked3Plugin::FsFileWriteL(TFsPluginRequest& aRequest) { TInt length = 0; TInt64 pos = 0; TFileName filename; TParse parse; TInt err = aRequest.FileName(filename); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::ELength, length); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::EPosition, pos); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL parse.Set(filename, NULL, NULL); _LOG4(_L("CStacked3Plugin::FsFileWriteL, file: %S, pos: %d, length: %d"), &filename, pos, length); if (aRequest.IsPostOperation()) { _LOG(_L("CStacked3Plugin::FsFileWriteL, post intercept")); } else { _LOG(_L("CStacked3Plugin::FsFileWriteL, pre intercept")); //set up test data for plugin TBuf8<20> wbuffer; wbuffer.Copy(_L8("HELLO WORLD SYMBIAN")); TInt length = wbuffer.Length(); HBufC8* tempBuf = HBufC8::NewMaxLC(length); TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length); RFilePlugin fileplugin(aRequest); err = fileplugin.AdoptFromClient(); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL //write to file err = fileplugin.Write(pos, wbuffer); _LOG2(_L("CStacked3Plugin::FsFileWriteL, RFilePlugin::Write returned %d"), err); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL //read from file err = fileplugin.Read(pos, tempBufPtr); _LOG2(_L("CStackedPlugin::FsFileWriteL, RFilePlugin::Read returned %d"), err); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL //testing the correct thing has been written to the drive err = wbuffer.Compare(tempBufPtr); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL fileplugin.Close(); CleanupStack::PopAndDestroy(); // send request down the stack User::Leave(KErrCompletion); } }