1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/lffs/loadntfs.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,85 @@
1.4 +// Copyright (c) 1998-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 +// e32test\lffs\loadntfs.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <f32file.h>
1.22 +
1.23 +_LIT(KFileSystemDllName, "ntfs.fsy");
1.24 +_LIT(KFileSystemName, "ntfs");
1.25 +
1.26 +RFs TheFs;
1.27 +
1.28 +TInt MountNTFS()
1.29 + {
1.30 + TBuf<256> cmd;
1.31 + User::CommandLine(cmd);
1.32 + TLex cmdlex(cmd);
1.33 + cmdlex.SkipSpace();
1.34 + TUint c = (TUint)cmdlex.Get();
1.35 + if (c>='a' && c<='z')
1.36 + c-=0x20;
1.37 + if (c<'A' || c>'Z')
1.38 + return KErrArgument;
1.39 + TBuf<4> driveLetter;
1.40 + driveLetter.SetLength(1);
1.41 + driveLetter[0] = (TText)c;
1.42 + RDebug::Print(_L("Drive %S"), &driveLetter);
1.43 +
1.44 + TInt driveNumber = TInt(c-'A') + TInt(EDriveA);
1.45 + TInt r;
1.46 + driveLetter.Append(_L(":\\"));
1.47 +
1.48 + RDebug::Print(_L("Add file system: %S"), &KFileSystemDllName);
1.49 + r=TheFs.AddFileSystem(KFileSystemDllName);
1.50 + if (r!=KErrNone && r!=KErrAlreadyExists)
1.51 + {
1.52 + RDebug::Print(_L("Failed: %d"), r);
1.53 + return r;
1.54 + }
1.55 +
1.56 + TFullName name;
1.57 + r = TheFs.FileSystemName(name, driveNumber);
1.58 + if (name.Length() != 0)
1.59 + {
1.60 + RDebug::Print(_L("Dismounting %S on drive %S\r\n"), &name, &driveLetter);
1.61 + r=TheFs.DismountFileSystem(name, driveNumber);
1.62 + RDebug::Print(_L("Dismount ret=%d"), r);
1.63 + }
1.64 +
1.65 + RDebug::Print(_L("Mount NTFS on drive %S\r\n"), &driveLetter);
1.66 + r = TheFs.MountFileSystem(KFileSystemName, driveNumber);
1.67 + RDebug::Print(_L("Mount r=%d"),r);
1.68 + return KErrNone;
1.69 + }
1.70 +
1.71 +GLDEF_C TInt E32Main()
1.72 + {
1.73 +
1.74 + CTrapCleanup* cleanup;
1.75 + cleanup=CTrapCleanup::New();
1.76 +
1.77 + TInt r=TheFs.Connect();
1.78 + RDebug::Print(_L("Connect ret %d"),r);
1.79 +
1.80 + if (r == KErrNone)
1.81 + r = MountNTFS();
1.82 + RDebug::Print(_L("Mount NTFS ret %d"),r);
1.83 +
1.84 + TheFs.Close();
1.85 + delete cleanup;
1.86 + return KErrNone;
1.87 + }
1.88 +