13
13
// This is still a work in progress.
14
14
#define C_MAX_STATS_BEFORE_QUIT (256)
15
15
16
- #define TABLE_COLUMNS (3 )
16
+ #define TABLE_COLUMNS (4 )
17
17
18
18
//TODO: Move this to its own space.
19
19
typedef struct
20
20
{
21
21
char m_cabinetCWD [PATH_MAX + 2 ];
22
22
char m_cbntOldCWD [PATH_MAX + 2 ];
23
23
bool m_bUsingTableView ;
24
+ char * m_pDestCWD ;
24
25
}
25
26
CabData ;
26
27
@@ -45,6 +46,7 @@ void FormatSizeDetailed(uint32_t size, char* size_buf)
45
46
46
47
#define g_cabinetCWD (((CabData*)pWindow->m_data)->m_cabinetCWD)
47
48
#define g_cbntOldCWD (((CabData*)pWindow->m_data)->m_cbntOldCWD)
49
+ #define g_pDestCWD (((CabData*)pWindow->m_data)->m_pDestCWD)
48
50
#define g_bUsingTableView (((CabData*)pWindow->m_data)->m_bUsingTableView)
49
51
50
52
enum
@@ -103,6 +105,7 @@ static void ClearFileListing(Window * pWindow)
103
105
AddTableColumn (pWindow , MAIN_LISTVIEW , "Name" , 200 );
104
106
AddTableColumn (pWindow , MAIN_LISTVIEW , "Size" , 100 );
105
107
AddTableColumn (pWindow , MAIN_LISTVIEW , "Last modified date" , 150 );
108
+ AddTableColumn (pWindow , MAIN_LISTVIEW , "File type" , 150 );
106
109
}
107
110
else
108
111
{
@@ -123,7 +126,7 @@ static void ChangeListViewMode(Window* pWindow)
123
126
}
124
127
125
128
// size = -1, means don't show anything to the file
126
- static void AddFileElementToList (Window * pWindow , const char * text , int icon , uint32_t file_size , int last_modified_date , bool is_symlink )
129
+ static void AddFileElementToList (Window * pWindow , const char * text , int icon , uint32_t file_size , int last_modified_date , bool is_symlink , const char * description )
127
130
{
128
131
if (is_symlink )
129
132
icon |= ICON_SHORTCUT_FLAG ;
@@ -148,6 +151,7 @@ static void AddFileElementToList(Window* pWindow, const char * text, int icon, u
148
151
table [0 ] = text ;
149
152
table [1 ] = size_buf ;
150
153
table [2 ] = date_buf ;
154
+ table [3 ] = description ;
151
155
152
156
AddTableRow (pWindow , MAIN_LISTVIEW , table , icon );
153
157
}
@@ -165,7 +169,7 @@ static void UpdateDirectoryListing (Window* pWindow)
165
169
166
170
if (strcmp (g_cabinetCWD , "/" )) //if can go to parent, add a button
167
171
{
168
- AddFileElementToList (pWindow , ".." , ICON_FOLDER_PARENT , -1 , -1 , false);
172
+ AddFileElementToList (pWindow , ".." , ICON_FOLDER_PARENT , -1 , -1 , false, "Up one level" );
169
173
}
170
174
171
175
DirEnt ent , * pEnt = & ent ;
@@ -205,8 +209,8 @@ static void UpdateDirectoryListing (Window* pWindow)
205
209
if (res < 0 )
206
210
{
207
211
char buf [512 ];
208
- sprintf (buf , "%s (can't stat -- %s )" , pEnt -> m_name , GetErrNoString (res ));
209
- AddFileElementToList (pWindow , buf , ICON_ERROR , -1 , -1 , false);
212
+ sprintf (buf , "%s (cannot stat)" , pEnt -> m_name , GetErrNoString (res ));
213
+ AddFileElementToList (pWindow , buf , ICON_ERROR , -1 , -1 , false, GetErrNoString ( res ) );
210
214
}
211
215
else if (pEnt -> m_type == FILE_TYPE_SYMBOLIC_LINK && filesDone < C_MAX_STATS_BEFORE_QUIT )
212
216
{
@@ -215,7 +219,7 @@ static void UpdateDirectoryListing (Window* pWindow)
215
219
if (res < 0 )
216
220
{
217
221
// TODO: ICON_CHAIN_BROKEN
218
- AddFileElementToList (pWindow , pEnt -> m_name , ICON_CHAIN_BROKEN , (pEnt -> m_type != FILE_TYPE_FILE ) ? (-1 ) : statResult .m_size , statResult .m_modifyTime , true);
222
+ AddFileElementToList (pWindow , pEnt -> m_name , ICON_CHAIN_BROKEN , (pEnt -> m_type != FILE_TYPE_FILE ) ? (-1 ) : statResult .m_size , statResult .m_modifyTime , true, "Broken symbolic link" );
219
223
}
220
224
else
221
225
{
@@ -226,8 +230,11 @@ static void UpdateDirectoryListing (Window* pWindow)
226
230
}
227
231
else
228
232
{
233
+ FileAssociation * pAssoc ;
229
234
stat_done :
230
- AddFileElementToList (pWindow , pEnt -> m_name , CabGetIconBasedOnName (pName , pEnt -> m_type ), (pEnt -> m_type != FILE_TYPE_FILE ) ? (-1 ) : statResult .m_size , statResult .m_modifyTime , bIsSymLink );
235
+ pAssoc = ResolveAssociation (pName , pEnt -> m_type );
236
+
237
+ AddFileElementToList (pWindow , pEnt -> m_name , pAssoc -> icon , (pEnt -> m_type != FILE_TYPE_FILE ) ? (-1 ) : statResult .m_size , statResult .m_modifyTime , bIsSymLink , pAssoc -> description );
231
238
}
232
239
}
233
240
@@ -543,7 +550,16 @@ void CALLBACK CabinetWindowProc (Window* pWindow, int messageType, long parm1, l
543
550
AddMenuBarItem (pWindow , MAIN_MENU_BAR , MENU$HELP , MENU$HELP$ABOUT , "About File Cabinet" );
544
551
}
545
552
546
- CabinetChangeDirectory (pWindow , "/" , false);
553
+ if (g_pDestCWD )
554
+ {
555
+ CabinetChangeDirectory (pWindow , g_pDestCWD , true);
556
+ MmFree (g_pDestCWD );
557
+ g_pDestCWD = NULL ;
558
+ }
559
+ else
560
+ {
561
+ CabinetChangeDirectory (pWindow , "/" , false);
562
+ }
547
563
548
564
// Add the cool bar widgets
549
565
int i = 0 ;
@@ -668,7 +684,7 @@ static void CreateListView(Window* pWindow)
668
684
}
669
685
}
670
686
671
- void CabinetEntry (UNUSED long argument )
687
+ void CabinetEntry (long argument )
672
688
{
673
689
// create ourself a window:
674
690
int xPos = (GetScreenSizeX () - CABINET_WIDTH ) / 2 ;
@@ -684,12 +700,23 @@ void CabinetEntry (UNUSED long argument)
684
700
685
701
pWindow -> m_iconID = ICON_CABINET ;
686
702
687
- pWindow -> m_data = MmAllocate (sizeof (CabData ));
703
+ CabData * pData = pWindow -> m_data = MmAllocate (sizeof (CabData ));
704
+ if (!pData )
705
+ {
706
+ if (argument )
707
+ MmFree ((char * )argument );
708
+
709
+ SLogMsg ("Cabinet data couldn't be allocated!!" );
710
+ DestroyWindow (pWindow );
711
+ while (HandleMessages (pWindow ));
712
+ return ;
713
+ }
688
714
689
- g_bUsingTableView = true;
715
+ g_pDestCWD = NULL ;
716
+ if (argument )
717
+ g_pDestCWD = (char * ) argument ;
690
718
691
- // setup:
692
- //ShowWindow(pWindow);
719
+ g_bUsingTableView = true;
693
720
694
721
// event loop:
695
722
#if THREADING_ENABLED
0 commit comments