|
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 * Directory operations for FileSystem component |
|
16 * @internalComponent |
|
17 * @released |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef DIRECTORY_H |
|
23 #define DIRECTORY_H |
|
24 |
|
25 #include "utils.h" |
|
26 |
|
27 /* If the macro _FILESYSTEM_DLL is defined, then the macro FILESYSTEM_API is used to |
|
28 * export the functions. Hence while building the DLL this macro should be used. |
|
29 * Else if the macro _USE_FILESYSTEM_DLL is defined, then the macro FILESYSTEM_API is |
|
30 * used to import the functions. Hence while linking this macro should be used. |
|
31 * If none of the above macros defined, then the macro FILESYSTEM_API is defined empty |
|
32 * and it is used for creating static library. |
|
33 * The purpose of using multiple macros is to deliver both the static and dynamic |
|
34 * libraries from the same set of source files. |
|
35 */ |
|
36 #ifdef _FILESYSTEM_DLL |
|
37 #define FILESYSTEM_API __declspec(dllexport) |
|
38 #elif _USE_FILESYSTEM_DLL |
|
39 #define FILESYSTEM_API __declspec(dllimport) |
|
40 #else |
|
41 #define FILESYSTEM_API |
|
42 #endif |
|
43 |
|
44 #include <list> |
|
45 #include <stack> |
|
46 #include <time.h> |
|
47 |
|
48 class CDirectory; |
|
49 class CLongEntry; |
|
50 |
|
51 typedef std::list<CDirectory*> EntryList; |
|
52 |
|
53 //Directory, file and volume Attributes |
|
54 enum KAttributes |
|
55 { |
|
56 EAttrReadOnly = 0x01, |
|
57 EAttrHidden = 0x02, |
|
58 EAttrSystem = 0x04, |
|
59 EAttrVolumeId = 0x08, |
|
60 EAttrDirectory = 0x10, |
|
61 EAttrArchive = 0x20, |
|
62 EAttrLongName = EAttrReadOnly | EAttrHidden | EAttrSystem | EAttrVolumeId, |
|
63 EAttrLongNameMask = EAttrReadOnly | EAttrHidden | EAttrSystem | EAttrVolumeId \ |
|
64 | EAttrDirectory | EAttrArchive, |
|
65 ELastLongEntry = 0x40 |
|
66 }; |
|
67 |
|
68 //Time format, should be written as a integer in FAT image |
|
69 typedef struct |
|
70 { |
|
71 unsigned short int Seconds:5; |
|
72 unsigned short int Minute:6; |
|
73 unsigned short int Hour:5; |
|
74 }FatTime; |
|
75 |
|
76 //Date format, should be written as a integer in FAT image |
|
77 typedef struct |
|
78 { |
|
79 unsigned short int Day:5; |
|
80 unsigned short int Month:4; |
|
81 unsigned short int Year:7; |
|
82 }FatDate; |
|
83 |
|
84 //This union convention used to convert bit fields into integer |
|
85 union TDateInteger |
|
86 { |
|
87 FatDate iCurrentDate; |
|
88 unsigned short int iImageDate; |
|
89 }; |
|
90 |
|
91 //This union convention used to convert bit fields into integer |
|
92 union TTimeInteger |
|
93 { |
|
94 FatTime iCurrentTime; |
|
95 unsigned short int iImageTime; |
|
96 }; |
|
97 |
|
98 /* This class describes the attributes of a single directory/file/volume entry. |
|
99 * |
|
100 * @internalComponent |
|
101 * @released |
|
102 */ |
|
103 class CDirectory |
|
104 { |
|
105 |
|
106 public: |
|
107 FILESYSTEM_API CDirectory(char* aEntryName); |
|
108 FILESYSTEM_API ~CDirectory(); |
|
109 FILESYSTEM_API EntryList* GetEntryList(); |
|
110 FILESYSTEM_API void InsertIntoEntryList(CDirectory* aEntry); |
|
111 FILESYSTEM_API void SetFilePath(char* aFilePath); |
|
112 FILESYSTEM_API String GetFilePath() const; |
|
113 FILESYSTEM_API void SetEntryName(String aEntryName); |
|
114 FILESYSTEM_API String GetEntryName() const; |
|
115 FILESYSTEM_API void SetEntryAttribute(char aAttribute); |
|
116 FILESYSTEM_API char GetEntryAttribute() const; |
|
117 char GetNtReservedByte() const; |
|
118 char GetCreationTimeMsecs() const; |
|
119 unsigned short int GetCreatedTime() const; |
|
120 unsigned short int GetCreationDate() const; |
|
121 unsigned short int GetLastAccessDate() const; |
|
122 unsigned short int GetClusterNumberHi() const; |
|
123 void SetClusterNumberHi(unsigned short int aHiClusterNumber); |
|
124 unsigned short int GetClusterNumberLow() const; |
|
125 void SetClusterNumberLow(unsigned short int aLowClusterNumber); |
|
126 unsigned short int GetLastWriteDate() const; |
|
127 unsigned short int GetLastWriteTime() const; |
|
128 FILESYSTEM_API void SetFileSize(unsigned int aFileSize); |
|
129 FILESYSTEM_API unsigned int GetFileSize() const; |
|
130 bool IsFile() const ; |
|
131 |
|
132 private: |
|
133 void InitializeTime(); |
|
134 |
|
135 private: |
|
136 String iEntryName; //Directory or file name |
|
137 char iAttribute; //To mention file or directory or Volume |
|
138 char iNtReserved; //Reserved for use by windows NT, this value always zero |
|
139 char iCreationTimeMsecs; /**Millisecond stamp at file creation time, Since this is not |
|
140 so important, always initialized to zero*/ |
|
141 unsigned short int iCreatedTime; //Time file was created |
|
142 unsigned short int iCreationDate; //Date file was created |
|
143 unsigned short int iLastAccessDate; //Date file was last accessed |
|
144 unsigned short int iClusterNumberHi;//High word of this entry's first cluster number |
|
145 unsigned short int iClusterNumberLow;//Low word of this entry's first cluster number |
|
146 unsigned short int iLastWriteDate; //Date file was written |
|
147 unsigned short int iLastWriteTime; //Time file was written |
|
148 unsigned int iFileSize; //file size |
|
149 EntryList iDirectoryList; //List Template used to hold subdirectories |
|
150 |
|
151 String iFilePath; //Holds file path only if the entry is of type "file" |
|
152 |
|
153 struct tm* iDateAndTime; |
|
154 union TTimeInteger iTime; |
|
155 union TDateInteger iDate; |
|
156 }; |
|
157 |
|
158 #endif //DIRECTORY_H |