×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Location
    HeFei,China
    Posts
    81

    Red face Promble with File Path Format???

    Hi Everybody;
    In my FileBrowser Example I have some questions specified As Below:
    //.cpp
    .......
    void CFileBrowserContainer::UpdateTitleL()
    {
    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();


    CAknTitlePane* titlePane = ( CAknTitlePane* )sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
    titlePane->SetTextL(iPath);
    }

    //Here to show the Drive info,typically C: D: E: Z: in the emulator;
    void CFileBrowserContainer::UpdateDriveDataL()
    {
    iPath.Zero();
    RFs session = CEikonEnv::Static()->FsSession();

    CDesCArray *itemArray = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
    itemArray->Reset();
    iListBox->HandleItemRemovalL();

    TDriveList driveList;
    User::LeaveIfError( session.DriveList( driveList ) );
    const TUint8* listPtr = driveList.Ptr();

    for ( TInt i=0; i < KMaxDrives; i++ )
    {
    if ( *listPtr != 0 )
    {
    TChar driveLetter;
    User::LeaveIfError( session.DriveToChar( i, driveLetter ) );
    TBuf<KMaxFileName> name(_L("1\t"));//
    name.Append(driveLetter);
    name.Append(_L(":\\")); //Q1,Here I Append "\\", Why just shows "\" in the file path on the emulator???
    itemArray->AppendL(name);
    }
    listPtr++;
    }
    iListBox->HandleItemAdditionL();
    iListBox->SetCurrentItemIndexAndDraw(0);
    }

    //Here to show the File info, a list of file's name;
    void CFileBrowserContainer::UpdateFileDataL()
    {
    RFs session = CEikonEnv::Static()->FsSession();
    if (iFileList)
    {
    delete iFileList;
    iFileList = NULL;
    }
    if (iDirList)
    {
    delete iDirList;
    iDirList = NULL;
    }
    TInt err = session.GetDir(iPath,KEntryAttNormal,ESortByName,iFileList,iDirList);
    if (err)
    {
    CEikonEnv::Static()->InfoMsg(_L("Media read error!"));
    UpdateDriveDataL();
    User::Leave(err);
    }
    CDesCArray *itemArray = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
    itemArray->Reset();
    iListBox->HandleItemRemovalL();

    for (TInt i=0;i<iDirList->Count();i++)
    {
    TBuf<KMaxFileName> name(_L("1\t"));
    name.Append((*iDirList)[i].iName);
    itemArray->AppendL(name);
    }
    for (TInt i=0;i<iFileList->Count();i++)
    {
    TBuf<KMaxFileName> name(_L("0\t"));
    name.Append((*iFileList)[i].iName);
    itemArray->AppendL(name);
    }
    iListBox->HandleItemAdditionL();
    iListBox->SetCurrentItemIndexAndDraw(0);
    }


    //Here handle listbox events;
    void CFileBrowserContainer::HandleListBoxEventL(
    CEikListBox* /*aListBox*/,
    TListBoxEvent aEventType )
    {
    if ( aEventType == MEikListBoxObserver::EEventEnterKeyPressed ||
    aEventType == MEikListBoxObserver::EEventItemClicked )
    {
    TInt index = iListBox->CurrentItemIndex();
    if (iPath.Length()>0 && index >= iDirList->Count())
    {
    CEikonEnv::Static()->InfoMsg(_L("Not a Folder!"));
    return;
    }
    if (iPath.Length()>0)
    {
    iPath.Append((*iDirList)[index].iName);
    iPath.Append(_L("\\"));
    }
    else
    {
    CDesCArray *itemArray = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
    iPath=(*itemArray)[index];
    iPath.Delete(0,2); //Q2,Here Why Deletes just first 2 not 3 elements? That is "1\t",3 elements?
    }
    UpdateFileDataL();
    UpdateTitleL();
    }
    }


    My questions are as above:
    //Q1,Here I Append "\\", Why just shows "\" in the file path on the emulator???
    //Q2,Here Why Deletes just 2 not 3? That is "1\t",3 elements?

    Thank you!

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: Promble with File Path Format???

    '\' is escape character, so if you want to actually have it, you gotta have '\\', and if you say delete 2 from point 0 it does delete two, why would you think it should delete 3 ?

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Location
    HeFei,China
    Posts
    81

    Re: Promble with File Path Format???

    In my opinion,The first 3 elements are "1\t".
    And the item string is (such as) "1\tC:\\", we want to get "C:\\",so I think "1\t" should be removed,that is iPath.Delete(0,3).

    But as you said, '\' is escape character,so is it that iPath.Delete(0,2) deletes both "1" and "t"??? Or other cases???

    So?

    Thank you!

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: Promble with File Path Format???

    Nope, first element is "1" and the second is "\t", since it is just one tab character. I would suggest you to do a bit of google searching to find out how the string stings work.

Similar Threads

  1. Carbide Build PKG file to SISX - Phone says: "Can't Install"
    By mikedeklerk in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 6
    Last Post: 2009-05-19, 08:23
  2. where the file in app path
    By billqu in forum Symbian
    Replies: 0
    Last Post: 2008-03-19, 11:29
  3. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  4. Replies: 0
    Last Post: 2002-06-10, 12:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×