userlibandfileserver/fileserver/sfat/fat_dir_entry.h
changeset 0 a41df078684a
child 15 4122176ea935
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32\sfat\inc\fat_dir_entry.h
       
    15 // FAT directory entry related stuff definitions.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 #if !defined(FAT_DIR_ENTRY_H)
       
    25 #define FAT_DIR_ENTRY_H
       
    26 
       
    27 
       
    28 //-------------------------------------------------------------------------------------------------------------------
       
    29 
       
    30 
       
    31 const TInt      KFatDirNameSize         = 11;   ///< Dos directory/File name length
       
    32 const TInt      KVFatEntryAttribute     = 0x0F;  ///< VFat entry attribute setting
       
    33 const TUint8    KDotEntryByte           = 0x2e;  ///< Dot value for self and parent pointer directory entries
       
    34 const TUint8    KBlankSpace             = 0x20;  ///< Blank space in a directory entry
       
    35 const TInt      KSizeOfFatDirEntryLog2  = 5;     ///< Log2 of size in bytes of a Fat directry entry 
       
    36 const TUint     KSizeOfFatDirEntry      = 1 << KSizeOfFatDirEntryLog2;    ///< Size in bytes of a Fat directry entry 
       
    37 
       
    38 const TUint16 KReservedIdOldEntry = 1;	///< Rugged FAT "OldEntry" id
       
    39 const TUint16 KReservedIdNewEntry = 0;  ///< Rugged FAT "ReservedIdNewEntry" id
       
    40 
       
    41 
       
    42 typedef TBuf8<KFatDirNameSize> TShortName;  ///< Buffer type fot short names in dos entries
       
    43 
       
    44 //-------------------------------------------------------------------------------------------------------------------
       
    45 
       
    46 /**
       
    47     Fat DOS directory entry structure
       
    48 */
       
    49 struct SFatDirEntry
       
    50     {
       
    51     TUint8  iName[KFatDirNameSize]; ///< :0  File/Directory name
       
    52     TUint8  iAttributes;            ///< :11 File/Directory attributes
       
    53     TUint8  iReserved1[2];          ///< :12 2 reserved bytes(in our implementation), some versions of Windows may use them
       
    54     TUint16 iTimeC;                 ///< :14 Creation time
       
    55     TUint16 iDateC;                 ///< :16 Creation date
       
    56     TUint16 iReserved2;             ///< :18 2 reserved bytes(in our implementation), FAT specs say that this is "last access date". Rugged FAT uses them as a special entry ID
       
    57     TUint16 iStartClusterHi;        ///< :20 High 16 bits of the File/Directory cluster number (Fat32 only)
       
    58     TUint16 iTime;                  ///< :22 last write access time 
       
    59     TUint16 iDate;                  ///< :24 last write access date 
       
    60     TUint16 iStartClusterLo;        ///< :26 Low 16 bits of the File/Directory cluster number 
       
    61     TUint32 iSize;                  ///< :28 File/Directory size in bytes
       
    62     };
       
    63 
       
    64 
       
    65 //-------------------------------------------------------------------------------------------------------------------
       
    66 
       
    67 /**
       
    68 Provides access to the Fat directory entry parameters
       
    69 */
       
    70 class TFatDirEntry
       
    71     {
       
    72 public:
       
    73     inline TFatDirEntry();
       
    74     inline void InitZ();
       
    75 
       
    76     inline const TPtrC8 Name() const;
       
    77     inline TInt Attributes() const;
       
    78     inline TTime Time(TTimeIntervalSeconds aOffset) const;
       
    79     inline TInt StartCluster() const;
       
    80     inline TUint32 Size() const;
       
    81     inline TBool IsErased() const;
       
    82     inline TBool IsCurrentDirectory() const;
       
    83     inline TBool IsParentDirectory() const;
       
    84     inline TBool IsEndOfDirectory() const;
       
    85     inline TBool IsGarbage() const;
       
    86     inline void SetName(const TDesC8& aDes);
       
    87     inline void SetAttributes(TInt anAtt);
       
    88     inline void SetTime(TTime aTime, TTimeIntervalSeconds aOffset);
       
    89     inline void SetCreateTime(TTime aTime, TTimeIntervalSeconds aOffset);
       
    90     inline void SetStartCluster(TInt aStartCluster);
       
    91     inline void SetSize(TUint32 aFilesize);
       
    92     inline void SetErased();
       
    93     inline void SetCurrentDirectory();
       
    94     inline void SetParentDirectory();
       
    95     inline void SetEndOfDirectory();
       
    96     inline TUint RuggedFatEntryId() const;
       
    97     inline void  SetRuggedFatEntryId(TUint16 aId);
       
    98 
       
    99 public:
       
   100     void InitializeAsVFat(TUint8 aCheckSum);
       
   101     void SetVFatEntry(const TDesC& aName,TInt aRemainderLen);
       
   102     void ReadVFatEntry(TDes16& aVBuf) const;
       
   103     inline TBool IsLongNameStart() const;
       
   104     inline TBool IsVFatEntry() const;
       
   105     inline TInt NumFollowing() const;
       
   106     inline TUint8 CheckSum() const;
       
   107 
       
   108 
       
   109 public:
       
   110     TUint8 iData[KSizeOfFatDirEntry]; ///< The directory entry data
       
   111     };
       
   112 
       
   113 
       
   114 
       
   115 #endif //FAT_DIR_ENTRY_H
       
   116 
       
   117 
       
   118 
       
   119 
       
   120 
       
   121 
       
   122 
       
   123 
       
   124 
       
   125 
       
   126 
       
   127 
       
   128 
       
   129