1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfsrv/cl_parse.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,852 @@
1.4 +// Copyright (c) 1995-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 +// f32\sfsrv\cl_parse.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "cl_std.h"
1.22 +
1.23 +const TInt KLexComponents=4;
1.24 +const TInt KLexNames=3;
1.25 +
1.26 +
1.27 +
1.28 +
1.29 +EXPORT_C TParseBase::TParseBase()
1.30 + : iWild(0)
1.31 +/**
1.32 +Default constructor.
1.33 +*/
1.34 + {
1.35 +
1.36 + Mem::FillZ(&iField[0],sizeof(iField));
1.37 + }
1.38 +
1.39 +
1.40 +
1.41 +
1.42 +TInt TParseBase::ParseDrive(TLex& aName,TBool& aDone)
1.43 +//
1.44 +// Parse the drive name.
1.45 +//
1.46 + {
1.47 +
1.48 + TPtrC d=aName.RemainderFromMark();
1.49 + if (d.Length()<2 || d[1]!=KDriveDelimiter)
1.50 + return(KErrNone); //must be Drive delimeter and longer that tow to be valid drive
1.51 + TCharF c=d[0];
1.52 + if (!c.IsAlpha()) //must be alphaber letter
1.53 + return(KErrBadName);
1.54 + if (!aDone)
1.55 + {
1.56 + if(iMod)
1.57 + NameBuf()+=d.Left(2);
1.58 + aDone=ETrue;
1.59 + }
1.60 + aName.SkipAndMark(2);
1.61 + return(KErrNone);
1.62 + }
1.63 +
1.64 +TInt TParseBase::ParsePath(TLex& aName,TBool& aDone)
1.65 +//
1.66 +// Parse the path.
1.67 +//
1.68 + {
1.69 +
1.70 + TPtrC d=aName.RemainderFromMark();
1.71 + if (d.Length() && d[0]!=KPathDelimiter)
1.72 + return(KErrNone); // Require first char of path to be a '\'
1.73 + TInt n=d.LocateReverse(KPathDelimiter)+1;
1.74 + if (n && !aDone)
1.75 + {
1.76 + if(iMod)
1.77 + {
1.78 + if (NameBuf().Length()+n>KMaxFileName)
1.79 + return(KErrBadName);
1.80 + NameBuf()+=d.Left(n);
1.81 + }
1.82 + aDone=ETrue;
1.83 + }
1.84 + aName.SkipAndMark(n);
1.85 + return(KErrNone);
1.86 + }
1.87 +
1.88 +LOCAL_C TBool IsSpace(const TDesC& aDes)
1.89 +//
1.90 +// Returns ETrue if aDes only contains spaces or is zero length
1.91 +//
1.92 + {
1.93 +
1.94 + TInt len=aDes.Length();
1.95 + for (TInt i=0;i<len;i++)
1.96 + {
1.97 + TChar txt=aDes[i];
1.98 + if (!txt.IsSpace())
1.99 + return(EFalse);
1.100 + }
1.101 + return(ETrue);
1.102 + }
1.103 +
1.104 +TInt TParseBase::ParseName(TLex& aName,TBool& aDone)
1.105 +//
1.106 +// Parse the name.
1.107 +//
1.108 + {
1.109 +
1.110 + TPtrC d=aName.RemainderFromMark();
1.111 + if (d.Locate(KPathDelimiter)!=KErrNotFound)
1.112 + return(KErrBadName); // Illegal name - filenames cannot contain a '\'
1.113 + TInt n=d.LocateReverse(KExtDelimiter);
1.114 + if (n==KErrNotFound)
1.115 + {
1.116 + n=d.Length();
1.117 + if (IsSpace(d.Left(n)))
1.118 + return(KErrNone);
1.119 + }
1.120 + TPtrC v=d.Left(n);
1.121 + if (n && !aDone)
1.122 + {
1.123 + if (v.Locate(KMatchOne)!=KErrNotFound) // Found ? in the name
1.124 + iWild|=(EWildName|EWildEither|EWildIsKMatchOne);
1.125 + if (v.Locate(KMatchAny)!=KErrNotFound) // Found * in the name
1.126 + iWild|=(EWildName|EWildEither|EWildIsKMatchAny);
1.127 + if(iMod)
1.128 + {
1.129 + if (NameBuf().Length()+n>KMaxFileName)
1.130 + return(KErrBadName);
1.131 + NameBuf()+=v;
1.132 + if (n==d.Length())
1.133 + NameBuf().TrimRight();
1.134 + }
1.135 + aDone=ETrue;
1.136 + }
1.137 + aName.SkipAndMark(n);
1.138 + return(KErrNone);
1.139 + }
1.140 +
1.141 +TInt TParseBase::ParseExt(TLex& aName,TBool& aDone)
1.142 +//
1.143 +// Parse the extension.
1.144 +//
1.145 + {
1.146 +
1.147 + TPtrC d=aName.RemainderFromMark();
1.148 + if (d.Length() && !IsSpace(d) && !aDone)
1.149 + {
1.150 + if (d.Locate(KMatchOne)!=KErrNotFound) // Found ? in the name
1.151 + iWild|=(EWildExt|EWildEither|EWildIsKMatchOne);
1.152 + if (d.Locate(KMatchAny)!=KErrNotFound) // Found * in the name
1.153 + iWild|=(EWildExt|EWildEither|EWildIsKMatchAny);
1.154 +
1.155 + if(iMod)
1.156 + {
1.157 + if (NameBuf().Length()+d.Length()>KMaxFileName)
1.158 + return(KErrBadName);
1.159 + NameBuf()+=d;
1.160 + NameBuf().TrimRight();
1.161 + }
1.162 + else
1.163 + aName.SkipAndMark(d.Length());
1.164 + aDone=ETrue;
1.165 + }
1.166 + return(KErrNone);
1.167 + }
1.168 +
1.169 +TInt TParseBase::Set(const TDesC* aName,const TDesC* aRelated,const TDesC* aDefault,TBool allowWild)
1.170 +//
1.171 +// Parse a name. Optionally allow wild cards.
1.172 +//
1.173 + {
1.174 +
1.175 + TInt (TParseBase::*parse[KLexComponents])(TLex& aName,TBool& aDone);
1.176 + parse[0]=&TParseBase::ParseDrive;
1.177 + parse[1]=&TParseBase::ParsePath;
1.178 + parse[2]=&TParseBase::ParseName;
1.179 + parse[3]=&TParseBase::ParseExt;
1.180 +
1.181 + iWild=0;
1.182 +
1.183 + Mem::FillZ(&iField[0],sizeof(iField));
1.184 +
1.185 + TLex name(*aName);
1.186 + TLex def;
1.187 + TLex rel;
1.188 + TInt lexnames;
1.189 + if(iMod)
1.190 + {
1.191 + if (aRelated)
1.192 + rel=(*aRelated);
1.193 + if (aDefault)
1.194 + def=(*aDefault);
1.195 + NameBuf().Zero();
1.196 + lexnames = KLexNames;
1.197 + }
1.198 + else
1.199 + {
1.200 + lexnames = 1;
1.201 + }
1.202 +
1.203 + TLex* lex[KLexNames];
1.204 + lex[0]=(&name);
1.205 + lex[1]=(&rel);
1.206 + lex[2]=(&def);
1.207 +
1.208 + name.Mark();
1.209 + rel.Mark();
1.210 + def.Mark();
1.211 +
1.212 + TInt r;
1.213 + TInt pos=0;
1.214 +
1.215 + for (TInt i=0;i<KLexComponents;i++)
1.216 + {
1.217 + TBool done=EFalse;
1.218 + for (TInt j=0;j<lexnames;j++)
1.219 + {
1.220 + if ((r=(this->*parse[i])(*lex[j],done))<KErrNone)
1.221 + return(r);
1.222 + if (j==0 && done)
1.223 + iField[i].present=ETrue;
1.224 + }
1.225 + TInt len;
1.226 + if(iMod)
1.227 + len=NameBuf().Length()-pos;
1.228 + else
1.229 + len=name.MarkedOffset()-pos;
1.230 + iField[i].len=(TUint8)len;
1.231 + iField[i].pos=(TUint8)pos;
1.232 + pos+=len;
1.233 + }
1.234 + if (!allowWild && iWild)
1.235 + return(KErrBadName);
1.236 + if (iField[EPath].len==1)
1.237 + iWild|=EIsRoot;
1.238 + return(KErrNone);
1.239 + }
1.240 +
1.241 +
1.242 +
1.243 +
1.244 +EXPORT_C TInt TParseBase::PopDir()
1.245 +/**
1.246 +Removes the last directory from the path in the fully parsed specification.
1.247 +
1.248 +This function may be used to navigate up one level in a directory hierarchy.
1.249 +An error is returned if the specified directory is the root.
1.250 +
1.251 +@return KErrNone if successful, otherwise one of the other system-wide error
1.252 + codes.
1.253 +*/
1.254 + {
1.255 +
1.256 + if (IsRoot())
1.257 + return(KErrGeneral);
1.258 + TInt len;
1.259 + if (iField[EName].pos==0 && NameBuf().Length()==256)
1.260 + len=256;
1.261 + else
1.262 + len=iField[EName].pos;
1.263 + TPtrC p(NameBuf().Ptr(),len-1);
1.264 + TInt pos=p.LocateReverse(KPathDelimiter)+1;
1.265 + len-=pos;
1.266 + NameBuf().Delete(pos,len);
1.267 + iField[EName].pos=(TUint8)(iField[EName].pos-len);
1.268 + iField[EExt].pos=(TUint8)(iField[EExt].pos-len);
1.269 + iField[EPath].len=(TUint8)(iField[EPath].len-len);
1.270 + if (iField[EPath].len==1)
1.271 + iWild|=EIsRoot;
1.272 + return(KErrNone);
1.273 + }
1.274 +
1.275 +
1.276 +
1.277 +
1.278 +EXPORT_C TInt TParseBase::AddDir(const TDesC& aName)
1.279 +/**
1.280 +Adds a single directory onto the end of the path in
1.281 +the fully parsed specification.
1.282 +
1.283 +The directory is inserted between the final directory, and the filename, if
1.284 +there is one.
1.285 +
1.286 +@param aName The directory to be added. It must not start with a \\ otherwise
1.287 + the function does not recognise it as a valid directory name
1.288 + and an error is returned.
1.289 + The directory name must not end with a \\ since the function
1.290 + adds this automatically. It must not exceed the maximum
1.291 + filename length, KMaxFileName characters, otherwise an error
1.292 + is returned.
1.293 +
1.294 +@return KErrNone if successful, otherwise another of the system-wide error
1.295 + codes.
1.296 +@see KMaxFileName
1.297 +*/
1.298 + {
1.299 +
1.300 + if (aName.Length()==0)
1.301 + return(KErrNone);
1.302 + TInt len=aName.Length()+1;
1.303 + if ((len+NameBuf().Length())>NameBuf().MaxLength())
1.304 + return(KErrGeneral);
1.305 + TInt pos=aName.Locate(KPathDelimiter);
1.306 + if (pos!=KErrNotFound)
1.307 + return(KErrBadName);
1.308 + TFileName n=aName;
1.309 + n.Append(KPathDelimiter);
1.310 + NameBuf().Insert(iField[EName].pos,n);
1.311 + iField[EPath].len=(TUint8)(iField[EPath].len+len);
1.312 + iField[EName].pos=(TUint8)(iField[EName].pos+len);
1.313 + iField[EExt].pos=(TUint8)(len+iField[EExt].pos);
1.314 + if (IsRoot())
1.315 + iWild&=~EIsRoot;
1.316 + return(KErrNone);
1.317 + }
1.318 +
1.319 +
1.320 +
1.321 +
1.322 +EXPORT_C const TDesC& TParseBase::FullName() const
1.323 +/**
1.324 +Gets the complete file specification.
1.325 +
1.326 +This is in the form:
1.327 +
1.328 +drive-letter: \\path\\filename.extension
1.329 +
1.330 +@return The fully parsed file specification.
1.331 +*/
1.332 + {
1.333 +
1.334 + return(NameBufC());
1.335 + }
1.336 +
1.337 +
1.338 +
1.339 +
1.340 +EXPORT_C TPtrC TParseBase::Drive() const
1.341 +/**
1.342 +Gets the drive letter.
1.343 +
1.344 +The drive letter is in the form:
1.345 +
1.346 +drive-letter:
1.347 +
1.348 +Note that the drive letter is folded.
1.349 +
1.350 +@return The drive letter and colon.
1.351 +*/
1.352 + {
1.353 +
1.354 + const SField& f=iField[EDrive];
1.355 + return(NameBufC().Mid(f.pos,f.len));
1.356 + }
1.357 +
1.358 +
1.359 +
1.360 +
1.361 +EXPORT_C TPtrC TParseBase::Path() const
1.362 +/**
1.363 +Gets the path.
1.364 +
1.365 +The path is in the form:
1.366 +
1.367 +\\path\\
1.368 +
1.369 +@return The path. It always begins and ends in a backslash.
1.370 +*/
1.371 + {
1.372 +
1.373 + const SField& f=iField[EPath];
1.374 + return(NameBufC().Mid(f.pos,f.len));
1.375 + }
1.376 +
1.377 +
1.378 +
1.379 +
1.380 +EXPORT_C TPtrC TParseBase::DriveAndPath() const
1.381 +/**
1.382 +Gets the drive letter and path.
1.383 +
1.384 +This is in the form
1.385 +
1.386 +drive-letter:\\path\\
1.387 +
1.388 +Note that the drive letter is folded
1.389 +
1.390 +@return The drive and path.
1.391 +*/
1.392 + {
1.393 +
1.394 + const SField& f=iField[EDrive];
1.395 + return(NameBufC().Mid(f.pos,f.len+iField[EPath].len));
1.396 + }
1.397 +
1.398 +
1.399 +
1.400 +
1.401 +EXPORT_C TPtrC TParseBase::Name() const
1.402 +/**
1.403 +Gets the filename.
1.404 +
1.405 +This is in the form
1.406 +
1.407 +filename
1.408 +
1.409 +@return The filename.
1.410 +*/
1.411 + {
1.412 +
1.413 + const SField& f=iField[EName];
1.414 + return(NameBufC().Mid(f.pos,f.len));
1.415 + }
1.416 +
1.417 +
1.418 +
1.419 +
1.420 +EXPORT_C TPtrC TParseBase::Ext() const
1.421 +/**
1.422 +Gets the extension.
1.423 +
1.424 +This is in the form:
1.425 +
1.426 +.extension
1.427 +
1.428 +@return The extension and preceding dot.
1.429 +*/
1.430 + {
1.431 +
1.432 + const SField& f=iField[EExt];
1.433 + return(NameBufC().Mid(f.pos,f.len));
1.434 + }
1.435 +
1.436 +
1.437 +
1.438 +
1.439 +EXPORT_C TPtrC TParseBase::NameAndExt() const
1.440 +/**
1.441 +Gets the filename and extension.
1.442 +
1.443 +This is in the form:
1.444 +
1.445 +filename.ext
1.446 +
1.447 +@return The filename and extension.
1.448 +*/
1.449 + {
1.450 +
1.451 + const SField& f=iField[EName];
1.452 + return(NameBufC().Mid(f.pos,f.len+iField[EExt].len));
1.453 + }
1.454 +
1.455 +
1.456 +
1.457 +
1.458 +EXPORT_C TBool TParseBase::DrivePresent() const
1.459 +/**
1.460 +Tests whether a drive is present.
1.461 +
1.462 +Note that this function refers to a component
1.463 +in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild()
1.464 +or RFs::Parse(), not to the resulting fully parsed file specification.
1.465 +
1.466 +@return True if a drive present, false if not.
1.467 +
1.468 +@see TParse
1.469 +@see RFs
1.470 +*/
1.471 + {
1.472 +
1.473 + return(iField[EDrive].present);
1.474 + }
1.475 +
1.476 +
1.477 +
1.478 +
1.479 +EXPORT_C TBool TParseBase::PathPresent() const
1.480 +/**
1.481 +Tests whether a path is present.
1.482 +
1.483 +Note that this function refers to a component
1.484 +in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild()
1.485 +or RFs::Parse(), not to the resulting fully parsed file specification.
1.486 +
1.487 +@return True if a path present, false if not.
1.488 +
1.489 +@see TParse
1.490 +@see RFs
1.491 +*/
1.492 + {
1.493 +
1.494 + return(iField[EPath].present);
1.495 + }
1.496 +
1.497 +
1.498 +
1.499 +
1.500 +EXPORT_C TBool TParseBase::NamePresent() const
1.501 +/**
1.502 +Tests whether a file name is present.
1.503 +
1.504 +Note that this function refers to a component
1.505 +in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild()
1.506 +or RFs::Parse(), not to the resulting fully parsed file specification.
1.507 +
1.508 +This function returns true even if the filename specified in aName contains
1.509 +only wildcards. It only returns false if nothing is specified.
1.510 +
1.511 +@return True if a name present, false if not.
1.512 +*/
1.513 + {
1.514 +
1.515 + return(iField[EName].present);
1.516 + }
1.517 +
1.518 +
1.519 +
1.520 +
1.521 +EXPORT_C TBool TParseBase::ExtPresent() const
1.522 +/**
1.523 +Tests whether an extension is present.
1.524 +
1.525 +Note that this function refers to a component
1.526 +in the aName argument specified in calls to TParse::Set(), TParse::SetNoWild()
1.527 +or RFs::Parse(), not to the resulting fully parsed file specification.
1.528 +
1.529 +This function returns true even if the extension contains only wildcards.
1.530 +It only returns false if nothing is specified.
1.531 +
1.532 +@return True if an extension present, false if not.
1.533 +*/
1.534 + {
1.535 +
1.536 + return(iField[EExt].present);
1.537 + }
1.538 +
1.539 +
1.540 +
1.541 +
1.542 +EXPORT_C TBool TParseBase::NameOrExtPresent() const
1.543 +/**
1.544 +Tests whether a filename or an extension are present.
1.545 +
1.546 +Note that this function refers to a component in the aName argument
1.547 +specified in calls to TParse::Set(), TParse::SetNoWild() or RFs::Parse(), not
1.548 +to the resulting fully parsed file specification.
1.549 +
1.550 +This function returns true even if the filename or extension specified in
1.551 +aName contain only wildcards. It only returns false if nothing is specified.
1.552 +
1.553 +@return True if either a name or an extension or both are present,
1.554 + otherwise false.
1.555 +*/
1.556 + {
1.557 +
1.558 + return(iField[EName].present || iField[EExt].present);
1.559 + }
1.560 +
1.561 +
1.562 +
1.563 +
1.564 +
1.565 +EXPORT_C TBool TParseBase::IsRoot() const
1.566 +/**
1.567 +Tests whether the path in the fully parsed specification is the root directory.
1.568 +
1.569 +@return True if path is root, false if not.
1.570 +*/
1.571 + {
1.572 +
1.573 + return(iWild&EIsRoot);
1.574 + }
1.575 +
1.576 +
1.577 +
1.578 +
1.579 +EXPORT_C TBool TParseBase::IsWild() const
1.580 +/**
1.581 +Tests whether the filename or the extension in the fully parsed specification
1.582 +contains one or more wildcard characters.
1.583 +
1.584 +@return True if wildcards are present, false if not.
1.585 +*/
1.586 + {
1.587 +
1.588 + return(iWild&EWildEither);
1.589 + }
1.590 +
1.591 +
1.592 +
1.593 +
1.594 +EXPORT_C TBool TParseBase::IsKMatchOne() const
1.595 +/**
1.596 +Tests whether the name or the extension contains a question mark wildcard.
1.597 +
1.598 +@return True if either the name or extension has a ? wild card,
1.599 + false otherwise.
1.600 +*/
1.601 + {
1.602 +
1.603 + return(iWild&EWildIsKMatchOne);
1.604 + }
1.605 +
1.606 +
1.607 +
1.608 +
1.609 +EXPORT_C TBool TParseBase::IsKMatchAny() const
1.610 +/**
1.611 +Tests whether the name or the extension contains asterisk wildcards.
1.612 +
1.613 +@return True if either the name or extension has a * wild card,
1.614 + false otherwise.
1.615 +*/
1.616 + {
1.617 +
1.618 + return(iWild&EWildIsKMatchAny);
1.619 + }
1.620 +
1.621 +
1.622 +
1.623 +
1.624 +EXPORT_C TBool TParseBase::IsNameWild() const
1.625 +/**
1.626 +Tests whether the filename in the fully parsed specification contains one or
1.627 +more wildcard characters.
1.628 +
1.629 +@return True if the filename contains wildcard characters, false if not.
1.630 +*/
1.631 + {
1.632 +
1.633 + return(iWild&EWildName);
1.634 + }
1.635 +
1.636 +
1.637 +
1.638 +
1.639 +EXPORT_C TBool TParseBase::IsExtWild() const
1.640 +/**
1.641 +Tests whether the extension in the fully parsed specification contains one
1.642 +or more wildcard characters.
1.643 +
1.644 +@return True if the extension contains wildcard characters, false if not.
1.645 +*/
1.646 + {
1.647 +
1.648 + return(iWild&EWildExt);
1.649 + }
1.650 +
1.651 +
1.652 +
1.653 +
1.654 +EXPORT_C TParse::TParse()
1.655 +/**
1.656 +Default constructor.
1.657 +*/
1.658 + {
1.659 + iMod=1;
1.660 + }
1.661 +
1.662 +
1.663 +
1.664 +
1.665 +EXPORT_C TInt TParse::Set(const TDesC& aName,const TDesC* aRelated,const TDesC* aDefault)
1.666 +/**
1.667 +Parses a file specification, allowing wildcards in the filename and extension.
1.668 +
1.669 +This function sets up the TParse object so that it can be used to provide
1.670 +useful information.
1.671 +
1.672 +@param aName The file specification to be parsed.
1.673 +@param aRelated The related file specification. This is optional,
1.674 + set to NULL to omit.
1.675 +@param aDefault The default file specification. This is optional,
1.676 + set to NULL to omit.
1.677 +
1.678 +@return KErrNone, if successful, otherwise one of the other system-wide error
1.679 + codes.
1.680 +*/
1.681 + {
1.682 +
1.683 + return(TParseBase::Set(&aName,aRelated,aDefault,ETrue));
1.684 + }
1.685 +
1.686 +
1.687 +
1.688 +
1.689 +EXPORT_C TInt TParse::SetNoWild(const TDesC& aName,const TDesC* aRelated,const TDesC* aDefault)
1.690 +/**
1.691 +Parses a file specification; disallows wildcards in any part of the file name
1.692 +or extension.
1.693 +
1.694 +If you need to specify wildcards use Set(). Otherwise, this
1.695 +function behaves in the same way as Set().
1.696 +
1.697 +@param aName The file specification to be parsed.
1.698 +@param aRelated The related file specification. This is optional,
1.699 + set to NULL to omit.
1.700 +@param aDefault The default file specification. This is optional,
1.701 + set to NULL to omit.
1.702 +
1.703 +@return KErrNone, if successful, otherwise one of the other system-wide error
1.704 + codes.
1.705 +
1.706 +@see TParse::Set
1.707 +*/
1.708 + {
1.709 +
1.710 + return(TParseBase::Set(&aName,aRelated,aDefault,EFalse));
1.711 + }
1.712 +
1.713 +
1.714 +
1.715 +
1.716 +EXPORT_C TDes& TParse::NameBuf()
1.717 +/**
1.718 +Gets a reference to the descriptor containing the file specification passed to
1.719 +the constructor of this object.
1.720 +
1.721 +@return A reference to the descriptor containing the filename.
1.722 +*/
1.723 + {
1.724 +
1.725 + return(iNameBuf);
1.726 + }
1.727 +
1.728 +
1.729 +
1.730 +
1.731 +EXPORT_C const TDesC& TParse::NameBufC() const
1.732 +/**
1.733 +Gets a const reference to the descriptor containing the file specification
1.734 +passed to the constructor of this object.
1.735 +
1.736 +@return A const reference to the descriptor containing the file specification.
1.737 +*/
1.738 + {
1.739 +
1.740 + return(iNameBuf);
1.741 + }
1.742 +
1.743 +
1.744 +
1.745 +
1.746 +EXPORT_C TParsePtr::TParsePtr(TDes& aName)
1.747 + : iNameBuf((TText*)aName.Ptr(),aName.Length(),aName.MaxLength())
1.748 +/**
1.749 +Constructor taking a reference to a filename.
1.750 +
1.751 +The specified filename is parsed and if this fails, a panic is raised.
1.752 +
1.753 +@param aName Reference to the filename to be parsed. On return contains
1.754 + the fully parsed path specification. If a filename and extension
1.755 + are specified, they may both contain wildcards.
1.756 + The maximum length is KMaxFileName characters.
1.757 +
1.758 +@panic FSCLIENT 24 if the the specified name fails to parse.
1.759 +
1.760 +@see KMaxFileName
1.761 +*/
1.762 + {
1.763 + iMod=1;
1.764 + TInt r=TParseBase::Set(&aName,NULL,NULL,ETrue);
1.765 + __ASSERT_ALWAYS(r==KErrNone,Panic(EParsePtrBadDescriptor0));
1.766 + }
1.767 +
1.768 +
1.769 +
1.770 +
1.771 +EXPORT_C TDes& TParsePtr::NameBuf()
1.772 +/**
1.773 +Gets a reference to the descriptor containing the filename passed to
1.774 +the constructor of this object.
1.775 +
1.776 +@return A reference to the descriptor containing the filename.
1.777 +*/
1.778 + {
1.779 +
1.780 + return(iNameBuf);
1.781 + }
1.782 +
1.783 +
1.784 +
1.785 +
1.786 +EXPORT_C const TDesC& TParsePtr::NameBufC() const
1.787 +/**
1.788 +Gets a const reference to the descriptor containing the filename passed to
1.789 +the constructor of this object.
1.790 +
1.791 +@return A const reference to the descriptor containing the filename.
1.792 +*/
1.793 + {
1.794 +
1.795 + return(iNameBuf);
1.796 + }
1.797 +
1.798 +
1.799 +
1.800 +
1.801 +EXPORT_C TParsePtrC::TParsePtrC(const TDesC& aName)
1.802 +/**
1.803 +Constructor taking a constant reference to a filename.
1.804 +
1.805 +The filename is parsed and if this fails, a panic is raised.
1.806 +Note that the filename cannot be modified using this class.
1.807 +
1.808 +@param aName Constant reference to the filename to be parsed.
1.809 + On return contains the fully parsed filename.
1.810 + If a file and extension are specified, they may both
1.811 + contain wildcards.
1.812 + The maximum length is KMaxFileName characters.
1.813 +
1.814 +@panic FSCLIENT 24 if the the specified name fails to parse.
1.815 +
1.816 +@see KMaxFileName
1.817 +*/
1.818 + {
1.819 + iMod=0;
1.820 + iNameBuf.Set(aName);
1.821 + TInt r = TParseBase::Set(&aName,NULL,NULL,ETrue);
1.822 + __ASSERT_ALWAYS(r==KErrNone,Panic(EParsePtrBadDescriptor0));
1.823 + }
1.824 +
1.825 +
1.826 +
1.827 +
1.828 +EXPORT_C TDes& TParsePtrC::NameBuf()
1.829 +/**
1.830 +Gets a reference to the descriptor containing the filename passed to
1.831 +the constructor of this object.
1.832 +
1.833 +@return A reference to the descriptor containing the filename.
1.834 +*/
1.835 + {
1.836 +
1.837 + Panic(EParsePtrCAccessError);
1.838 + return(*(TDes*)&iNameBuf);
1.839 + }
1.840 +
1.841 +
1.842 +
1.843 +
1.844 +EXPORT_C const TDesC& TParsePtrC::NameBufC() const
1.845 +/**
1.846 +Gets a const reference to the descriptor containing the filename passed to
1.847 +the constructor of this object.
1.848 +
1.849 +@return A const reference to the descriptor containing the filename.
1.850 +*/
1.851 + {
1.852 +
1.853 + return(iNameBuf);
1.854 + }
1.855 +