symport/f32/sfsrv/cl_find.cpp
author jjkang
Fri, 11 Jun 2010 15:22:09 +0800
changeset 2 806186ab5e14
parent 1 0a7b44b10206
permissions -rw-r--r--
Change SFL to EPL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
2
806186ab5e14 Change SFL to EPL
jjkang
parents: 1
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
1
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
2
806186ab5e14 Change SFL to EPL
jjkang
parents: 1
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     7
//
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    10
//
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    11
// Contributors:
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    12
//
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    13
// Description:
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    14
// f32\sfsrv\cl_find.cpp
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    15
// 
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    16
//
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    17
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    18
#include "cl_std.h"
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    19
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    20
EXPORT_C TFindFile::TFindFile(RFs& aFs)
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    21
	: iFs(&aFs), iPathPos(0), iCurrentDrive(0), iMode(-1), iMatchMask(0)
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    22
/**
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    23
Constructor taking a file server session.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    24
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    25
@param aFs File server session.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    26
*/
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    27
	{
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    28
	
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    29
	iFile.Set(_L(""),NULL,NULL);
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    30
	}
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    31
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    32
TInt TFindFile::DoFindByPath(const TDesC& aFileName,const TDesC* aPath)
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    33
//
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    34
// Look for a file in each directory in the path
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    35
// Make initial check for aFileName in the current directory
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    36
//
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    37
	{
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    38
	TUint att;
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    39
	
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    40
#ifdef _DEBUG_LOGGING
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    41
	RDebug::Print(_L("DEBUG: FindByPath> aFileName=%S id=%x\n"), &aFileName);
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    42
#endif
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    43
	
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    44
	// At the moment this is just looking for an exact match for the file
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    45
	// or does the file exist in the current directory
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    46
	iFile.Set(aFileName, NULL, NULL);
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    47
	if (iFs->Att(iFile.FullName(), att) == KErrNone)
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    48
		return KErrNone;
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    49
	
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    50
	iFile.Set(iFile.NameAndExt(), NULL, NULL);
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    51
	return iFs->Att(iFile.FullName(), att);
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    52
	}
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    53
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    54
EXPORT_C TInt TFindFile::FindByPath(const TDesC& aFileName,const TDesC* aPath)
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    55
/**
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    56
Searches for a file/directory in one or more directories in the path.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    57
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    58
The search ends when the file/directory is found, or when every directory
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    59
specified in the path list has been unsuccessfully searched.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    60
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    61
Notes:
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    62
	
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    63
1. For the equivalent search using wildcards, use FindWildByPath().
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    64
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    65
2. After a file has been found, use TFindFile::File() to get the fully qualified path of the file. To
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    66
   search for the next occurrence, use TFindFile::Find().
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    67
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    68
@param aFileName The filename to search for. If this specifies a directory as well
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    69
                 as a filename, then that directory is searched first.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    70
@param aPath     A list of directories to be searched. Paths in this list must
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    71
                 be separated by a semicolon character, but a semicolon is not
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    72
                 required after the	final path. The directories are searched in
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    73
                 the order in which they occur in the list. If a path in
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    74
                 the list contains a drive letter, that drive alone is searched.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    75
                 If a path contains no drive letter, the function searches for
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    76
                 the file in that directory on every available drive in turn,
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    77
                 beginning with drive Y:, in descending alphabetical order
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    78
                 and ending with drive Z:.When path is empty then session path 
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    79
                 will be used for the search.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    80
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    81
@return KErrNone, if the filename was found;
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    82
        KErrNotFound, if the filename was not found.
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    83
        KErrArgument, if the filename is empty. 
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    84
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    85
@see TFindFile::FindWildByPath
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    86
@see TFindFile::File
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    87
@see TFindFile::Find
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    88
*/
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    89
	{
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    90
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    91
	iDir=NULL;
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    92
	return(DoFindByPath(aFileName,aPath));
0a7b44b10206 Catch up of Symbian tools for @1627812
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    93
	}