1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/premodifier_plugin.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1363 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// modifier_plugin.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "premodifier_plugin.h"
1.22 +#include "plugincommon.h"
1.23 +
1.24 +/**
1.25 +Leaving New function for the plugin
1.26 +@internalComponent
1.27 +*/
1.28 +CPreModifierPlugin* CPreModifierPlugin::NewL()
1.29 + {
1.30 + CPreModifierPlugin* self = new(ELeave) CPreModifierPlugin;
1.31 + CleanupStack::PushL(self);
1.32 + self->ConstructL();
1.33 + CleanupStack::Pop();
1.34 + return self;
1.35 + }
1.36 +
1.37 +
1.38 +/**
1.39 +Constructor for the plugin
1.40 +@internalComponent
1.41 +*/
1.42 +CPreModifierPlugin::CPreModifierPlugin() : iInterceptsEnabled(EFalse),
1.43 + iLogging(ETrue)
1.44 + {
1.45 + }
1.46 +
1.47 +
1.48 +void CPreModifierPlugin::ConstructL()
1.49 + {
1.50 + }
1.51 +
1.52 +/**
1.53 +The destructor for the plugin
1.54 +@internalComponent
1.55 +*/
1.56 +CPreModifierPlugin::~CPreModifierPlugin()
1.57 + {
1.58 + }
1.59 +
1.60 +/**
1.61 +Initialise the plugin.
1.62 +@internalComponent
1.63 +*/
1.64 +void CPreModifierPlugin::InitialiseL()
1.65 + {
1.66 + EnableInterceptsL();
1.67 + }
1.68 +
1.69 +/**
1.70 +Enable the plugin's intercepts.
1.71 +@internalComponent
1.72 +*/
1.73 +void CPreModifierPlugin::EnableInterceptsL()
1.74 + {
1.75 + if (iInterceptsEnabled) return;
1.76 +
1.77 + User::LeaveIfError(RegisterIntercept(EFsFileRead, EPostIntercept));
1.78 + User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPostIntercept));
1.79 + User::LeaveIfError(RegisterIntercept(EFsFileRename, EPostIntercept));
1.80 + User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPostIntercept));
1.81 + User::LeaveIfError(RegisterIntercept(EFsFileSize, EPostIntercept));
1.82 + User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPostIntercept));
1.83 + User::LeaveIfError(RegisterIntercept(EFsFileLock, EPostIntercept));
1.84 + User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPostIntercept));
1.85 + User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPostIntercept));
1.86 + User::LeaveIfError(RegisterIntercept(EFsFileReplace, EPostIntercept));
1.87 + User::LeaveIfError(RegisterIntercept(EFsReadFileSection, EPostIntercept));
1.88 + User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPostIntercept));
1.89 + User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPostIntercept));
1.90 + User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPostIntercept));
1.91 + User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPostIntercept));
1.92 + User::LeaveIfError(RegisterIntercept(EFsFileTemp, EPostIntercept));
1.93 + User::LeaveIfError(RegisterIntercept(EFsDelete, EPostIntercept));
1.94 + User::LeaveIfError(RegisterIntercept(EFsReplace, EPostIntercept));
1.95 + User::LeaveIfError(RegisterIntercept(EFsRename, EPostIntercept));
1.96 + User::LeaveIfError(RegisterIntercept(EFsEntry, EPostIntercept));
1.97 + User::LeaveIfError(RegisterIntercept(EFsSetEntry, EPostIntercept));
1.98 + User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPostIntercept));
1.99 +
1.100 + _LOG(_L("Pre-Modifier Plugin: Enabled intercepts."));
1.101 +
1.102 + iInterceptsEnabled = ETrue;
1.103 + }
1.104 +
1.105 +/**
1.106 +Disable the plugin's intercepts.
1.107 +@internalComponent
1.108 +*/
1.109 +void CPreModifierPlugin::DisableInterceptsL()
1.110 + {
1.111 + if (!iInterceptsEnabled) return;
1.112 +
1.113 + User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPostIntercept));
1.114 + User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPostIntercept));
1.115 + User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPostIntercept));
1.116 + User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPostIntercept));
1.117 + User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPostIntercept));
1.118 + User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPostIntercept));
1.119 + User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPostIntercept));
1.120 + User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPostIntercept));
1.121 + User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPostIntercept));
1.122 + User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPostIntercept));
1.123 + User::LeaveIfError(UnregisterIntercept(EFsReadFileSection, EPostIntercept));
1.124 + User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPostIntercept));
1.125 + User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked, EPostIntercept));
1.126 + User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPostIntercept));
1.127 + User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPostIntercept));
1.128 + User::LeaveIfError(UnregisterIntercept(EFsFileTemp, EPostIntercept));
1.129 + User::LeaveIfError(UnregisterIntercept(EFsDelete, EPostIntercept));
1.130 + User::LeaveIfError(UnregisterIntercept(EFsReplace, EPostIntercept));
1.131 + User::LeaveIfError(UnregisterIntercept(EFsRename, EPostIntercept));
1.132 + User::LeaveIfError(UnregisterIntercept(EFsEntry, EPostIntercept));
1.133 + User::LeaveIfError(UnregisterIntercept(EFsSetEntry, EPostIntercept));
1.134 + User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPostIntercept));
1.135 +
1.136 + _LOG(_L("Pre-Modifier Plugin: Disabled intercepts."));
1.137 +
1.138 + iInterceptsEnabled = EFalse;
1.139 + }
1.140 +
1.141 +/**
1.142 +Handle requests
1.143 +@internalComponent
1.144 +*/
1.145 +TInt CPreModifierPlugin::DoRequestL(TFsPluginRequest& aRequest)
1.146 + {
1.147 + TInt err = KErrNone;
1.148 +
1.149 + TInt function = aRequest.Function();
1.150 +
1.151 + switch(function)
1.152 + {
1.153 + case EFsFileRead:
1.154 + TRAP(err, FsFileReadL(aRequest));
1.155 + break;
1.156 +
1.157 + case EFsFileWrite:
1.158 + TRAP(err, FsFileWriteL(aRequest));
1.159 + break;
1.160 +
1.161 + case EFsFileRename:
1.162 + TRAP(err, FsFileRenameL(aRequest));
1.163 + break;
1.164 +
1.165 + case EFsFileCreate:
1.166 + TRAP(err, FsFileCreateL(aRequest));
1.167 + break;
1.168 +
1.169 + case EFsFileSize:
1.170 + TRAP(err, FsFileSizeL(aRequest));
1.171 + break;
1.172 +
1.173 + case EFsFileSetSize:
1.174 + TRAP(err, FsFileSetSizeL(aRequest));
1.175 + break;
1.176 +
1.177 + case EFsFileLock:
1.178 + TRAP(err, FsFileLockL(aRequest));
1.179 + break;
1.180 +
1.181 + case EFsFileUnLock:
1.182 + TRAP(err, FsFileUnLockL(aRequest));
1.183 + break;
1.184 +
1.185 + case EFsFileSeek:
1.186 + TRAP(err, FsFileSeekL(aRequest));
1.187 + break;
1.188 +
1.189 + case EFsDirReadOne:
1.190 + TRAP(err,FsDirReadOneL(aRequest));
1.191 + break;
1.192 +
1.193 + case EFsDirReadPacked:
1.194 + TRAP(err,FsDirReadPackedL(aRequest));
1.195 + break;
1.196 +
1.197 + case EFsFileOpen:
1.198 + TRAP(err, FsFileOpenL(aRequest));
1.199 + break;
1.200 +
1.201 + case EFsFileReplace:
1.202 + TRAP(err, FsFileReplaceL(aRequest));
1.203 + break;
1.204 +
1.205 + case EFsReadFileSection:
1.206 + TRAP(err, FsReadFileSectionL(aRequest));
1.207 + break;
1.208 +
1.209 + case EFsFileSubClose:
1.210 + TRAP(err, FsFileSubCloseL(aRequest));
1.211 + break;
1.212 +
1.213 + case EFsDirOpen:
1.214 + TRAP(err, FsDirOpenL(aRequest));
1.215 + break;
1.216 +
1.217 + case EFsFileTemp:
1.218 + TRAP(err, FsFileTempL(aRequest));
1.219 + break;
1.220 +
1.221 + case EFsDelete:
1.222 + TRAP(err, FsDeleteL(aRequest));
1.223 + break;
1.224 +
1.225 + case EFsReplace:
1.226 + TRAP(err, FsReplaceL(aRequest));
1.227 + break;
1.228 +
1.229 + case EFsRename:
1.230 + TRAP(err, FsRenameL(aRequest));
1.231 + break;
1.232 +
1.233 + case EFsEntry:
1.234 + TRAP(err, FsEntryL(aRequest));
1.235 + break;
1.236 +
1.237 + case EFsSetEntry:
1.238 + TRAP(err, FsSetEntryL(aRequest));
1.239 + break;
1.240 +
1.241 + default:
1.242 + break;
1.243 + }
1.244 +
1.245 + return err;
1.246 + }
1.247 +
1.248 +
1.249 +/**
1.250 +@internalComponent
1.251 +*/
1.252 +void CPreModifierPlugin::FsFileUnLockL(TFsPluginRequest& aRequest)
1.253 + {
1.254 + TInt length = 0;
1.255 + TInt64 pos = 0;
1.256 + TFileName filename;
1.257 + TParse parse;
1.258 +
1.259 + TInt err = aRequest.FileName(filename);
1.260 + iLastError = err;
1.261 + iLineNumber = __LINE__;
1.262 + if(err!=KErrNone)
1.263 + User::Leave(err); //trapped in DoRequestL
1.264 +
1.265 + err = aRequest.Read(TFsPluginRequest::ELength, length);
1.266 + iLastError = err;
1.267 + iLineNumber = __LINE__;
1.268 + if(err!=KErrNone)
1.269 + User::Leave(err); //trapped in DoRequestL
1.270 +
1.271 + err = aRequest.Read(TFsPluginRequest::EPosition, pos);
1.272 + iLastError = err;
1.273 + iLineNumber = __LINE__;
1.274 + if(err!=KErrNone)
1.275 + User::Leave(err); //trapped in DoRequestL
1.276 +
1.277 + parse.Set(filename, NULL, NULL);
1.278 + //TPtrC extension(parse.Ext());
1.279 +
1.280 + _LOG4(_L("CPreModifierPlugin::FsFileUnLockL, file: %S, pos: %d, length: %d"), &filename, pos, length);
1.281 +
1.282 + if (aRequest.IsPostOperation())
1.283 + {
1.284 + _LOG(_L("CPreModifierPlugin::FsFileUnLockL, post intercept"));
1.285 + }
1.286 + else
1.287 + {
1.288 + User::Invariant();
1.289 + }
1.290 + }
1.291 +
1.292 +/**
1.293 +@internalComponent
1.294 +*/
1.295 +void CPreModifierPlugin::FsFileLockL(TFsPluginRequest& aRequest)
1.296 + {
1.297 + TInt length = 0;
1.298 + TInt64 pos = 0;
1.299 + TFileName filename;
1.300 + TParse parse;
1.301 +
1.302 + TInt err = aRequest.FileName(filename);
1.303 + iLastError = err;
1.304 + iLineNumber = __LINE__;
1.305 + if(err!=KErrNone)
1.306 + User::Leave(err); //trapped in DoRequestL
1.307 +
1.308 + err = aRequest.Read(TFsPluginRequest::ELength, length);
1.309 + iLastError = err;
1.310 + iLineNumber = __LINE__;
1.311 + if(err!=KErrNone)
1.312 + User::Leave(err); //trapped in DoRequestL
1.313 +
1.314 + err = aRequest.Read(TFsPluginRequest::EPosition, pos);
1.315 + iLastError = err;
1.316 + iLineNumber = __LINE__;
1.317 + if(err!=KErrNone)
1.318 + User::Leave(err); //trapped in DoRequestL
1.319 +
1.320 + parse.Set(filename, NULL, NULL);
1.321 + TPtrC extension(parse.Ext());
1.322 +
1.323 + _LOG4(_L("CPreModifierPlugin::FsFileLockL, file: %S, pos: %d, length: %d"), &filename, pos, length);
1.324 +
1.325 + if (aRequest.IsPostOperation())
1.326 + {
1.327 + _LOG(_L("CPreModifierPlugin::FsFileLockL, post intercept"));
1.328 +
1.329 + // Request read from post interception
1.330 + if (extension.CompareF(_L(".lockread")) == 0)
1.331 + {
1.332 + length = 10;
1.333 + HBufC8* tempBuf = HBufC8::NewMaxLC(length);
1.334 + TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
1.335 + _LOG(_L("CPreModifierPlugin::FsFileLockL , calling AdoptFromClient in post intercept"));
1.336 + RFilePlugin fileplugin(aRequest);
1.337 + TInt err = fileplugin.AdoptFromClient();
1.338 + iLastError = err;
1.339 + iLineNumber = __LINE__;
1.340 + if(err!=KErrNone)
1.341 + User::Leave(err); //trapped in DoRequestL
1.342 +
1.343 + _LOG2(_L("CPreModifierPlugin::FsFileLockL, Adopt returned %d"), err);
1.344 +
1.345 + err = fileplugin.Read(pos, tempBufPtr, length);
1.346 + _LOG2(_L("CPreModifierPlugin::FsFileLockL, FileRead returned %d"), err);
1.347 + iLastError = err;
1.348 + iLineNumber = __LINE__;
1.349 + if(err!=KErrNone)
1.350 + User::Leave(err); //trapped in DoRequestL
1.351 + fileplugin.Close();
1.352 + CleanupStack::PopAndDestroy();
1.353 + }
1.354 +
1.355 + // Request close from post interception
1.356 + if(extension.CompareF(_L(".lockclose")) == 0)
1.357 + {
1.358 + _LOG(_L("CPreModifierPlugin::FsFileLockL, file = *.lockclose post intercept "));
1.359 + RFilePlugin fileplugin(aRequest);
1.360 + TInt err = fileplugin.AdoptFromClient();
1.361 + _LOG2(_L("CPreModifierPlugin::FsFileLockL ,Open %d"), err);
1.362 + iLastError = err;
1.363 + iLineNumber = __LINE__;
1.364 + if(err!=KErrNone)
1.365 + User::Leave(err); //trapped in DoRequestL
1.366 + fileplugin.Close();
1.367 + _LOG(_L("CPreModifierPlugin::FsFileLockL, Close"));
1.368 + }
1.369 +
1.370 + }
1.371 + else
1.372 + {
1.373 + User::Invariant();
1.374 + }
1.375 + }
1.376 +
1.377 +/**
1.378 +@internalComponent
1.379 +*/
1.380 +void CPreModifierPlugin::FsFileSeekL(TFsPluginRequest& aRequest)
1.381 + {
1.382 + TFileName filename;
1.383 + TParse parse;
1.384 +
1.385 + TInt err = aRequest.FileName(filename);
1.386 + iLastError = err;
1.387 + iLineNumber = __LINE__;
1.388 + if(err!=KErrNone)
1.389 + User::Leave(err); //trapped in DoRequestL
1.390 +
1.391 + parse.Set(filename, NULL, NULL);
1.392 +
1.393 + _LOG2(_L("CPreModifierPlugin::FsFileSeekL, file: %S"), &filename);
1.394 +
1.395 + if (aRequest.IsPostOperation())
1.396 + {
1.397 + _LOG(_L("CPreModifierPlugin::FsFileSeekL, post intercept"));
1.398 + }
1.399 + else
1.400 + {
1.401 + User::Invariant();
1.402 + }
1.403 + }
1.404 +
1.405 +/**
1.406 +@internalComponent
1.407 +*/
1.408 +void CPreModifierPlugin::FsFileSizeL(TFsPluginRequest& aRequest)
1.409 + {
1.410 + TFileName filename;
1.411 + TParse parse;
1.412 +
1.413 + TInt err = aRequest.FileName(filename);
1.414 + iLastError = err;
1.415 + iLineNumber = __LINE__;
1.416 + if(err!=KErrNone)
1.417 + User::Leave(err); //trapped in DoRequestL
1.418 +
1.419 + parse.Set(filename, NULL, NULL);
1.420 +
1.421 + _LOG2(_L("CPreModifierPlugin::FsFileSizeL, file: %S"), &filename);
1.422 +
1.423 + if (aRequest.IsPostOperation())
1.424 + {
1.425 + _LOG(_L("CPreModifierPlugin::FsFileSizeL, post intercept"));
1.426 + }
1.427 + else
1.428 + {
1.429 + User::Invariant();
1.430 + }
1.431 + }
1.432 +
1.433 +/**
1.434 +@internalComponent
1.435 +*/
1.436 +void CPreModifierPlugin::FsFileSetSizeL(TFsPluginRequest& aRequest)
1.437 + {
1.438 + TFileName filename;
1.439 + TParse parse;
1.440 +
1.441 + TInt err = aRequest.FileName(filename);
1.442 + iLastError = err;
1.443 + iLineNumber = __LINE__;
1.444 + if(err!=KErrNone)
1.445 + User::Leave(err); //trapped in DoRequestL
1.446 +
1.447 + parse.Set(filename, NULL, NULL);
1.448 +
1.449 + _LOG2(_L("CPreModifierPlugin::FsFileSetSizeL, file: %S"), &filename);
1.450 +
1.451 + if (aRequest.IsPostOperation())
1.452 + {
1.453 + _LOG(_L("CPreModifierPlugin::FsFileSetSizeL, post intercept"));
1.454 + }
1.455 + else
1.456 + {
1.457 + User::Invariant();
1.458 + }
1.459 + }
1.460 +
1.461 +/**
1.462 +@internalComponent
1.463 +*/
1.464 +void CPreModifierPlugin::FsFileReadL(TFsPluginRequest& aRequest)
1.465 + {
1.466 + TInt length = 0;
1.467 + TInt64 pos = 0;
1.468 + TFileName filename;
1.469 + TParse parse;
1.470 +
1.471 + TInt err = aRequest.FileName(filename);
1.472 + iLastError = err;
1.473 + iLineNumber = __LINE__;
1.474 + if(err!=KErrNone)
1.475 + User::Leave(err); //trapped in DoRequestL
1.476 +
1.477 + err = aRequest.Read(TFsPluginRequest::ELength, length);
1.478 + iLastError = err;
1.479 + iLineNumber = __LINE__;
1.480 + if(err!=KErrNone)
1.481 + User::Leave(err); //trapped in DoRequestL
1.482 +
1.483 + err = aRequest.Read(TFsPluginRequest::EPosition, pos);
1.484 + iLastError = err;
1.485 + iLineNumber = __LINE__;
1.486 + if(err!=KErrNone)
1.487 + User::Leave(err); //trapped in DoRequestL
1.488 +
1.489 + parse.Set(filename, NULL, NULL);
1.490 +
1.491 + _LOG4(_L("CPreModifierPlugin::FsFileReadL, file: %S, pos: %d, length: %d"), &filename, pos, length);
1.492 +
1.493 + if (aRequest.IsPostOperation())
1.494 + {
1.495 + _LOG(_L("CPreModifierPlugin::FsFileReadL, post intercept"));
1.496 + }
1.497 + else
1.498 + {
1.499 + User::Invariant();
1.500 + }
1.501 + }
1.502 +
1.503 +
1.504 +/**
1.505 +@internalComponent
1.506 +*/
1.507 +void CPreModifierPlugin::FsFileWriteL(TFsPluginRequest& aRequest)
1.508 + {
1.509 + TInt err = KErrNone;
1.510 + TInt length = 0;
1.511 + TInt64 pos = 0;
1.512 + TFileName filename;
1.513 + TParse parse;
1.514 +
1.515 + TBuf<256> testfilename1;
1.516 + TBuf<256> testfilename2;
1.517 +
1.518 + //setting up test files
1.519 + testfilename1.Append(iDriveToTest);
1.520 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.521 +
1.522 + testfilename2.Append(iDriveToTest);
1.523 + testfilename2.Append(_L(":\\Data\\createcreate3.txt"));
1.524 +
1.525 + err = aRequest.FileName(filename);
1.526 + iLastError = err;
1.527 + iLineNumber = __LINE__;
1.528 + if(err!=KErrNone)
1.529 + User::Leave(err); //trapped in DoRequestL
1.530 +
1.531 + err = aRequest.Read(TFsPluginRequest::ELength, length);
1.532 + iLastError = err;
1.533 + iLineNumber = __LINE__;
1.534 + if(err!=KErrNone)
1.535 + User::Leave(err); //trapped in DoRequestL
1.536 +
1.537 + err = aRequest.Read(TFsPluginRequest::EPosition, pos);
1.538 + iLastError = err;
1.539 + iLineNumber = __LINE__;
1.540 + if(err!=KErrNone)
1.541 + User::Leave(err); //trapped in DoRequestL
1.542 +
1.543 + parse.Set(filename, NULL, NULL);
1.544 +
1.545 + _LOG4(_L("CPreModifierPlugin::FsFileWriteL, file: %S, pos: %d, length: %d"), &filename, pos, length);
1.546 +
1.547 + if (aRequest.IsPostOperation())
1.548 + {
1.549 + _LOG(_L("CPreModifierPlugin::FsFileWriteL, post intercept"));
1.550 + }
1.551 + else
1.552 + {
1.553 + User::Invariant();
1.554 + }
1.555 + }
1.556 +
1.557 +
1.558 +
1.559 +/**
1.560 +@internalComponent
1.561 +*/
1.562 +void CPreModifierPlugin::FsFileRenameL(TFsPluginRequest& aRequest)
1.563 + {
1.564 + TFileName oldfilename, newfilename;
1.565 + TParse parse;
1.566 +
1.567 + oldfilename = aRequest.Src().FullName();
1.568 + newfilename = aRequest.Dest().FullName();
1.569 +
1.570 + parse.Set(oldfilename, NULL, NULL);
1.571 + TPtrC extension(parse.Ext());
1.572 +
1.573 + _LOG3(_L("CPreModifierPlugin::FsFileRenameL, old name: %S, new name: %S"), &oldfilename, &newfilename);
1.574 +
1.575 + if (aRequest.IsPostOperation())
1.576 + {
1.577 + _LOG(_L("CPreModifierPlugin::FsFileRenameL, post intercept"));
1.578 +
1.579 + if (extension.CompareF(_L(".tst")) == 0)
1.580 + {
1.581 + TBuf8<32> tempBuf = (_L8("Rename Post Intercept"));
1.582 + RFilePlugin fileplugin(aRequest);
1.583 + TInt err = fileplugin.AdoptFromClient();
1.584 + iLastError = err;
1.585 + iLineNumber = __LINE__;
1.586 + if(err!=KErrNone)
1.587 + User::Leave(err); //trapped in DoRequestL
1.588 +
1.589 + err = fileplugin.Write(20, tempBuf);
1.590 + _LOG2(_L("CPreModifierPlugin::FsFileRenameL, FileWrite returned %d"), err);
1.591 + iLastError = err;
1.592 + iLineNumber = __LINE__;
1.593 + if(err!=KErrNone)
1.594 + User::Leave(err); //trapped in DoRequestL
1.595 + fileplugin.Close();
1.596 + }
1.597 + }
1.598 + else
1.599 + {
1.600 + User::Invariant();
1.601 + }
1.602 + }
1.603 +
1.604 +
1.605 +void CPreModifierPlugin::FsFileCreateL(TFsPluginRequest& aRequest)
1.606 + {
1.607 + TFileName filename;
1.608 + TParse parse;
1.609 +
1.610 + filename = aRequest.Src().FullName();
1.611 +
1.612 + TUint mode;
1.613 + TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
1.614 + iLastError = err;
1.615 + iLineNumber = __LINE__;
1.616 + if(err!=KErrNone)
1.617 + User::Leave(err); //trapped in DoRequestL
1.618 +
1.619 + parse.Set(filename, NULL, NULL);
1.620 + TPtrC extension(parse.Ext());
1.621 +
1.622 + if (aRequest.IsPostOperation())
1.623 + {
1.624 + _LOG(_L("CPreModifierPlugin::FsFileCreateL, post intercept"));
1.625 +
1.626 + if (extension.CompareF(_L(".tst")) == 0)
1.627 + {
1.628 + RFilePlugin fileplugin(aRequest);
1.629 + TInt err = fileplugin.AdoptFromClient();
1.630 + iLastError = err;
1.631 + iLineNumber = __LINE__;
1.632 + if(err!=KErrNone)
1.633 + User::Leave(err); //trapped in DoRequestL
1.634 +
1.635 + //write to the newly created file
1.636 + TBuf8<64> wbuffer;
1.637 + wbuffer.Copy(_L8("TestTestTest"));
1.638 + err = fileplugin.Write(0, wbuffer);
1.639 + _LOG2(_L("CPreModifierPlugin::FsFileCreateL, RFilePlugin::Write to the newly created file returned %d"), err);
1.640 + iLastError = err;
1.641 + iLineNumber = __LINE__;
1.642 + if(err!=KErrNone)
1.643 + User::Leave(err); //trapped in DoRequestL
1.644 +
1.645 + TInt length = wbuffer.Length();
1.646 + HBufC8* tempBuf = HBufC8::NewMaxLC(length);
1.647 + TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
1.648 + err = fileplugin.Read(0, tempBufPtr);
1.649 + _LOG2(_L("CPreModifierPlugin::FsFileCreateL, RFilePlugin::Read returned %d"), err);
1.650 + iLastError = err;
1.651 + iLineNumber = __LINE__;
1.652 + if(err!=KErrNone)
1.653 + User::Leave(err); //trapped in DoRequestL
1.654 + //testing the correct thing has been written to the drive
1.655 + err = wbuffer.Compare(tempBufPtr);
1.656 + iLastError = err;
1.657 + iLineNumber = __LINE__;
1.658 + if(err!=KErrNone)
1.659 + User::Leave(err); //trapped in DoRequestL
1.660 +
1.661 + fileplugin.Close();
1.662 + CleanupStack::PopAndDestroy(); //tempBuf
1.663 + }
1.664 + }
1.665 + else
1.666 + {
1.667 + User::Invariant();
1.668 + }
1.669 + }
1.670 +
1.671 +void CPreModifierPlugin::FsFileOpenL(TFsPluginRequest& aRequest)
1.672 + {
1.673 +
1.674 + TFileName filename;
1.675 + TParse parse;
1.676 +
1.677 + filename = aRequest.Src().FullName();
1.678 +
1.679 + TUint mode;
1.680 + TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
1.681 + iLastError = err;
1.682 + iLineNumber = __LINE__;
1.683 + if(err!=KErrNone)
1.684 + User::Leave(err); //trapped in DoRequestL
1.685 +
1.686 + parse.Set(filename, NULL, NULL);
1.687 + TPtrC extension(parse.Ext());
1.688 +
1.689 + _LOG2(_L("CPreModifierPlugin::FsFileOpenL, file: %S"), &filename);
1.690 +
1.691 + if (aRequest.IsPostOperation())
1.692 + {
1.693 + _LOG(_L("CPreModifierPlugin::FsFileOpenL, post intercept"));
1.694 + if ((extension.CompareF(_L(".tst")) == 0) && (aRequest.Message().Int1() != 0) && (mode & EFileWrite))
1.695 + {
1.696 +
1.697 + RFilePlugin fileplugin(aRequest);
1.698 + err = fileplugin.AdoptFromClient();
1.699 + iLastError = err;
1.700 + iLineNumber = __LINE__;
1.701 + if(err!=KErrNone)
1.702 + User::Leave(err); //trapped in DoRequestL
1.703 +
1.704 + //write to the newly opened file
1.705 + TBuf8<64> wbuffer;
1.706 + wbuffer.Copy(_L8("TestTestTest"));
1.707 + err = fileplugin.Write(0, wbuffer);
1.708 + _LOG2(_L("CPreModifierPlugin::FsFileOpenL, RFilePlugin::Write to the newly opened file returned %d"), err);
1.709 + iLastError = err;
1.710 + iLineNumber = __LINE__;
1.711 + if(err!=KErrNone)
1.712 + User::Leave(err); //trapped in DoRequestL
1.713 +
1.714 + TInt length = wbuffer.Length();
1.715 + HBufC8* tempBuf = HBufC8::NewMaxLC(length);
1.716 + TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
1.717 + err = fileplugin.Read(0, tempBufPtr);
1.718 + _LOG2(_L("CPreModifierPlugin::FsFileOpenL, RFilePlugin::Read returned %d"), err);
1.719 + iLastError = err;
1.720 + iLineNumber = __LINE__;
1.721 + if(err!=KErrNone)
1.722 + User::Leave(err); //trapped in DoRequestL
1.723 +
1.724 + //testing the correct thing has been written to the drive
1.725 + err = wbuffer.Compare(tempBufPtr);
1.726 + iLastError = err;
1.727 + iLineNumber = __LINE__;
1.728 + if(err!=KErrNone)
1.729 + User::Leave(err); //trapped in DoRequestL
1.730 +
1.731 + fileplugin.Close();
1.732 +
1.733 + CleanupStack::PopAndDestroy(); //tempbuf
1.734 + }
1.735 + }
1.736 + else
1.737 + {
1.738 + User::Invariant();
1.739 + }
1.740 + }
1.741 +
1.742 +
1.743 +void CPreModifierPlugin::FsFileTempL(TFsPluginRequest& aRequest)
1.744 + {
1.745 + TBuf<256> testfilename1;
1.746 +
1.747 + //setting up test files
1.748 + testfilename1.Append(iDriveToTest);
1.749 + testfilename1.Append(_L(":\\Data\\"));
1.750 +
1.751 + if (aRequest.IsPostOperation())
1.752 + {
1.753 + _LOG(_L("CPreModifierPlugin::FsFileTempL, post intercept"));
1.754 +
1.755 + RFilePlugin fileplugin(aRequest);
1.756 + TInt err = fileplugin.AdoptFromClient();
1.757 + iLastError = err;
1.758 + iLineNumber = __LINE__;
1.759 + if(err!=KErrNone)
1.760 + User::Leave(err); //trapped in DoRequestL
1.761 +
1.762 + //write to the newly created temp file
1.763 + TBuf8<64> wbuffer;
1.764 + wbuffer.Copy(_L8("TestTestTest"));
1.765 + err = fileplugin.Write(0, wbuffer);
1.766 + _LOG2(_L("CPreModifierPlugin::FsFileTempL, RFilePlugin::Write to the newly created temp file returned %d"), err);
1.767 + iLastError = err;
1.768 + iLineNumber = __LINE__;
1.769 + if(err!=KErrNone)
1.770 + User::Leave(err); //trapped in DoRequestL
1.771 +
1.772 + TInt length = wbuffer.Length();
1.773 + HBufC8* tempBuf = HBufC8::NewMaxLC(length);
1.774 + TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
1.775 + err = fileplugin.Read(0, tempBufPtr);
1.776 + _LOG2(_L("CPreModifierPlugin::FsFileTempL, RFilePlugin::Read returned %d"), err);
1.777 + iLastError = err;
1.778 + iLineNumber = __LINE__;
1.779 + if(err!=KErrNone)
1.780 + User::Leave(err); //trapped in DoRequestL
1.781 +
1.782 + fileplugin.Close();
1.783 +
1.784 + //testing the correct thing has been written to the drive
1.785 + err = wbuffer.Compare(tempBufPtr);
1.786 + iLastError = err;
1.787 + iLineNumber = __LINE__;
1.788 + if(err!=KErrNone)
1.789 + User::Leave(err); //trapped in DoRequestL
1.790 +
1.791 + CleanupStack::PopAndDestroy();
1.792 + }
1.793 + else
1.794 + {
1.795 + User::Invariant();
1.796 + }
1.797 + }
1.798 +
1.799 +
1.800 +void CPreModifierPlugin::FsFileReplaceL(TFsPluginRequest& aRequest)
1.801 + {
1.802 + TFileName filename;
1.803 + TParse parse;
1.804 +
1.805 + filename = aRequest.Src().FullName();
1.806 +
1.807 + TUint mode;
1.808 + TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
1.809 + iLastError = err;
1.810 + iLineNumber = __LINE__;
1.811 + if(err!=KErrNone)
1.812 + User::Leave(err); //trapped in DoRequestL
1.813 +
1.814 + parse.Set(filename, NULL, NULL);
1.815 + TPtrC extension(parse.Ext());
1.816 +
1.817 + _LOG2(_L("CPreModifierPlugin::FsFileReplaceL, file: %S"), &filename);
1.818 +
1.819 + if (aRequest.IsPostOperation())
1.820 + {
1.821 + _LOG(_L("CPreModifierPlugin::FsFileReplaceL, post intercept"));
1.822 + if ((extension.CompareF(_L(".tst")) == 0) && (aRequest.Message().Int1() != 0))
1.823 + {
1.824 + //write to the newly replaced file
1.825 + TBuf8<64> wbuffer;
1.826 + wbuffer.Copy(_L8("TestTestTest"));
1.827 +
1.828 + RFilePlugin fileplugin(aRequest);
1.829 + TInt err = fileplugin.AdoptFromClient();
1.830 + iLastError = err;
1.831 + iLineNumber = __LINE__;
1.832 + if(err!=KErrNone)
1.833 + User::Leave(err); //trapped in DoRequestL
1.834 +
1.835 + err = fileplugin.Write(0, wbuffer);
1.836 + _LOG2(_L("CPreModifierPlugin::FsFileReplaceL, RFilePlugin::Write to the newly created file returned %d"), err);
1.837 + iLastError = err;
1.838 + iLineNumber = __LINE__;
1.839 + if(err!=KErrNone)
1.840 + User::Leave(err); //trapped in DoRequestL
1.841 +
1.842 + TInt length = wbuffer.Length();
1.843 + HBufC8* tempBuf = HBufC8::NewMaxLC(length);
1.844 + TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
1.845 + err = fileplugin.Read(0, tempBufPtr);
1.846 + _LOG2(_L("CPreModifierPlugin::FsFileReplaceL, RFilePlugin::Read returned %d"), err);
1.847 + iLastError = err;
1.848 + iLineNumber = __LINE__;
1.849 + if(err!=KErrNone)
1.850 + User::Leave(err); //trapped in DoRe
1.851 +
1.852 + //testing the correct thing has been written to the drive
1.853 + err = wbuffer.Compare(tempBufPtr);
1.854 + iLastError = err;
1.855 + iLineNumber = __LINE__;
1.856 + if(err!=KErrNone)
1.857 + User::Leave(err); //trapped in DoRequestL
1.858 +
1.859 + fileplugin.Close();
1.860 + CleanupStack::PopAndDestroy();
1.861 + }
1.862 + }
1.863 + else
1.864 + {
1.865 + User::Invariant();
1.866 + }
1.867 + }
1.868 +
1.869 +
1.870 +
1.871 +void CPreModifierPlugin::FsReadFileSectionL(TFsPluginRequest& aRequest)
1.872 + {
1.873 + TInt err = KErrNone;
1.874 + TInt length = 0;
1.875 + TInt64 pos = 0;
1.876 + TFileName filename;
1.877 + TParse parse;
1.878 + TBuf<256> testfilename1;
1.879 +
1.880 + //setting up test files
1.881 + testfilename1.Append(iDriveToTest);
1.882 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.883 +
1.884 + filename = aRequest.Src().FullName();
1.885 +
1.886 + err = aRequest.Read(TFsPluginRequest::ELength, length);
1.887 + iLastError = err;
1.888 + iLineNumber = __LINE__;
1.889 + if(err!=KErrNone)
1.890 + User::Leave(err); //trapped in DoRequestL
1.891 +
1.892 + err = aRequest.Read(TFsPluginRequest::EPosition, pos);
1.893 + iLastError = err;
1.894 + iLineNumber = __LINE__;
1.895 + if(err!=KErrNone)
1.896 + User::Leave(err); //trapped in DoRequestL
1.897 +
1.898 + parse.Set(filename, NULL, NULL);
1.899 +
1.900 + _LOG2(_L("CPreModifierPlugin::FsReadFileSectionL, file: %S"), &filename);
1.901 +
1.902 + if (aRequest.IsPostOperation())
1.903 + {
1.904 + _LOG(_L("CPreModifierPlugin::FsReadFileSectionL, post intercept - enter"));
1.905 + RFilePlugin fileplugin2(aRequest,ETrue);
1.906 + //open a second file
1.907 + err = fileplugin2.Open(testfilename1, EFileWrite);
1.908 + _LOG3(_L("CPreModifierPlugin::FsReadFileSectionL - RFilePlugin::Open for %S returned %d"), &testfilename1, err);
1.909 + iLastError = err;
1.910 + iLineNumber = __LINE__;
1.911 + if(err!=KErrNone)
1.912 + User::Leave(err); //trapped in DoRequestL
1.913 +
1.914 + TInt64 size=0;
1.915 + err = fileplugin2.Size(size);
1.916 + _LOG3(_L("CPreModifierPlugin::FsReadFileSectionL - RFilePlugin::Size for %S returned %d"), &testfilename1, err);
1.917 + iLastError = err;
1.918 + iLineNumber = __LINE__;
1.919 + if(err!=KErrNone)
1.920 + User::Leave(err); //trapped in DoRequestL
1.921 +
1.922 + //close the second file
1.923 + fileplugin2.Close();
1.924 + _LOG(_L("CPreModifierPlugin::FsReadFileSectionL - post intercept - exit"));
1.925 + }
1.926 + else
1.927 + {
1.928 + User::Invariant();
1.929 + }
1.930 + }
1.931 +
1.932 +
1.933 +void CPreModifierPlugin::FsDeleteL(TFsPluginRequest& aRequest)
1.934 + {
1.935 + TInt err = KErrNone;
1.936 + TFileName filename;
1.937 +
1.938 + TBuf<256> testfilename1;
1.939 +
1.940 + //setting up test files
1.941 + testfilename1.Append(iDriveToTest);
1.942 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.943 +
1.944 + filename = aRequest.Src().FullName();
1.945 +
1.946 + if (aRequest.IsPostOperation())
1.947 + {
1.948 + _LOG(_L("CPreModifierPlugin::FsDeleteL, post intercept"));
1.949 +
1.950 + RFilePlugin fileplugin2(aRequest);
1.951 + //open a second file
1.952 + err = fileplugin2.Open(testfilename1, EFileWrite);
1.953 + _LOG3(_L("RFilePlugin::Open for %S returned %d"), &testfilename1, err);
1.954 + iLastError = err;
1.955 + iLineNumber = __LINE__;
1.956 + if(err!=KErrNone)
1.957 + User::Leave(err); //trapped in DoRequestL
1.958 +
1.959 + TInt64 size=0;
1.960 + err = fileplugin2.Size(size);
1.961 + iLastError = err;
1.962 + iLineNumber = __LINE__;
1.963 + if(err!=KErrNone)
1.964 + User::Leave(err); //trapped in DoRequestL
1.965 +
1.966 + //close the second file
1.967 + fileplugin2.Close();
1.968 + _LOG2(_L("CPreModifierPlugin::FsDeleteL, RFilePlugin::Close to the second file returned %d"), err);
1.969 + }
1.970 + else
1.971 + {
1.972 + User::Invariant();
1.973 + }
1.974 + }
1.975 +
1.976 +
1.977 +void CPreModifierPlugin::FsReplaceL(TFsPluginRequest& aRequest)
1.978 + {
1.979 + TFileName oldfilename;
1.980 + TFileName newfilename;
1.981 +
1.982 + oldfilename = aRequest.Src().FullName();
1.983 + newfilename = aRequest.Dest().FullName();
1.984 +
1.985 + TBuf<256> testfilename1;
1.986 +
1.987 + //setting up test files
1.988 + testfilename1.Append(iDriveToTest);
1.989 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.990 +
1.991 +
1.992 + if (aRequest.IsPostOperation())
1.993 + {
1.994 + //STF: Is this code going to get called - the pre-operation completes early?
1.995 +
1.996 + _LOG(_L("CPreModifierPlugin::FsReplaceL, post intercept"));
1.997 + //We should check that the name has changed here.
1.998 + RFilePlugin file(aRequest);
1.999 + TInt err = file.AdoptFromClient();
1.1000 + iLastError = err;
1.1001 + iLineNumber = __LINE__;
1.1002 + if(err!=KErrNone)
1.1003 + User::Leave(err); //trapped in DoRequestL
1.1004 +
1.1005 + TInt compare = oldfilename.Compare(newfilename);
1.1006 + if(compare != 0) //is equal
1.1007 + {
1.1008 + //User::Leave(compare);
1.1009 + //It wont be equal as the name is coming from the request aint it.
1.1010 + //Pointless comparison then eh?
1.1011 + }
1.1012 +
1.1013 + file.Close();
1.1014 +
1.1015 + RFilePlugin fileplugin2(aRequest);
1.1016 + //open a second file
1.1017 + err = fileplugin2.Open(testfilename1, EFileWrite);
1.1018 + _LOG3(_L("CPreModifierPlugin::FsReplaceL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
1.1019 + iLastError = err;
1.1020 + iLineNumber = __LINE__;
1.1021 + if(err!=KErrNone)
1.1022 + User::Leave(err); //trapped in DoRequestL
1.1023 +
1.1024 + TInt64 size=0;
1.1025 + err =fileplugin2.Size(size);
1.1026 + iLastError = err;
1.1027 + iLineNumber = __LINE__;
1.1028 + if(err!=KErrNone)
1.1029 + User::Leave(err); //trapped in DoRequestL
1.1030 +
1.1031 + //close the second file
1.1032 + fileplugin2.Close();
1.1033 + _LOG2(_L("CPreModifierPlugin::FsReplaceL, RFilePlugin::Close to the second file returned %d"), err);
1.1034 + }
1.1035 + else
1.1036 + {
1.1037 + User::Invariant();
1.1038 + }
1.1039 + }
1.1040 +
1.1041 +
1.1042 +void CPreModifierPlugin::FsRenameL(TFsPluginRequest& aRequest)
1.1043 + {
1.1044 + TInt err = KErrNone;
1.1045 + TFileName oldfilename;
1.1046 + TFileName newfilename;
1.1047 +
1.1048 + oldfilename = aRequest.Src().FullName();
1.1049 + newfilename = aRequest.Dest().FullName();
1.1050 +
1.1051 + TBuf<256> testfilename1;
1.1052 +
1.1053 + //setting up test files
1.1054 + testfilename1.Append(iDriveToTest);
1.1055 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.1056 +
1.1057 + if (aRequest.IsPostOperation())
1.1058 + {
1.1059 + _LOG(_L("CPreModifierPlugin::FsRenameL, post intercept"));
1.1060 + RFilePlugin fileplugin2(aRequest);
1.1061 + //open a second file
1.1062 + err = fileplugin2.Open(testfilename1, EFileWrite);
1.1063 + _LOG3(_L("CPreModifierPlugin::FsRenameL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
1.1064 + iLastError = err;
1.1065 + iLineNumber = __LINE__;
1.1066 + if(err!=KErrNone)
1.1067 + User::Leave(err); //trapped in DoRequestL
1.1068 +
1.1069 + TInt64 size=0;
1.1070 + err = fileplugin2.Size(size);
1.1071 + iLastError = err;
1.1072 + iLineNumber = __LINE__;
1.1073 + if(err!=KErrNone)
1.1074 + User::Leave(err); //trapped in DoRequestL
1.1075 +
1.1076 + //close the second file
1.1077 + fileplugin2.Close();
1.1078 + _LOG2(_L("CPreModifierPlugin::FsRenameL, RFilePlugin::Close to the second file returned %d"), err);
1.1079 + }
1.1080 + else
1.1081 + {
1.1082 + User::Invariant();
1.1083 + }
1.1084 + }
1.1085 +
1.1086 +void CPreModifierPlugin::FsEntryL(TFsPluginRequest& aRequest)
1.1087 + {
1.1088 + TInt err = KErrNone;
1.1089 + TFileName filename;
1.1090 +
1.1091 + filename = aRequest.Src().FullName();
1.1092 +
1.1093 + TBuf<256> testfilename1;
1.1094 +
1.1095 + //setting up test files
1.1096 + testfilename1.Append(iDriveToTest);
1.1097 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.1098 +
1.1099 + if (aRequest.IsPostOperation())
1.1100 + {
1.1101 + _LOG(_L("CPreModifierPlugin::FsEntryL, post intercept"));
1.1102 + RFilePlugin fileplugin2(aRequest);
1.1103 + //open a second file
1.1104 + err = fileplugin2.Open(testfilename1, EFileWrite);
1.1105 + _LOG3(_L("CPreModifierPlugin::FsEntryL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
1.1106 + iLastError = err;
1.1107 + iLineNumber = __LINE__;
1.1108 + if(err!=KErrNone)
1.1109 + User::Leave(err); //trapped in DoRequestL
1.1110 +
1.1111 + TInt64 size=0;
1.1112 + err = fileplugin2.Size(size);
1.1113 + iLastError = err;
1.1114 + iLineNumber = __LINE__;
1.1115 + if(err!=KErrNone)
1.1116 + User::Leave(err); //trapped in DoRequestL
1.1117 +
1.1118 + //close the second file
1.1119 + fileplugin2.Close();
1.1120 + _LOG2(_L("CPreModifierPlugin::FsEntryL, RFilePlugin::Close to the second file returned %d"), err);
1.1121 + }
1.1122 + else
1.1123 + {
1.1124 + User::Invariant();
1.1125 + }
1.1126 + }
1.1127 +
1.1128 +
1.1129 +
1.1130 +void CPreModifierPlugin::FsSetEntryL(TFsPluginRequest& aRequest)
1.1131 + {
1.1132 + TInt err = KErrNone;
1.1133 +
1.1134 + TBuf<256> testfilename1;
1.1135 +
1.1136 + //setting up test files
1.1137 + testfilename1.Append(iDriveToTest);
1.1138 + testfilename1.Append(_L(":\\Data\\test.txt"));
1.1139 +
1.1140 + if (aRequest.IsPostOperation())
1.1141 + {
1.1142 + _LOG(_L("CPreModifierPlugin::FsSetEntryL, post intercept"));
1.1143 + RFilePlugin fileplugin2(aRequest);
1.1144 + //open a second file
1.1145 + err = fileplugin2.Open(testfilename1, EFileWrite);
1.1146 + _LOG3(_L("CPreModifierPlugin::FsSetEntryL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
1.1147 + iLastError = err;
1.1148 + iLineNumber = __LINE__;
1.1149 + if(err!=KErrNone)
1.1150 + User::Leave(err); //trapped in DoRequestL
1.1151 +
1.1152 + TInt64 size=0;
1.1153 + err = fileplugin2.Size(size);
1.1154 + iLastError = err;
1.1155 + iLineNumber = __LINE__;
1.1156 + if(err!=KErrNone)
1.1157 + User::Leave(err); //trapped in DoRequestL
1.1158 +
1.1159 + //close the second file
1.1160 + fileplugin2.Close();
1.1161 + _LOG2(_L("CPreModifierPlugin::FsSetEntryL, RFilePlugin::Close to the second file returned %d"), err);
1.1162 + }
1.1163 + else
1.1164 + {
1.1165 + User::Invariant();
1.1166 + }
1.1167 + }
1.1168 +
1.1169 +
1.1170 +/**
1.1171 +@internalComponent
1.1172 +*/
1.1173 +void CPreModifierPlugin::FsFileSubCloseL(TFsPluginRequest& aRequest)
1.1174 + {
1.1175 + if (aRequest.IsPostOperation())
1.1176 + {
1.1177 + _LOG(_L("CPreModifierPlugin::FsFileSubCloseL, post intercept"));
1.1178 + }
1.1179 + else
1.1180 + {
1.1181 + User::Invariant();
1.1182 + }
1.1183 + }
1.1184 +
1.1185 +/**
1.1186 +@internalComponent
1.1187 +*/
1.1188 +void CPreModifierPlugin::FsDirOpenL(TFsPluginRequest& aRequest)
1.1189 + {
1.1190 + if (aRequest.IsPostOperation())
1.1191 + {
1.1192 + _LOG(_L("CPreModifierPlugin::FsDirOpenL, post intercept"));
1.1193 + }
1.1194 + else
1.1195 + {
1.1196 + User::Invariant();
1.1197 + }
1.1198 + }
1.1199 +
1.1200 +void CPreModifierPlugin::FsDirReadOneL(TFsPluginRequest& aRequest)
1.1201 + {
1.1202 +
1.1203 + TFileName name;
1.1204 + TInt err = aRequest.FileName(name);
1.1205 + iLastError = err;
1.1206 + iLineNumber = __LINE__;
1.1207 + if(err!=KErrNone)
1.1208 + User::Leave(err); //trapped in DoRequestL
1.1209 +
1.1210 + if (aRequest.IsPostOperation())
1.1211 + {
1.1212 + _LOG(_L("CPreModifierPlugin::FsDirReadOneL, post intercept"));
1.1213 + }
1.1214 + else
1.1215 + {
1.1216 + User::Invariant();
1.1217 + }
1.1218 + }
1.1219 +
1.1220 +
1.1221 +/**
1.1222 +@internalComponent
1.1223 +*/
1.1224 +void CPreModifierPlugin::FsDirReadPackedL(TFsPluginRequest& aRequest)
1.1225 + {
1.1226 + if (aRequest.IsPostOperation())
1.1227 + {
1.1228 + _LOG(_L("CPreModifierPlugin::FsDirReadPackedL, post intercept"));
1.1229 + }
1.1230 + else
1.1231 + {
1.1232 + User::Invariant();
1.1233 + }
1.1234 + }
1.1235 +
1.1236 +
1.1237 +CFsPluginConn* CPreModifierPlugin::NewPluginConnL()
1.1238 + {
1.1239 + return new(ELeave) CPreModifierPluginConn();
1.1240 + }
1.1241 +
1.1242 +//Asynchronous RPlugin::DoRequest
1.1243 +void CPreModifierPlugin::FsPluginDoRequestL(CFsPluginConnRequest& aRequest)
1.1244 + {
1.1245 + FsPluginDoControlL(aRequest);
1.1246 + }
1.1247 +
1.1248 +//Synchronous RPlugin::DoControl
1.1249 +TInt CPreModifierPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
1.1250 + {
1.1251 + TInt err = KErrNone;
1.1252 +
1.1253 + //We can use this to set the drive
1.1254 + //We can store this as a member of this class.
1.1255 +
1.1256 + TPckg<TInt> errCodeDes(iLastError);
1.1257 + TPckg<TInt> errMsgDes(iLineNumber);
1.1258 +
1.1259 +
1.1260 + TInt function = aRequest.Function();
1.1261 + switch(function)
1.1262 + {
1.1263 + case KPluginSetDrive:
1.1264 + {
1.1265 + TPckg<TChar> drive(iDriveToTest);
1.1266 + TRAP(err,aRequest.ReadParam1L(drive));
1.1267 + break;
1.1268 + }
1.1269 + case KPluginGetError:
1.1270 + {
1.1271 + TRAP(err,aRequest.WriteParam1L(errCodeDes));
1.1272 + TRAP(err,aRequest.WriteParam2L(errMsgDes));
1.1273 + break;
1.1274 + }
1.1275 + default:
1.1276 + break;
1.1277 + }
1.1278 +
1.1279 + return err;
1.1280 + }
1.1281 +
1.1282 +TInt CPreModifierPluginConn::DoControl(CFsPluginConnRequest& aRequest)
1.1283 + {
1.1284 + return ((CPreModifierPlugin*)Plugin())->FsPluginDoControlL(aRequest);
1.1285 + }
1.1286 +
1.1287 +void CPreModifierPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
1.1288 + {
1.1289 + DoControl(aRequest);
1.1290 + }
1.1291 +
1.1292 +void CPreModifierPluginConn::DoCancel(TInt /*aReqMask*/)
1.1293 + {
1.1294 + }
1.1295 +
1.1296 +//factory functions
1.1297 +
1.1298 +class CPreModifierPluginFactory : public CFsPluginFactory
1.1299 + {
1.1300 +public:
1.1301 + CPreModifierPluginFactory();
1.1302 + virtual TInt Install();
1.1303 + virtual CFsPlugin* NewPluginL();
1.1304 + virtual CFsPlugin* NewPluginConnL();
1.1305 + virtual TInt UniquePosition();
1.1306 + };
1.1307 +
1.1308 +/**
1.1309 +Constructor for the plugin factory
1.1310 +@internalComponent
1.1311 +*/
1.1312 +CPreModifierPluginFactory::CPreModifierPluginFactory()
1.1313 + {
1.1314 + }
1.1315 +
1.1316 +/**
1.1317 +Install function for the plugin factory
1.1318 +@internalComponent
1.1319 +*/
1.1320 +TInt CPreModifierPluginFactory::Install()
1.1321 + {
1.1322 + SetSupportedDrives(KPluginSupportAllDrives);
1.1323 + //iSupportedDrives = 1<<23;
1.1324 + return(SetName(&KPreModifierPluginName));
1.1325 + }
1.1326 +
1.1327 +/**
1.1328 +@internalComponent
1.1329 +*/
1.1330 +TInt CPreModifierPluginFactory::UniquePosition()
1.1331 + {
1.1332 + return(KPreModifierPos);
1.1333 + }
1.1334 +
1.1335 +/**
1.1336 +Plugin factory function
1.1337 +@internalComponent
1.1338 +*/
1.1339 +CFsPlugin* CPreModifierPluginFactory::NewPluginL()
1.1340 +
1.1341 + {
1.1342 + return CPreModifierPlugin::NewL();
1.1343 + }
1.1344 +
1.1345 +/**
1.1346 +Plugin factory function
1.1347 +@internalComponent
1.1348 +*/
1.1349 +CFsPlugin* CPreModifierPluginFactory::NewPluginConnL()
1.1350 +
1.1351 + {
1.1352 + return CPreModifierPlugin::NewL();
1.1353 + }
1.1354 +
1.1355 +/**
1.1356 +Create a new Plugin
1.1357 +@internalComponent
1.1358 +*/
1.1359 +extern "C" {
1.1360 +
1.1361 +EXPORT_C CFsPluginFactory* CreateFileSystem()
1.1362 + {
1.1363 + return(new CPreModifierPluginFactory());
1.1364 + }
1.1365 +}
1.1366 +