OSDN Git Service

Add support for retaining time stamps on uploading files.
[ffftp/ffftp.git] / filelist.c
index cb1295b..0760c53 100644 (file)
@@ -147,6 +147,8 @@ static WNDPROC LocalProcPtr;
 static WNDPROC RemoteProcPtr;\r
 \r
 static HIMAGELIST ListImg = NULL;\r
+// ファイルアイコン表示対応\r
+static HIMAGELIST ListImgFileIcon = NULL;\r
 \r
 static char FindStr[40+1] = { "*" };           /* 検索文字列 */\r
 static int IgnoreNew = NO;\r
@@ -181,6 +183,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst)
        LV_COLUMN LvCol;\r
        long Tmp;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvCol, 0, sizeof(LV_COLUMN));\r
+\r
        /*===== ローカル側のリストビュー =====*/\r
 \r
        hWndListLocal = CreateWindowEx(/*WS_EX_STATICEDGE*/WS_EX_CLIENTEDGE,\r
@@ -796,7 +801,7 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                        if(hWnd == hWndListRemote)\r
                        {\r
                                if(AskConnecting() == YES)\r
-                                       UpLoadDragProc(wParam);\r
+                                       UploadDragProc(wParam);\r
                        }\r
                        else if(hWnd == hWndListLocal)\r
                        {\r
@@ -1123,6 +1128,9 @@ void GetListTabWidth(void)
        LV_COLUMN LvCol;\r
        int i;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvCol, 0, sizeof(LV_COLUMN));\r
+\r
        for(i = 0; i <= 3; i++)\r
        {\r
                LvCol.mask = LVCF_WIDTH;\r
@@ -1340,22 +1348,22 @@ void RefreshIconImageList(FLISTANCHOR *Anchor)
        int i;\r
        char Cur[FMAX_PATH+1];\r
        SHFILEINFO FileInfo;\r
-       SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
-       ShowWindow(hWndListLocal, SW_SHOW);\r
-       SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
-       ShowWindow(hWndListRemote, SW_SHOW);\r
-       ImageList_Destroy(ListImg);\r
-       ListImg = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 1);\r
-       hBitmap = LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(dirattr_bmp));\r
-       ImageList_AddMasked(ListImg, hBitmap, RGB(255,0,0));\r
-       DeleteObject(hBitmap);\r
-       ImageId = 0;\r
-       Pos = Anchor->Top;\r
-       for(i = 0; i < Anchor->Files; i++)\r
+       if(AskDispFileIcon() == YES)\r
        {\r
-               Pos->ImageId = -1;\r
-               if(AskDispFileIcon() == YES)\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+               ImageList_Destroy(ListImgFileIcon);\r
+               ListImgFileIcon = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 0, 1);\r
+               hBitmap = LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(dirattr16_bmp));\r
+               ImageList_AddMasked(ListImgFileIcon, hBitmap, RGB(255, 0, 0));\r
+               DeleteObject(hBitmap);\r
+               ImageId = 0;\r
+               Pos = Anchor->Top;\r
+               for(i = 0; i < Anchor->Files; i++)\r
                {\r
+                       Pos->ImageId = -1;\r
                        if(Pos->Node == NODE_DRIVE)\r
                                strcpy(Cur, Pos->File);\r
                        else\r
@@ -1366,20 +1374,27 @@ void RefreshIconImageList(FLISTANCHOR *Anchor)
                        }\r
                        if(SHGetFileInfoM(Cur, 0, &FileInfo, sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_ICON) != 0)\r
                        {\r
-                               if(ImageList_AddIcon(ListImg, FileInfo.hIcon) >= 0)\r
+                               if(ImageList_AddIcon(ListImgFileIcon, FileInfo.hIcon) >= 0)\r
                                {\r
                                        Pos->ImageId = ImageId;\r
                                        ImageId++;\r
                                }\r
                                DestroyIcon(FileInfo.hIcon);\r
                        }\r
+                       Pos = Pos->Next;\r
                }\r
-               Pos = Pos->Next;\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImgFileIcon);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImgFileIcon);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+       }\r
+       else\r
+       {\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
        }\r
-       SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
-       ShowWindow(hWndListLocal, SW_SHOW);\r
-       SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
-       ShowWindow(hWndListRemote, SW_SHOW);\r
 }\r
 \r
 void GetLocalDirForWnd(void)\r
@@ -1434,7 +1449,7 @@ void GetLocalDirForWnd(void)
        if(DispDrives)\r
        {\r
                GetLogicalDriveStrings(FMAX_PATH, Scan);\r
-               NoDrives = LoadHideDriveListRegistory();\r
+               NoDrives = LoadHideDriveListRegistry();\r
 \r
                Pos = Scan;\r
                while(*Pos != NUL)\r
@@ -1516,20 +1531,36 @@ static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LON
 \r
                        if((Sort & SORT_GET_ORD) == SORT_ASCENT)\r
                        {\r
-                               if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
-                                       ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
+                               // 読みにくいのでリファクタリング\r
+//                             if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+//                                     ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
+//#if defined(HAVE_TANDEM)\r
+//                                ((AskHostType() == HTYPE_TANDEM) &&\r
+//                                 ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+//                                     ((Cmp = Attr - Pos->Attr) < 0)) ||\r
+//#endif\r
+//                                (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
+//                                     ((Cmp = Size - Pos->Size) < 0)) ||\r
+//                                (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
+//                                     ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
+//                             {\r
+//                                     break;\r
+//                             }\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0))\r
+                                       break;\r
 #if defined(HAVE_TANDEM)\r
-                                  ((AskHostType() == HTYPE_TANDEM) &&\r
-                                   ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
-                                       ((Cmp = Attr - Pos->Attr) < 0)) ||\r
+                               if((AskHostType() == HTYPE_TANDEM) &&\r
+                                       ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = Attr - Pos->Attr) < 0))\r
+                                       break;\r
 #endif\r
-                                  (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
-                                       ((Cmp = Size - Pos->Size) < 0)) ||\r
-                                  (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
-                                       ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
-                               {\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
+                                       ((Cmp = Size - Pos->Size) < 0))\r
+                                       break;\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
+                                       ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0))\r
                                        break;\r
-                               }\r
 \r
                                if(((Sort & SORT_MASK_ORD) == SORT_NAME) || (Cmp == 0))\r
                                {\r
@@ -1683,6 +1714,8 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        if(Pos == -1)\r
                Pos = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0);\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        /* アイコン/ファイル名 */\r
        LvItem.mask = LVIF_TEXT | LVIF_IMAGE;\r
        LvItem.iItem = Pos;\r
@@ -1695,8 +1728,8 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        else\r
                LvItem.iImage = 4;\r
        // ファイルアイコン表示対応\r
-       if(hWnd == GetLocalHwnd() && ImageId >= 0)\r
-               LvItem.iImage = 5 + ImageId;\r
+       if(AskDispFileIcon() == YES && hWnd == GetLocalHwnd())\r
+               LvItem.iImage = ImageId + 5;\r
        LvItem.iItem = SendMessage(hWnd, LVM_INSERTITEM, 0, (LPARAM)&LvItem);\r
 \r
        /* 日付/時刻 */\r
@@ -1805,6 +1838,8 @@ void SelectFileInList(HWND hWnd, int Type)
        FILETIME Time2;\r
        int Find;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        Win = WIN_LOCAL;\r
        WinDst = WIN_REMOTE;\r
        if(hWnd == GetRemoteHwnd())\r
@@ -1985,6 +2020,8 @@ void FindFileInList(HWND hWnd, int Type)
        LV_ITEM LvItem;\r
        char *Title;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        Win = WIN_LOCAL;\r
        Title = MSGJPN050;\r
        if(hWnd == GetRemoteHwnd())\r
@@ -2266,6 +2303,8 @@ int FindNameNode(int Win, char *Name)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&FindInfo, 0, sizeof(LV_FINDINFO));\r
        FindInfo.flags = LVFI_STRING;\r
        FindInfo.psz = Name;\r
        return(SendMessage(hWnd, LVM_FINDITEM, -1, (LPARAM)&FindInfo));\r
@@ -2293,6 +2332,8 @@ void GetNodeName(int Win, int Pos, char *Buf, int Max)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 0;\r
@@ -2326,6 +2367,8 @@ int GetNodeTime(int Win, int Pos, FILETIME *Buf)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 1;\r
@@ -2360,6 +2403,8 @@ int GetNodeSize(int Win, int Pos, LONGLONG *Buf)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 2;\r
@@ -2407,6 +2452,8 @@ int GetNodeAttr(int Win, int Pos, int *Buf)
        Ret = NO;\r
        if(Win == WIN_REMOTE)\r
        {\r
+               // 変数が未初期化のバグ修正\r
+               memset(&LvItem, 0, sizeof(LV_ITEM));\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
 #if defined(HAVE_TANDEM)\r
@@ -2454,6 +2501,8 @@ int GetNodeType(int Win, int Pos)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 2;\r
@@ -2491,6 +2540,8 @@ void GetNodeOwner(int Win, int Pos, char *Buf, int Max)
        strcpy(Buf, "");\r
        if(Win == WIN_REMOTE)\r
        {\r
+               // 変数が未初期化のバグ修正\r
+               memset(&LvItem, 0, sizeof(LV_ITEM));\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
                LvItem.iSubItem = 5;\r
@@ -4911,6 +4962,7 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                                                        sTime.wSecond = atoi_n(Value + 12, 2);\r
                                                        sTime.wMilliseconds = 0;\r
                                                        SystemTimeToFileTime(&sTime, Time);\r
+                                                       // 時刻はGMT\r
 //                                                     SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
                                                        *InfoExist |= FINFO_DATE | FINFO_TIME;\r
                                                }\r