remotestoragefw/remotefileengine/src/rsfwdirent.cpp
changeset 0 3ad9d5175a89
equal deleted inserted replaced
-1:000000000000 0:3ad9d5175a89
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Directory entry container
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "rsfwdirent.h"
       
    21 #include "rsfwdirentattr.h"
       
    22 
       
    23 // ======================== CRsfwDirEnt MEMBER FUNCTIONS ==========================
       
    24 
       
    25 // ----------------------------------------------------------------------------
       
    26 // CRsfwDirEnt::NewLC
       
    27 // ----------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C CRsfwDirEnt* CRsfwDirEnt::NewLC(const TDesC& aName, CRsfwDirEntAttr* aAttr)
       
    30     {
       
    31     CRsfwDirEnt* self = new (ELeave) CRsfwDirEnt();
       
    32     CleanupStack::PushL(self);
       
    33     self->ConstructL(aName, aAttr);
       
    34     return self;
       
    35     }
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // CRsfwDirEnt::NewLC
       
    39 // ----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CRsfwDirEnt* CRsfwDirEnt::NewLC(const TDesC8& aName, CRsfwDirEntAttr* aAttr)
       
    42     {
       
    43     CRsfwDirEnt* self = new (ELeave) CRsfwDirEnt();
       
    44     CleanupStack::PushL(self);
       
    45     self->Construct8L(aName, aAttr);
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 // CRsfwDirEnt::NewL
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CRsfwDirEnt* CRsfwDirEnt::NewL(const TDesC& aName, CRsfwDirEntAttr* aAttr)
       
    54     {
       
    55     CRsfwDirEnt* self = NewLC(aName, aAttr);
       
    56     CleanupStack::Pop(self);
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // CRsfwDirEnt::NewL
       
    62 // ----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C CRsfwDirEnt* CRsfwDirEnt::NewL(const TDesC8& aName, CRsfwDirEntAttr* aAttr)
       
    65     {
       
    66     CRsfwDirEnt* self = NewLC(aName, aAttr);
       
    67     CleanupStack::Pop(self);
       
    68     return self;
       
    69     }
       
    70 
       
    71 // ----------------------------------------------------------------------------
       
    72 // CRsfwDirEnt::CRsfwDirEnt
       
    73 // ----------------------------------------------------------------------------
       
    74 //
       
    75 CRsfwDirEnt::CRsfwDirEnt()
       
    76     {
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CRsfwDirEnt::~CRsfwDirEnt
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C CRsfwDirEnt::~CRsfwDirEnt()
       
    84     {
       
    85     delete iName;
       
    86     if (!iNotOwnAttr)
       
    87         {
       
    88         delete iAttr;
       
    89         }
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 // CRsfwDirEnt::Name
       
    94 // ----------------------------------------------------------------------------
       
    95 //
       
    96 EXPORT_C const HBufC* CRsfwDirEnt::Name() const
       
    97     {
       
    98     return iName;
       
    99     }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // CRsfwDirEnt::GetName
       
   103 // ----------------------------------------------------------------------------
       
   104 //
       
   105 EXPORT_C void CRsfwDirEnt::GetName(TDes& aName) const
       
   106     {
       
   107     aName.Copy(*iName);
       
   108     }
       
   109 
       
   110 // ----------------------------------------------------------------------------
       
   111 // CRsfwDirEnt::GetName
       
   112 // ----------------------------------------------------------------------------
       
   113 //
       
   114 EXPORT_C void CRsfwDirEnt::GetName(TDes8& aName) const
       
   115     {
       
   116     aName.Copy(*iName);
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CRsfwDirEnt::SetNameL
       
   121 // ----------------------------------------------------------------------------
       
   122 //
       
   123 EXPORT_C void CRsfwDirEnt::SetNameL(const TDesC& aName) 
       
   124     {
       
   125     if (iName)
       
   126         {
       
   127         delete iName;
       
   128         iName = NULL;
       
   129         }
       
   130     iName = aName.AllocL();
       
   131     }
       
   132 
       
   133 // ----------------------------------------------------------------------------
       
   134 // CRsfwDirEnt::SetNameL
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void CRsfwDirEnt::SetNameL(const TDesC8& aName) 
       
   138     {
       
   139     if (iName)
       
   140         {
       
   141         delete iName;
       
   142         iName = NULL;
       
   143         }
       
   144     iName = HBufC::NewL(aName.Length());
       
   145     TPtr namePtr = iName->Des();
       
   146     namePtr.Copy(aName);
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------------------------------
       
   150 // CRsfwDirEnt::Attr
       
   151 // ----------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C CRsfwDirEntAttr* CRsfwDirEnt::Attr() const
       
   154     {
       
   155     return iAttr;
       
   156     }
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CRsfwDirEnt::ExtractAttr
       
   160 // ----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C CRsfwDirEntAttr* CRsfwDirEnt::ExtractAttr()
       
   163     {
       
   164     iNotOwnAttr = ETrue;
       
   165     return iAttr;
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------------------------------
       
   169 // CRsfwDirEnt::SetAttrL
       
   170 // ----------------------------------------------------------------------------
       
   171 //
       
   172 EXPORT_C void CRsfwDirEnt::SetAttrL(CRsfwDirEntAttr* aAttr)
       
   173     {
       
   174     if (iAttr && !iNotOwnAttr)
       
   175         {
       
   176         delete iAttr;
       
   177         }
       
   178     if (aAttr)
       
   179         {
       
   180         iAttr = aAttr;
       
   181         }
       
   182     else
       
   183         {
       
   184         iAttr = CRsfwDirEntAttr::NewL();
       
   185         }
       
   186     iNotOwnAttr = EFalse;
       
   187     }
       
   188 
       
   189 void CRsfwDirEnt::ConstructL(const TDesC& aName, CRsfwDirEntAttr* aAttr)
       
   190     {
       
   191     SetNameL(aName);
       
   192     SetAttrL(aAttr);
       
   193     }
       
   194 
       
   195 void CRsfwDirEnt::Construct8L(const TDesC8& aName, CRsfwDirEntAttr* aAttr)
       
   196     {
       
   197     SetNameL(aName);
       
   198     SetAttrL(aAttr);
       
   199     }
       
   200 
       
   201 // End of File