imgtools/imglib/filesystem/include/longname.h
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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 the License "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: 
       
    15 * Long name class for FileSystem component
       
    16 * @internalComponent
       
    17 * @released
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef LONGNAME_H
       
    23 #define LONGNAME_H
       
    24 
       
    25 #include "cluster.h"
       
    26 #include "longentry.h"
       
    27 
       
    28 #define ToString(dataInteger) reinterpret_cast<char*>(&dataInteger),sizeof(dataInteger)
       
    29 
       
    30 typedef std::stack<CLongEntry*> LongEntryStack;
       
    31 typedef std::list<String> StringList;
       
    32 
       
    33 //Long entry sub name lengths
       
    34 enum TLongSubNameLength
       
    35 {
       
    36 	ESubName1Length = 5,
       
    37 	ESubName2Length = 6,
       
    38 	ESubName3Length = 2
       
    39 };
       
    40 
       
    41 //Name length constants
       
    42 enum TNameLength
       
    43 {
       
    44 	EExtensionLength = 0x03,
       
    45 	EShortNameInitialLength = 0x06,
       
    46 	ETildeNumberPosition = 0x07,
       
    47 	ENameLength = 0x8,
       
    48 	ENameLengthWithExtension = 0x0B
       
    49 };
       
    50 
       
    51 //Holds all the short directory entry.
       
    52 static StringList GShortEntryList;
       
    53 
       
    54 /**
       
    55 This class is used to prepare Long Name Directory entry portion of Directory Entry region
       
    56 
       
    57 @internalComponent
       
    58 @released
       
    59 */
       
    60 class ClongName
       
    61 {
       
    62 private:
       
    63 	StringList iSubNamesList;		//Holds the splitted file names 
       
    64 	LongEntryStack iLongEntryStack;	//Holds all the long name directory entry node's
       
    65 	unsigned int iClusterNumber;	//Current cluster number, where the current long entry needs to be written
       
    66 	CCluster* iClusterPtr;
       
    67 	String iLongName;
       
    68 	char iLongEntryAttribute;
       
    69 	String iShortName;
       
    70 	unsigned int iLongNameLength;
       
    71 	unsigned int iTildeNumberPosition;
       
    72 	/**If the received sub name entry size is equal to its expected length, then
       
    73 	two NULL character should be preceded at the start of next sub name 
       
    74 	*/
       
    75 	bool iSubNameProperEnd; //Is name ends without NULL character termination?
       
    76 	bool iFirstNullName;// Is first name ending with NULL character?
       
    77 
       
    78 private:
       
    79 	String GetShortEntryName();
       
    80 	unsigned char CalculateCheckSum();
       
    81 	void WriteLongEntry(CLongEntry* aLongEntry,String& longEntryString);
       
    82 	void WriteSubName(String& aSubName,unsigned short aSubNameLength,
       
    83 					  String& alongEntryString);
       
    84 	void FormatLongFileName(String& aLongName);
       
    85 	void CheckAndUpdateShortName(String& aShortName);
       
    86 	void PushAndErase(String& aFirstName,String& aSecondName,String& aThirdName);
       
    87 	void GetSubName(String& aLongName,
       
    88 				   int& aStartIndex,
       
    89 				   int& aStringLength,
       
    90 				   int aSubNameLength,
       
    91 				   String& aSubName);
       
    92 	void PopAndErase();
       
    93 	void CalculateExtentionLength();
       
    94 
       
    95 public:
       
    96 	ClongName(CCluster* aClusterPtr, CDirectory* aEntry);
       
    97 	~ClongName();
       
    98 	CDirectory* CreateShortEntry(CDirectory* aEntry);
       
    99 	String CreateLongEntries();
       
   100 	static void DestroyShortEntryList();
       
   101 };
       
   102 
       
   103 #endif //LONGNAME_H