os/kernelhwsrv/kerneltest/e32test/lffs/load9660.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\lffs\load9660.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <f32file.h>
sl@0
    19
sl@0
    20
_LIT(KFileSystemDllName, "iso9660.fsy");
sl@0
    21
_LIT(KFileSystemName, "iso9660");
sl@0
    22
sl@0
    23
RFs TheFs;
sl@0
    24
sl@0
    25
TInt MountISO9660()
sl@0
    26
	{
sl@0
    27
	TBuf<256> cmd;
sl@0
    28
	User::CommandLine(cmd);
sl@0
    29
	TLex cmdlex(cmd);
sl@0
    30
	cmdlex.SkipSpace();
sl@0
    31
	TUint c = (TUint)cmdlex.Get();
sl@0
    32
	if (c>='a' && c<='z')
sl@0
    33
		c-=0x20;
sl@0
    34
	if (c<'A' || c>'Z')
sl@0
    35
		return KErrArgument;
sl@0
    36
	TBuf<4> driveLetter;
sl@0
    37
	driveLetter.SetLength(1);
sl@0
    38
	driveLetter[0] = (TText)c;
sl@0
    39
    RDebug::Print(_L("Drive %S"), &driveLetter);
sl@0
    40
    
sl@0
    41
    TInt driveNumber = TInt(c-'A') + TInt(EDriveA);
sl@0
    42
	TInt r;
sl@0
    43
	driveLetter.Append(_L(":\\"));
sl@0
    44
    
sl@0
    45
    RDebug::Print(_L("Add file system: %S"), &KFileSystemDllName);
sl@0
    46
    r=TheFs.AddFileSystem(KFileSystemDllName);
sl@0
    47
    if (r!=KErrNone && r!=KErrAlreadyExists)
sl@0
    48
		{
sl@0
    49
		RDebug::Print(_L("Failed: %d"), r);
sl@0
    50
		return r;
sl@0
    51
		}
sl@0
    52
sl@0
    53
	TFullName name;
sl@0
    54
	r = TheFs.FileSystemName(name, driveNumber);
sl@0
    55
	if (name.Length() != 0)
sl@0
    56
		{
sl@0
    57
        RDebug::Print(_L("Dismounting %S on drive %S\r\n"), &name, &driveLetter);
sl@0
    58
        r=TheFs.DismountFileSystem(name, driveNumber);
sl@0
    59
		RDebug::Print(_L("Dismount ret=%d"), r);
sl@0
    60
    	}
sl@0
    61
sl@0
    62
    RDebug::Print(_L("Mount ISO9660 on drive %S\r\n"), &driveLetter);
sl@0
    63
    r = TheFs.MountFileSystem(KFileSystemName, driveNumber);
sl@0
    64
	RDebug::Print(_L("Mount r=%d"),r);
sl@0
    65
    return KErrNone;
sl@0
    66
	}
sl@0
    67
sl@0
    68
GLDEF_C TInt E32Main()
sl@0
    69
	{
sl@0
    70
sl@0
    71
    CTrapCleanup* cleanup;
sl@0
    72
    cleanup=CTrapCleanup::New();
sl@0
    73
sl@0
    74
	TInt r=TheFs.Connect();
sl@0
    75
	RDebug::Print(_L("Connect ret %d"),r);
sl@0
    76
sl@0
    77
	if (r == KErrNone)
sl@0
    78
		r = MountISO9660();
sl@0
    79
	RDebug::Print(_L("Mount ISO9660 ret %d"),r);
sl@0
    80
	
sl@0
    81
    TheFs.Close();
sl@0
    82
    delete cleanup;
sl@0
    83
    return KErrNone;
sl@0
    84
	}
sl@0
    85