os/kernelhwsrv/userlibandfileserver/fileserver/sfsrv/cl_parse.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-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
// f32\sfsrv\cl_parse.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "cl_std.h"
sl@0
    19
sl@0
    20
const TInt KLexComponents=4;
sl@0
    21
const TInt KLexNames=3;
sl@0
    22
sl@0
    23
sl@0
    24
sl@0
    25
sl@0
    26
EXPORT_C TParseBase::TParseBase()
sl@0
    27
	: iWild(0)
sl@0
    28
/**
sl@0
    29
Default constructor.
sl@0
    30
*/
sl@0
    31
	{
sl@0
    32
sl@0
    33
	Mem::FillZ(&iField[0],sizeof(iField));
sl@0
    34
	}
sl@0
    35
sl@0
    36
sl@0
    37
sl@0
    38
sl@0
    39
TInt TParseBase::ParseDrive(TLex& aName,TBool& aDone)
sl@0
    40
//
sl@0
    41
// Parse the drive name.
sl@0
    42
//
sl@0
    43
	{
sl@0
    44
sl@0
    45
	TPtrC d=aName.RemainderFromMark();
sl@0
    46
	if (d.Length()<2 || d[1]!=KDriveDelimiter)
sl@0
    47
		return(KErrNone);	//must be Drive delimeter and longer that tow to be valid drive
sl@0
    48
	TCharF c=d[0];
sl@0
    49
	if (!c.IsAlpha())		//must be alphaber letter 
sl@0
    50
		return(KErrBadName);
sl@0
    51
	if (!aDone)
sl@0
    52
		{
sl@0
    53
		if(iMod)
sl@0
    54
			NameBuf()+=d.Left(2);
sl@0
    55
		aDone=ETrue;
sl@0
    56
		}
sl@0
    57
	aName.SkipAndMark(2);
sl@0
    58
	return(KErrNone);
sl@0
    59
	}
sl@0
    60
sl@0
    61
TInt TParseBase::ParsePath(TLex& aName,TBool& aDone)
sl@0
    62
//
sl@0
    63
// Parse the path.
sl@0
    64
//
sl@0
    65
	{
sl@0
    66
sl@0
    67
	TPtrC d=aName.RemainderFromMark();
sl@0
    68
	if (d.Length() && d[0]!=KPathDelimiter)
sl@0
    69
		return(KErrNone); // Require first char of path to be a '\'
sl@0
    70
	TInt n=d.LocateReverse(KPathDelimiter)+1;
sl@0
    71
	if (n && !aDone)
sl@0
    72
		{
sl@0
    73
		if(iMod)
sl@0
    74
			{
sl@0
    75
			if (NameBuf().Length()+n>KMaxFileName)
sl@0
    76
				return(KErrBadName);
sl@0
    77
			NameBuf()+=d.Left(n);
sl@0
    78
			}
sl@0
    79
		aDone=ETrue;
sl@0
    80
		}
sl@0
    81
	aName.SkipAndMark(n);
sl@0
    82
	return(KErrNone);
sl@0
    83
	}
sl@0
    84
sl@0
    85
LOCAL_C TBool IsSpace(const TDesC& aDes)
sl@0
    86
//
sl@0
    87
// Returns ETrue if aDes only contains spaces or is zero length
sl@0
    88
//
sl@0
    89
	{
sl@0
    90
sl@0
    91
	TInt len=aDes.Length();
sl@0
    92
	for (TInt i=0;i<len;i++)
sl@0
    93
		{
sl@0
    94
		TChar txt=aDes[i];
sl@0
    95
		if (!txt.IsSpace())
sl@0
    96
			return(EFalse);
sl@0
    97
		}
sl@0
    98
	return(ETrue);
sl@0
    99
	}
sl@0
   100
sl@0
   101
TInt TParseBase::ParseName(TLex& aName,TBool& aDone)
sl@0
   102
//
sl@0
   103
// Parse the name.
sl@0
   104
//
sl@0
   105
	{
sl@0
   106
sl@0
   107
	TPtrC d=aName.RemainderFromMark();
sl@0
   108
	if (d.Locate(KPathDelimiter)!=KErrNotFound)
sl@0
   109
		return(KErrBadName); // Illegal name - filenames cannot contain a '\'
sl@0
   110
	TInt n=d.LocateReverse(KExtDelimiter);
sl@0
   111
	if (n==KErrNotFound)
sl@0
   112
		{
sl@0
   113
		n=d.Length();
sl@0
   114
		if (IsSpace(d.Left(n)))
sl@0
   115
			return(KErrNone);
sl@0
   116
		}
sl@0
   117
	TPtrC v=d.Left(n);
sl@0
   118
	if (n && !aDone)
sl@0
   119
		{
sl@0
   120
		if (v.Locate(KMatchOne)!=KErrNotFound)	//	Found ? in the name
sl@0
   121
			iWild|=(EWildName|EWildEither|EWildIsKMatchOne);		
sl@0
   122
		if (v.Locate(KMatchAny)!=KErrNotFound)	//	Found * in the name
sl@0
   123
			iWild|=(EWildName|EWildEither|EWildIsKMatchAny);		
sl@0
   124
		if(iMod)
sl@0
   125
			{
sl@0
   126
			if (NameBuf().Length()+n>KMaxFileName)	
sl@0
   127
				return(KErrBadName);
sl@0
   128
			NameBuf()+=v;
sl@0
   129
			if (n==d.Length())
sl@0
   130
				NameBuf().TrimRight();
sl@0
   131
			}
sl@0
   132
		aDone=ETrue;
sl@0
   133
		}
sl@0
   134
	aName.SkipAndMark(n);
sl@0
   135
	return(KErrNone);
sl@0
   136
	}
sl@0
   137
sl@0
   138
TInt TParseBase::ParseExt(TLex& aName,TBool& aDone)
sl@0
   139
//
sl@0
   140
// Parse the extension.
sl@0
   141
//
sl@0
   142
	{
sl@0
   143
sl@0
   144
	TPtrC d=aName.RemainderFromMark();
sl@0
   145
	if (d.Length() && !IsSpace(d) && !aDone)
sl@0
   146
		{
sl@0
   147
		if (d.Locate(KMatchOne)!=KErrNotFound) //	Found ? in the name
sl@0
   148
			iWild|=(EWildExt|EWildEither|EWildIsKMatchOne);
sl@0
   149
		if (d.Locate(KMatchAny)!=KErrNotFound) //	Found * in the name
sl@0
   150
			iWild|=(EWildExt|EWildEither|EWildIsKMatchAny);
sl@0
   151
		
sl@0
   152
		if(iMod)
sl@0
   153
			{
sl@0
   154
			if (NameBuf().Length()+d.Length()>KMaxFileName)
sl@0
   155
				return(KErrBadName);
sl@0
   156
			NameBuf()+=d;
sl@0
   157
			NameBuf().TrimRight();
sl@0
   158
			}
sl@0
   159
		else
sl@0
   160
			aName.SkipAndMark(d.Length());
sl@0
   161
		aDone=ETrue;
sl@0
   162
		}
sl@0
   163
	return(KErrNone);
sl@0
   164
	}
sl@0
   165
sl@0
   166
TInt TParseBase::Set(const TDesC* aName,const TDesC* aRelated,const TDesC* aDefault,TBool allowWild)
sl@0
   167
//
sl@0
   168
// Parse a name. Optionally allow wild cards.
sl@0
   169
//
sl@0
   170
	{
sl@0
   171
sl@0
   172
	TInt (TParseBase::*parse[KLexComponents])(TLex& aName,TBool& aDone);
sl@0
   173
	parse[0]=&TParseBase::ParseDrive;
sl@0
   174
	parse[1]=&TParseBase::ParsePath;
sl@0
   175
	parse[2]=&TParseBase::ParseName;
sl@0
   176
	parse[3]=&TParseBase::ParseExt;
sl@0
   177
	
sl@0
   178
	iWild=0;
sl@0
   179
sl@0
   180
	Mem::FillZ(&iField[0],sizeof(iField));
sl@0
   181
	
sl@0
   182
	TLex name(*aName);
sl@0
   183
	TLex def;
sl@0
   184
	TLex rel;
sl@0
   185
	TInt lexnames;
sl@0
   186
	if(iMod)
sl@0
   187
		{
sl@0
   188
		if (aRelated)
sl@0
   189
			rel=(*aRelated);
sl@0
   190
		if (aDefault)
sl@0
   191
			def=(*aDefault);
sl@0
   192
		NameBuf().Zero();
sl@0
   193
		lexnames = KLexNames;
sl@0
   194
		}
sl@0
   195
	else
sl@0
   196
		{
sl@0
   197
		lexnames = 1;
sl@0
   198
		}
sl@0
   199
	
sl@0
   200
	TLex* lex[KLexNames];
sl@0
   201
	lex[0]=(&name);
sl@0
   202
	lex[1]=(&rel);
sl@0
   203
	lex[2]=(&def);
sl@0
   204
	
sl@0
   205
	name.Mark();
sl@0
   206
	rel.Mark();
sl@0
   207
	def.Mark();
sl@0
   208
	
sl@0
   209
	TInt r;
sl@0
   210
	TInt pos=0;
sl@0
   211
	
sl@0
   212
	for (TInt i=0;i<KLexComponents;i++)
sl@0
   213
		{
sl@0
   214
		TBool done=EFalse;
sl@0
   215
		for (TInt j=0;j<lexnames;j++)
sl@0
   216
			{
sl@0
   217
			if ((r=(this->*parse[i])(*lex[j],done))<KErrNone)
sl@0
   218
				return(r);
sl@0
   219
			if (j==0 && done)
sl@0
   220
				iField[i].present=ETrue;
sl@0
   221
			}
sl@0
   222
		TInt len;
sl@0
   223
		if(iMod)
sl@0
   224
			len=NameBuf().Length()-pos;
sl@0
   225
		else
sl@0
   226
			len=name.MarkedOffset()-pos;
sl@0
   227
		iField[i].len=(TUint8)len;
sl@0
   228
		iField[i].pos=(TUint8)pos;
sl@0
   229
		pos+=len;
sl@0
   230
		}
sl@0
   231
	if (!allowWild && iWild)
sl@0
   232
		return(KErrBadName);
sl@0
   233
	if (iField[EPath].len==1)
sl@0
   234
		iWild|=EIsRoot;
sl@0
   235
	return(KErrNone);
sl@0
   236
	}
sl@0
   237
sl@0
   238
sl@0
   239
sl@0
   240
sl@0
   241
EXPORT_C TInt TParseBase::PopDir()
sl@0
   242
/**
sl@0
   243
Removes the last directory from the path in the fully parsed specification.
sl@0
   244
 
sl@0
   245
This function may be used to navigate up one level in a directory hierarchy.
sl@0
   246
An error is returned if the specified directory is the root.
sl@0
   247
sl@0
   248
@return KErrNone if successful, otherwise one of the other system-wide error 
sl@0
   249
        codes.
sl@0
   250
*/
sl@0
   251
	{
sl@0
   252
sl@0
   253
	if (IsRoot())
sl@0
   254
		return(KErrGeneral);
sl@0
   255
	TInt len;
sl@0
   256
	if (iField[EName].pos==0 && NameBuf().Length()==256)
sl@0
   257
		len=256;
sl@0
   258
	else
sl@0
   259
		len=iField[EName].pos;
sl@0
   260
	TPtrC p(NameBuf().Ptr(),len-1);
sl@0
   261
	TInt pos=p.LocateReverse(KPathDelimiter)+1;
sl@0
   262
	len-=pos;
sl@0
   263
	NameBuf().Delete(pos,len);
sl@0
   264
	iField[EName].pos=(TUint8)(iField[EName].pos-len);
sl@0
   265
	iField[EExt].pos=(TUint8)(iField[EExt].pos-len);
sl@0
   266
	iField[EPath].len=(TUint8)(iField[EPath].len-len);
sl@0
   267
	if (iField[EPath].len==1)
sl@0
   268
		iWild|=EIsRoot;
sl@0
   269
	return(KErrNone);
sl@0
   270
	}
sl@0
   271
sl@0
   272
sl@0
   273
sl@0
   274
sl@0
   275
EXPORT_C TInt TParseBase::AddDir(const TDesC& aName)
sl@0
   276
/**
sl@0
   277
Adds a single directory onto the end of the path in
sl@0
   278
the fully parsed specification. 
sl@0
   279
sl@0
   280
The directory is inserted between the final directory, and the filename, if 
sl@0
   281
there is one.
sl@0
   282
sl@0
   283
@param aName The directory to be added. It must not start with a \\ otherwise 
sl@0
   284
             the function does not recognise it as a valid directory name
sl@0
   285
             and an error is returned.
sl@0
   286
             The directory name must not end with a \\ since the function 
sl@0
   287
             adds this automatically. It must not exceed the maximum
sl@0
   288
             filename length, KMaxFileName characters, otherwise  an error
sl@0
   289
             is returned.
sl@0
   290
sl@0
   291
@return KErrNone if successful, otherwise another of the system-wide error 
sl@0
   292
        codes.   
sl@0
   293
@see KMaxFileName
sl@0
   294
*/
sl@0
   295
	{
sl@0
   296
sl@0
   297
	if (aName.Length()==0)
sl@0
   298
		return(KErrNone);
sl@0
   299
	TInt len=aName.Length()+1;
sl@0
   300
	if ((len+NameBuf().Length())>NameBuf().MaxLength())
sl@0
   301
		return(KErrGeneral);
sl@0
   302
	TInt pos=aName.Locate(KPathDelimiter);
sl@0
   303
	if (pos!=KErrNotFound)
sl@0
   304
		return(KErrBadName);
sl@0
   305
	TFileName n=aName;
sl@0
   306
	n.Append(KPathDelimiter);
sl@0
   307
	NameBuf().Insert(iField[EName].pos,n);
sl@0
   308
	iField[EPath].len=(TUint8)(iField[EPath].len+len);
sl@0
   309
	iField[EName].pos=(TUint8)(iField[EName].pos+len);
sl@0
   310
	iField[EExt].pos=(TUint8)(len+iField[EExt].pos);
sl@0
   311
	if (IsRoot())
sl@0
   312
		iWild&=~EIsRoot;
sl@0
   313
	return(KErrNone);
sl@0
   314
	}
sl@0
   315
sl@0
   316
sl@0
   317
sl@0
   318
sl@0
   319
EXPORT_C const TDesC& TParseBase::FullName() const
sl@0
   320
/**
sl@0
   321
Gets the complete file specification.
sl@0
   322
sl@0
   323
This is in the form:
sl@0
   324
sl@0
   325
drive-letter: \\path\\filename.extension
sl@0
   326
sl@0
   327
@return The fully parsed file specification.
sl@0
   328
*/
sl@0
   329
	{
sl@0
   330
sl@0
   331
	return(NameBufC());
sl@0
   332
	}
sl@0
   333
sl@0
   334
sl@0
   335
sl@0
   336
sl@0
   337
EXPORT_C TPtrC TParseBase::Drive() const
sl@0
   338
/**
sl@0
   339
Gets the drive letter.
sl@0
   340
sl@0
   341
The drive letter is in the form:
sl@0
   342
sl@0
   343
drive-letter:
sl@0
   344
sl@0
   345
Note that the drive letter is folded.
sl@0
   346
sl@0
   347
@return The drive letter and colon.
sl@0
   348
*/
sl@0
   349
	{
sl@0
   350
sl@0
   351
	const SField& f=iField[EDrive];
sl@0
   352
	return(NameBufC().Mid(f.pos,f.len));
sl@0
   353
	}
sl@0
   354
sl@0
   355
sl@0
   356
sl@0
   357
sl@0
   358
EXPORT_C TPtrC TParseBase::Path() const
sl@0
   359
/**
sl@0
   360
Gets the path.
sl@0
   361
sl@0
   362
The path is in the form:
sl@0
   363
sl@0
   364
\\path\\
sl@0
   365
sl@0
   366
@return The path. It always begins and ends in a backslash.
sl@0
   367
*/
sl@0
   368
	{
sl@0
   369
sl@0
   370
	const SField& f=iField[EPath];
sl@0
   371
	return(NameBufC().Mid(f.pos,f.len));
sl@0
   372
	}
sl@0
   373
sl@0
   374
sl@0
   375
sl@0
   376
sl@0
   377
EXPORT_C TPtrC TParseBase::DriveAndPath() const
sl@0
   378
/**
sl@0
   379
Gets the drive letter and path.
sl@0
   380
sl@0
   381
This is in the form
sl@0
   382
sl@0
   383
drive-letter:\\path\\
sl@0
   384
sl@0
   385
Note that the drive letter is folded
sl@0
   386
sl@0
   387
@return The drive and path.
sl@0
   388
*/
sl@0
   389
	{
sl@0
   390
sl@0
   391
	const SField& f=iField[EDrive];
sl@0
   392
	return(NameBufC().Mid(f.pos,f.len+iField[EPath].len));
sl@0
   393
	}
sl@0
   394
sl@0
   395
sl@0
   396
sl@0
   397
sl@0
   398
EXPORT_C TPtrC TParseBase::Name() const
sl@0
   399
/**
sl@0
   400
Gets the filename.
sl@0
   401
sl@0
   402
This is in the form
sl@0
   403
sl@0
   404
filename
sl@0
   405
sl@0
   406
@return The filename.
sl@0
   407
*/
sl@0
   408
	{
sl@0
   409
sl@0
   410
	const SField& f=iField[EName];
sl@0
   411
	return(NameBufC().Mid(f.pos,f.len));
sl@0
   412
	}
sl@0
   413
sl@0
   414
sl@0
   415
sl@0
   416
sl@0
   417
EXPORT_C TPtrC TParseBase::Ext() const
sl@0
   418
/**
sl@0
   419
Gets the extension.
sl@0
   420
sl@0
   421
This is in the form:
sl@0
   422
sl@0
   423
.extension
sl@0
   424
sl@0
   425
@return The extension and preceding dot.
sl@0
   426
*/
sl@0
   427
	{
sl@0
   428
sl@0
   429
	const SField& f=iField[EExt];
sl@0
   430
	return(NameBufC().Mid(f.pos,f.len));
sl@0
   431
	}
sl@0
   432
sl@0
   433
sl@0
   434
sl@0
   435
sl@0
   436
EXPORT_C TPtrC TParseBase::NameAndExt() const
sl@0
   437
/**
sl@0
   438
Gets the filename and extension.
sl@0
   439
sl@0
   440
This is in the form:
sl@0
   441
sl@0
   442
filename.ext
sl@0
   443
sl@0
   444
@return The filename and extension.
sl@0
   445
*/
sl@0
   446
	{
sl@0
   447
sl@0
   448
	const SField& f=iField[EName];
sl@0
   449
	return(NameBufC().Mid(f.pos,f.len+iField[EExt].len));
sl@0
   450
	}
sl@0
   451
sl@0
   452
sl@0
   453
sl@0
   454
sl@0
   455
EXPORT_C TBool TParseBase::DrivePresent() const
sl@0
   456
/**
sl@0
   457
Tests whether a drive is present.
sl@0
   458
sl@0
   459
Note that this function refers to a component 
sl@0
   460
in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild() 
sl@0
   461
or RFs::Parse(), not to the resulting fully parsed file specification.
sl@0
   462
sl@0
   463
@return True if a drive present, false if not.
sl@0
   464
sl@0
   465
@see TParse
sl@0
   466
@see RFs
sl@0
   467
*/
sl@0
   468
	{
sl@0
   469
sl@0
   470
	return(iField[EDrive].present);
sl@0
   471
	}
sl@0
   472
sl@0
   473
sl@0
   474
sl@0
   475
sl@0
   476
EXPORT_C TBool TParseBase::PathPresent() const
sl@0
   477
/**
sl@0
   478
Tests whether a path is present.
sl@0
   479
sl@0
   480
Note that this function refers to a component 
sl@0
   481
in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild() 
sl@0
   482
or RFs::Parse(), not to the resulting fully parsed file specification.
sl@0
   483
sl@0
   484
@return True if a path present, false if not.
sl@0
   485
sl@0
   486
@see TParse
sl@0
   487
@see RFs
sl@0
   488
*/
sl@0
   489
	{
sl@0
   490
sl@0
   491
	return(iField[EPath].present);
sl@0
   492
	}
sl@0
   493
sl@0
   494
sl@0
   495
sl@0
   496
sl@0
   497
EXPORT_C TBool TParseBase::NamePresent() const
sl@0
   498
/**
sl@0
   499
Tests whether a file name is present.
sl@0
   500
sl@0
   501
Note that this function refers to a component 
sl@0
   502
in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild() 
sl@0
   503
or RFs::Parse(), not to the resulting fully parsed file specification.
sl@0
   504
sl@0
   505
This function returns true even if the filename specified in aName contains 
sl@0
   506
only wildcards. It only returns false if nothing is specified.
sl@0
   507
sl@0
   508
@return True if a name present, false if not.
sl@0
   509
*/
sl@0
   510
	{
sl@0
   511
sl@0
   512
	return(iField[EName].present);
sl@0
   513
	}
sl@0
   514
sl@0
   515
sl@0
   516
sl@0
   517
sl@0
   518
EXPORT_C TBool TParseBase::ExtPresent() const
sl@0
   519
/**
sl@0
   520
Tests whether an extension is present.
sl@0
   521
sl@0
   522
Note that this function refers to a component
sl@0
   523
in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild() 
sl@0
   524
or RFs::Parse(), not to the resulting fully parsed file specification.
sl@0
   525
sl@0
   526
This function returns true even if the extension contains only wildcards. 
sl@0
   527
It only returns false if nothing is specified.
sl@0
   528
sl@0
   529
@return True if an extension present, false if not.
sl@0
   530
*/
sl@0
   531
	{
sl@0
   532
sl@0
   533
	return(iField[EExt].present);
sl@0
   534
	}
sl@0
   535
sl@0
   536
sl@0
   537
sl@0
   538
sl@0
   539
EXPORT_C TBool TParseBase::NameOrExtPresent() const
sl@0
   540
/**
sl@0
   541
Tests whether a filename or an extension are present.
sl@0
   542
sl@0
   543
Note that this function refers to a component in the aName argument
sl@0
   544
specified in calls to TParse::Set(), TParse::SetNoWild() or RFs::Parse(), not
sl@0
   545
to the resulting fully parsed file specification.
sl@0
   546
sl@0
   547
This function returns true even if the filename or extension specified in 
sl@0
   548
aName contain only wildcards. It only returns false if nothing is specified.
sl@0
   549
sl@0
   550
@return True if either a name or an extension or both are present,
sl@0
   551
        otherwise false.
sl@0
   552
*/
sl@0
   553
	{
sl@0
   554
sl@0
   555
	return(iField[EName].present || iField[EExt].present);
sl@0
   556
	}
sl@0
   557
sl@0
   558
sl@0
   559
sl@0
   560
sl@0
   561
sl@0
   562
EXPORT_C TBool TParseBase::IsRoot() const
sl@0
   563
/**
sl@0
   564
Tests whether the path in the fully parsed specification is the root directory.
sl@0
   565
sl@0
   566
@return True if path is root, false if not.
sl@0
   567
*/
sl@0
   568
	{
sl@0
   569
sl@0
   570
	return(iWild&EIsRoot);
sl@0
   571
	}
sl@0
   572
sl@0
   573
sl@0
   574
sl@0
   575
sl@0
   576
EXPORT_C TBool TParseBase::IsWild() const
sl@0
   577
/**
sl@0
   578
Tests whether the filename or the extension in the fully parsed specification 
sl@0
   579
contains one or more wildcard characters.
sl@0
   580
sl@0
   581
@return True if wildcards are present, false if not.
sl@0
   582
*/
sl@0
   583
	{
sl@0
   584
sl@0
   585
	return(iWild&EWildEither);	
sl@0
   586
	}
sl@0
   587
sl@0
   588
sl@0
   589
sl@0
   590
sl@0
   591
EXPORT_C TBool TParseBase::IsKMatchOne() const
sl@0
   592
/**
sl@0
   593
Tests whether the name or the extension contains a question mark wildcard.
sl@0
   594
sl@0
   595
@return True if either the name or extension has a ? wild card,
sl@0
   596
        false otherwise.
sl@0
   597
*/
sl@0
   598
	{
sl@0
   599
sl@0
   600
	return(iWild&EWildIsKMatchOne);	
sl@0
   601
	}
sl@0
   602
sl@0
   603
sl@0
   604
sl@0
   605
sl@0
   606
EXPORT_C TBool TParseBase::IsKMatchAny() const
sl@0
   607
/**
sl@0
   608
Tests whether the name or the extension contains asterisk wildcards.
sl@0
   609
sl@0
   610
@return True if either the name or extension has a * wild card,
sl@0
   611
        false otherwise.
sl@0
   612
*/
sl@0
   613
	{
sl@0
   614
sl@0
   615
	return(iWild&EWildIsKMatchAny);	
sl@0
   616
	}
sl@0
   617
sl@0
   618
sl@0
   619
sl@0
   620
sl@0
   621
EXPORT_C TBool TParseBase::IsNameWild() const
sl@0
   622
/**
sl@0
   623
Tests whether the filename in the fully parsed specification contains one or 
sl@0
   624
more wildcard characters.
sl@0
   625
sl@0
   626
@return True if the filename contains wildcard characters, false if not.
sl@0
   627
*/
sl@0
   628
	{
sl@0
   629
sl@0
   630
	return(iWild&EWildName);
sl@0
   631
	}
sl@0
   632
sl@0
   633
sl@0
   634
sl@0
   635
sl@0
   636
EXPORT_C TBool TParseBase::IsExtWild() const
sl@0
   637
/**
sl@0
   638
Tests whether the extension in the fully parsed specification contains one 
sl@0
   639
or more wildcard characters.
sl@0
   640
sl@0
   641
@return True if the extension contains wildcard characters, false if not.
sl@0
   642
*/
sl@0
   643
	{
sl@0
   644
sl@0
   645
	return(iWild&EWildExt);
sl@0
   646
	}
sl@0
   647
sl@0
   648
sl@0
   649
sl@0
   650
sl@0
   651
EXPORT_C TParse::TParse()
sl@0
   652
/**
sl@0
   653
Default constructor.
sl@0
   654
*/
sl@0
   655
	{
sl@0
   656
	iMod=1;
sl@0
   657
	}
sl@0
   658
sl@0
   659
sl@0
   660
sl@0
   661
sl@0
   662
EXPORT_C TInt TParse::Set(const TDesC& aName,const TDesC* aRelated,const TDesC* aDefault)
sl@0
   663
/**
sl@0
   664
Parses a file specification, allowing wildcards in the filename and extension.
sl@0
   665
sl@0
   666
This function sets up the TParse object so that it can be used to provide 
sl@0
   667
useful information.
sl@0
   668
sl@0
   669
@param aName    The file specification to be parsed.
sl@0
   670
@param aRelated The related file specification. This is optional,
sl@0
   671
                set to NULL to  omit.
sl@0
   672
@param aDefault The default file specification. This is optional,
sl@0
   673
                set to NULL to omit.
sl@0
   674
                
sl@0
   675
@return KErrNone, if successful, otherwise one of the other system-wide error
sl@0
   676
        codes.
sl@0
   677
*/
sl@0
   678
	{
sl@0
   679
sl@0
   680
	return(TParseBase::Set(&aName,aRelated,aDefault,ETrue));
sl@0
   681
	}
sl@0
   682
sl@0
   683
sl@0
   684
sl@0
   685
sl@0
   686
EXPORT_C TInt TParse::SetNoWild(const TDesC& aName,const TDesC* aRelated,const TDesC* aDefault)
sl@0
   687
/**
sl@0
   688
Parses a file specification; disallows wildcards in any part of the file name 
sl@0
   689
or extension.
sl@0
   690
sl@0
   691
If you need to specify wildcards use Set(). Otherwise, this 
sl@0
   692
function behaves in the same way as Set().
sl@0
   693
sl@0
   694
@param aName    The file specification to be parsed.
sl@0
   695
@param aRelated The related file specification. This is optional,
sl@0
   696
                set to NULL to omit.
sl@0
   697
@param aDefault The default file specification. This is optional,
sl@0
   698
                set to NULL to omit.
sl@0
   699
                
sl@0
   700
@return KErrNone, if successful, otherwise one of the other system-wide error 
sl@0
   701
        codes.
sl@0
   702
sl@0
   703
@see TParse::Set
sl@0
   704
*/
sl@0
   705
	{
sl@0
   706
sl@0
   707
	return(TParseBase::Set(&aName,aRelated,aDefault,EFalse));
sl@0
   708
	}
sl@0
   709
sl@0
   710
sl@0
   711
sl@0
   712
sl@0
   713
EXPORT_C TDes& TParse::NameBuf()
sl@0
   714
/**
sl@0
   715
Gets a reference to the descriptor containing the file specification passed to
sl@0
   716
the constructor of this object. 
sl@0
   717
sl@0
   718
@return A reference to the descriptor containing the filename.
sl@0
   719
*/
sl@0
   720
	{
sl@0
   721
sl@0
   722
	return(iNameBuf);
sl@0
   723
	}
sl@0
   724
sl@0
   725
sl@0
   726
sl@0
   727
sl@0
   728
EXPORT_C const TDesC& TParse::NameBufC() const
sl@0
   729
/**
sl@0
   730
Gets a const reference to the descriptor containing the file specification
sl@0
   731
passed to the constructor of this object. 
sl@0
   732
sl@0
   733
@return A const reference to the descriptor containing the file specification.
sl@0
   734
*/
sl@0
   735
	{
sl@0
   736
sl@0
   737
	return(iNameBuf);
sl@0
   738
	}
sl@0
   739
sl@0
   740
sl@0
   741
sl@0
   742
sl@0
   743
EXPORT_C TParsePtr::TParsePtr(TDes& aName)
sl@0
   744
	: iNameBuf((TText*)aName.Ptr(),aName.Length(),aName.MaxLength())
sl@0
   745
/**
sl@0
   746
Constructor taking a reference to a filename.
sl@0
   747
sl@0
   748
The specified filename is parsed and if this fails, a panic is raised.
sl@0
   749
sl@0
   750
@param aName Reference to the filename to be parsed. On return contains
sl@0
   751
             the fully parsed path specification. If a filename and extension
sl@0
   752
             are specified, they may both contain wildcards.
sl@0
   753
             The maximum length is KMaxFileName characters.
sl@0
   754
             
sl@0
   755
@panic FSCLIENT 24 if the the specified name fails to parse.
sl@0
   756
             
sl@0
   757
@see KMaxFileName
sl@0
   758
*/
sl@0
   759
	{
sl@0
   760
	iMod=1;
sl@0
   761
	TInt r=TParseBase::Set(&aName,NULL,NULL,ETrue);
sl@0
   762
	__ASSERT_ALWAYS(r==KErrNone,Panic(EParsePtrBadDescriptor0));
sl@0
   763
	}
sl@0
   764
sl@0
   765
sl@0
   766
sl@0
   767
sl@0
   768
EXPORT_C TDes& TParsePtr::NameBuf()
sl@0
   769
/**
sl@0
   770
Gets a reference to the descriptor containing the filename passed to
sl@0
   771
the constructor of this object. 
sl@0
   772
sl@0
   773
@return A reference to the descriptor containing the filename.
sl@0
   774
*/
sl@0
   775
	{
sl@0
   776
sl@0
   777
	return(iNameBuf);
sl@0
   778
	}
sl@0
   779
sl@0
   780
sl@0
   781
sl@0
   782
sl@0
   783
EXPORT_C const TDesC& TParsePtr::NameBufC() const
sl@0
   784
/**
sl@0
   785
Gets a const reference to the descriptor containing the filename passed to
sl@0
   786
the constructor of this object. 
sl@0
   787
sl@0
   788
@return A const reference to the descriptor containing the filename.
sl@0
   789
*/
sl@0
   790
	{
sl@0
   791
sl@0
   792
	return(iNameBuf);
sl@0
   793
	}
sl@0
   794
sl@0
   795
sl@0
   796
sl@0
   797
sl@0
   798
EXPORT_C TParsePtrC::TParsePtrC(const TDesC& aName)
sl@0
   799
/**
sl@0
   800
Constructor taking a constant reference to a filename.
sl@0
   801
sl@0
   802
The filename is parsed and if this fails, a panic is raised.
sl@0
   803
Note that the filename cannot be modified using this class.
sl@0
   804
sl@0
   805
@param aName Constant reference to the filename to be parsed.
sl@0
   806
             On return contains the fully parsed filename.
sl@0
   807
             If a file and extension are specified, they may both
sl@0
   808
             contain wildcards.
sl@0
   809
             The maximum length is KMaxFileName characters.
sl@0
   810
             
sl@0
   811
@panic FSCLIENT 24 if the the specified name fails to parse.
sl@0
   812
sl@0
   813
@see KMaxFileName
sl@0
   814
*/
sl@0
   815
	{
sl@0
   816
	iMod=0;
sl@0
   817
	iNameBuf.Set(aName);
sl@0
   818
	TInt r = TParseBase::Set(&aName,NULL,NULL,ETrue);
sl@0
   819
	__ASSERT_ALWAYS(r==KErrNone,Panic(EParsePtrBadDescriptor0));
sl@0
   820
	}
sl@0
   821
sl@0
   822
sl@0
   823
sl@0
   824
sl@0
   825
EXPORT_C TDes& TParsePtrC::NameBuf()
sl@0
   826
/**
sl@0
   827
Gets a reference to the descriptor containing the filename passed to
sl@0
   828
the constructor of this object. 
sl@0
   829
sl@0
   830
@return A reference to the descriptor containing the filename.
sl@0
   831
*/
sl@0
   832
	{
sl@0
   833
sl@0
   834
	Panic(EParsePtrCAccessError);
sl@0
   835
	return(*(TDes*)&iNameBuf);
sl@0
   836
	}
sl@0
   837
sl@0
   838
sl@0
   839
sl@0
   840
sl@0
   841
EXPORT_C const TDesC& TParsePtrC::NameBufC() const
sl@0
   842
/**
sl@0
   843
Gets a const reference to the descriptor containing the filename passed to
sl@0
   844
the constructor of this object. 
sl@0
   845
sl@0
   846
@return A const reference to the descriptor containing the filename.
sl@0
   847
*/
sl@0
   848
	{
sl@0
   849
sl@0
   850
	return(iNameBuf);
sl@0
   851
	}
sl@0
   852