void CAknFileSettingPage::SetFolderL(const TDesC& aFolder)
{
    TParse parse;
    TFileName file;
    TDesC* pos=NULL;
    parse.SetNoWild(iFileValue,NULL,NULL);
    if(aFolder.CompareF(KFolderUp)==0)
    {
        if(iFileValue.Length())
        {
            if(parse.PopDir()==KErrNone)
            {
                TParse parse2;
                parse2.SetNoWild(iFileValue,NULL,NULL);
                TPtrC ptr=parse2.DriveAndPath();
                file=ptr.Left(ptr.Length()-1);
                parse2.SetNoWild(file,NULL,NULL);
                file=parse2.NameAndExt();
                pos=&file;
                iFileValue=parse.DriveAndPath();
            }
            else
                iFileValue.Zero();
        }
    }
    else
    {
        iFileValue=parse.DriveAndPath();
        iFileValue.Append(aFolder);
        iFileValue.Append('\\');
    }
    ReadFilesL(pos);
}
Esempio n. 2
0
TBool CFileSelectDialog::OkToExitL(TInt aButton)
	{
	TInt selected=ListBox()->CurrentItemIndex();
	_LOGDATA(_L("Selected: %d"),selected);
	if (aButton==EAknSoftkeyCancel){return ETrue;}
	if (iCurrentPath.Compare(_L(""))==0)
		{
		_LOG(_L("(iCurrentPath.Compare(_L(""))==0)"));
		_LOG(iCurrentPath);
		iCurrentPath.Append(iArray->MdcaPoint(selected));
		iCurrentPath.Append(_L("\\"));
		if (BaflUtils::PathExists(iFs,iCurrentPath)){Update();Show();return EFalse;}
		//Update();
		}
	else if ((selected>1&&iType==EFolder)||(selected>0&&iType==EFile))
		{
		_LOG(_L("((selected>1)&&(iCurrentPath.Compare(_L(""))!=0))"));
		_LOG(iCurrentPath);
		TBuf<255> temp(iArray->MdcaPoint(selected));
		TChar c1='[',c2=']';
		if (temp[0]==c1&&temp[temp.Length()-1]==c2) {temp.Copy(temp.Left(temp.Length()-1));temp.Copy(temp.Right(temp.Length()-1));}
		_LOGDATA(_L("Temp: %S"),&temp);
		iCurrentPath.Append(temp);
		iCurrentPath.Append(_L("\\"));
		_LOGDATA(_L("CurrPath after append: %S"),&iCurrentPath);
		CEikonEnv::Static()->InfoMsg(iCurrentPath);
		User::After(500000);
		if (BaflUtils::PathExists(iFs,iCurrentPath)){Update();Show();return EFalse;}
		else if (BaflUtils::FileExists(iFs,iCurrentPath.Left(iCurrentPath.Length()-1)))
			{
			iResult.Copy(iCurrentPath.Left(iCurrentPath.Length()-1));
			return ETrue;
			}
		}
	else if (selected==0)
		{
		_LOG(_L("(selected==0&&(iCurrentPath.Compare(_L(""))!=0))"));
		_LOG(iCurrentPath);
		TParse p;
		iFs.Parse(iCurrentPath, p);
		_LOG(_L("Will pop now"))
		TInt err=p.PopDir();
		if (err!=KErrNone||iCurrentPath.Compare(p.FullName())==0){iCurrentPath.Copy(_L(""));}
		else {iCurrentPath.Copy(p.FullName());}
		//if (iCurrentPath.Compare(_L(""))!=0)
		Update();Show();return EFalse;
		}
	else if (selected==1&&iType==EFolder&&(iCurrentPath.Compare(_L(""))!=0))
		{
		_LOG(_L("Will update result"));
		iResult.Copy(iCurrentPath);
		return ETrue;
		}
	Update();Show();return EFalse;
	}
void RemoveDirectoryTreeL(RFs& aFs, const TDesC& aFileName)
	{
	TParse directory;
	User::LeaveIfError(directory.SetNoWild(aFileName, NULL, NULL));
	while(!directory.IsRoot())
		{
		// try to remove this directory
		TInt err = aFs.RmDir(directory.DriveAndPath());
		if(err == KErrInUse || err == KErrAccessDenied)
			{
			break;
			}
		VerifyDeletionErrorL(err);		
		// move to deleted directory's parent
		User::LeaveIfError(directory.PopDir());
		}	
	}
Esempio n. 4
0
GLDEF_C TInt GetFullPath(TParse& aParse, const TText16* upath, RFs& aSession, TDes* aFileName)
//
// Parse a path of the form "[C:][\]AAA\..\.\BBB\xxx" where:
// .  indicates the current directory
// .. indicates move to the parent directory
// An optional "\" at the start of the path indicates the path is not relative to the current path,
// and is implied if the drive specifier is present
// If aFileName is non-NULL then the final component is a filename and should be copied into 
// the aFileName descriptor.
//
	{

	TInt r;
	TBuf<3> drive;
	TFileName nextBit;
	TText16 c=*upath;

	if (c && upath[1]==KDriveDelimiter) 
		{
		// drive name specified
		if (c==L'?')
			drive.Zero();			// use "?:" to mean scan across drives
		else
			{
			drive.Copy(TPtrC16(upath, 2));
			drive.UpperCase();
			}
		upath+=2;
		drive.Append(TChar(KPathDelimiter));	// enforce absoluteness
		}
	else
		{
		// no leading drive specifier
		drive.Zero();
		if (c==KPathDelimiter||c==L'/')
			{
			upath+=1;
			drive.Append(TChar(KPathDelimiter));
			}
		}
	r = aSession.Parse(drive, aParse);

	// upath now looks like a relative pathname, to be added onto
	// aParse a directory at a time. Note that '/' is not allowed in
	// EPOC32 file or directory names, so treat it as an alternative separator

	c=*upath;
	while (c && (r==KErrNone))
		{
		const TText16* ustart=upath;
		do 
			c=*upath++;
		while (c && c!=KPathDelimiter && c!=L'/');

		TInt len=(upath-ustart)-1;		// excludes delimiter
		if (len==0)
			continue;
		if (ustart[0]==L'.')
			{
			if (len==1)
				continue;	// directory . ignored
			if (len==2 && ustart[1]==L'.')
				{
				// directory ..
				(void) aParse.PopDir();	// just stick at root dir, no errors
				continue;
				}
			}
		if (len>=KMaxFileName)
			return ENAMETOOLONG;
		if (c==L'\0' && aFileName!=NULL)
			{
			// it's the trailing filename
			aFileName->Copy(TPtrC16(ustart, len));
			break;
			}
		else	
			{
			// it's a component of the accumulating path
			nextBit.Copy(TPtrC16(ustart, len));
			r = aParse.AddDir(nextBit);
			}
		}
	return(r);
	}