X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=filelist.c;h=51da350bd0328dcb28d0591e091103545a8ae207;hb=619b82a7a7f0c24da339c76ef9a102960ce928b0;hp=74d943cdcf496d0e3f304307d3e41ada4d536d8b;hpb=c30cc851b60a7c4006cd02b4718d9738a6c4049a;p=ffftp%2Fffftp.git diff --git a/filelist.c b/filelist.c index 74d943c..51da350 100644 --- a/filelist.c +++ b/filelist.c @@ -31,6 +31,8 @@ //#define _WIN32_WINNT 0x400 #define STRICT +// IPv6対応 +#include #include #include #include @@ -183,7 +185,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst) if(hWndListLocal != NULL) { - LocalProcPtr = (WNDPROC)SetWindowLong(hWndListLocal, GWL_WNDPROC, (LONG)LocalWndProc); + // 64ビット対応 +// LocalProcPtr = (WNDPROC)SetWindowLong(hWndListLocal, GWL_WNDPROC, (LONG)LocalWndProc); + LocalProcPtr = (WNDPROC)SetWindowLongPtr(hWndListLocal, GWL_WNDPROC, (LONG_PTR)LocalWndProc); Tmp = SendMessage(hWndListLocal, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0); Tmp |= LVS_EX_FULLROWSELECT; @@ -232,7 +236,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst) if(hWndListRemote != NULL) { - RemoteProcPtr = (WNDPROC)SetWindowLong(hWndListRemote, GWL_WNDPROC, (LONG)RemoteWndProc); + // 64ビット対応 +// RemoteProcPtr = (WNDPROC)SetWindowLong(hWndListRemote, GWL_WNDPROC, (LONG)RemoteWndProc); + RemoteProcPtr = (WNDPROC)SetWindowLongPtr(hWndListRemote, GWL_WNDPROC, (LONG_PTR)RemoteWndProc); Tmp = SendMessage(hWndListRemote, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0); Tmp |= LVS_EX_FULLROWSELECT; @@ -854,7 +860,10 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA PathDir = LocDir; FileListBase = NULL; - MakeSelectedFileList(WIN_LOCAL, YES, NO, &FileListBase, &CancelFlg); + // ローカル側からアプリケーションにD&Dできないバグ修正 +// MakeSelectedFileList(WIN_LOCAL, YES, NO, &FileListBase, &CancelFlg); + MakeSelectedFileList(WIN_LOCAL, NO, NO, &FileListBase, &CancelFlg); + FileListBaseNoExpand = FileListBase; } else if (hWndDragStart == hWndListRemote) { GetCursorPos(&Point); @@ -1118,32 +1127,50 @@ void GetListTabWidth(void) void SetListViewType(void) { - long lStyle; + // 64ビット対応 +// long lStyle; + LONG_PTR lStyle; switch(ListType) { case LVS_LIST : - lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE); + // 64ビット対応 +// lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE); + lStyle = GetWindowLongPtr(GetLocalHwnd(), GWL_STYLE); lStyle &= ~(LVS_REPORT | LVS_LIST); lStyle |= LVS_LIST; - SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle); + // 64ビット対応 +// SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle); + SetWindowLongPtr(GetLocalHwnd(), GWL_STYLE, lStyle); - lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE); + // 64ビット対応 +// lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE); + lStyle = GetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE); lStyle &= ~(LVS_REPORT | LVS_LIST); lStyle |= LVS_LIST; - SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle); + // 64ビット対応 +// SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle); + SetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE, lStyle); break; default : - lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE); + // 64ビット対応 +// lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE); + lStyle = GetWindowLongPtr(GetLocalHwnd(), GWL_STYLE); lStyle &= ~(LVS_REPORT | LVS_LIST); lStyle |= LVS_REPORT; - SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle); + // 64ビット対応 +// SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle); + SetWindowLongPtr(GetLocalHwnd(), GWL_STYLE, lStyle); - lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE); + // 64ビット対応 +// lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE); + lStyle = GetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE); lStyle &= ~(LVS_REPORT | LVS_LIST); lStyle |= LVS_REPORT; - SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle); + // 64ビット対応 +// SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle); + SetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE, lStyle); break; } return; @@ -4771,9 +4798,11 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size, /* 年がない */ /* 現在の日付から推定 */ - if((sTimeNow.wMonth == 12) && (sTime.wMonth == 1)) - sTime.wYear++; - else if(sTimeNow.wMonth+1 == sTime.wMonth) + // 恐らくホストとローカルの時刻が異なる場合の対処のようだがとりあえず無効にする +// if((sTimeNow.wMonth == 12) && (sTime.wMonth == 1)) +// sTime.wYear++; +// else if(sTimeNow.wMonth+1 == sTime.wMonth) + if(sTimeNow.wMonth+1 == sTime.wMonth) /* nothing */; else if(sTimeNow.wMonth < sTime.wMonth) sTime.wYear--; @@ -4825,11 +4854,12 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size, if(strchr("dl", *Str) != NULL) { - if((_mbscmp(_mbsninc(Fname, _mbslen(Fname) - 1), "/") == 0) || - (_mbscmp(_mbsninc(Fname, _mbslen(Fname) - 1), "\\") == 0)) - { - *(Fname + strlen(Fname) - 1) = NUL; - } + // 0x5Cが含まれる文字列を扱えないバグ修正 +// if((_mbscmp(_mbsninc(Fname, _mbslen(Fname) - 1), "/") == 0) || +// (_mbscmp(_mbsninc(Fname, _mbslen(Fname) - 1), "\\") == 0)) +// { +// *(Fname + strlen(Fname) - 1) = NUL; +// } Ret = NODE_DIR; if(*Str == 'l') *Link = YES; @@ -4893,12 +4923,27 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size, break; } - if((Ret != NODE_NONE) && (strlen(Fname) > 0)) + // UTF-8対応 +// if((Ret != NODE_NONE) && (strlen(Fname) > 0)) + if(!(OrgListType & LIST_RAW_NAME) && (Ret != NODE_NONE) && (strlen(Fname) > 0)) { + // UTF-8対応 +// if(CheckSpecialDirName(Fname) == YES) +// Ret = NODE_NONE; +// else +// ChangeFnameRemote2Local(Fname, FMAX_PATH); + ChangeFnameRemote2Local(Fname, FMAX_PATH); + // UTF-8の冗長表現によるディレクトリトラバーサル対策 + FixStringM(Fname, Fname); + // 0x5Cが含まれる文字列を扱えないバグ修正 + if((_mbscmp(_mbsninc(Fname, _mbslen(Fname) - 1), "/") == 0) + || (_mbscmp(_mbsninc(Fname, _mbslen(Fname) - 1), "\\") == 0)) + *(Fname + strlen(Fname) - 1) = NUL; if(CheckSpecialDirName(Fname) == YES) Ret = NODE_NONE; - else - ChangeFnameRemote2Local(Fname, FMAX_PATH); + // 文字コードが正しくないために長さが0になったファイル名は表示しない + if(strlen(Fname) == 0) + Ret = NODE_NONE; } return(Ret); } @@ -5449,3 +5494,99 @@ static int atoi_n(const char *Str, int Len) +// UTF-8対応 +// ファイル一覧から漢字コードを推測 +// 優先度はUTF-8、Shift_JIS、EUC、JISの順 +int AnalyzeNameKanjiCode(int Num) +{ + char Str[FMAX_PATH+1]; + char Name[FMAX_PATH+1]; + LONGLONG Size; + FILETIME Time; + int Attr; + FILE *fd; + int Node; + int ListType; + char Owner[OWNER_NAME_LEN+1]; + int Link; + int InfoExist; + int NameKanjiCode; + int Point; + int PointSJIS; + int PointJIS; + int PointEUC; + int PointUTF8N; + char* p; + + NameKanjiCode = KANJI_AUTO; + Point = 0; + PointSJIS = 0; + PointJIS = 0; + PointEUC = 0; + PointUTF8N = 0; + MakeCacheFileName(Num, Str); + if((fd = fopen(Str, "rb")) != NULL) + { + while(GetListOneLine(Str, FMAX_PATH, fd) == FFFTP_SUCCESS) + { + if((ListType = AnalizeFileInfo(Str)) != LIST_UNKNOWN) + { + strcpy(Name, ""); + Node = ResolvFileInfo(Str, ListType | LIST_RAW_NAME, Name, &Size, &Time, &Attr, Owner, &Link, &InfoExist); + p = Name; + while(*p != '\0') + { + if(*p & 0x80) + { + p = NULL; + break; + } + p++; + } + if(!p) + { + if(!CheckStringM(Name)) + PointUTF8N++; + else + { + switch(CheckKanjiCode(Name, strlen(Name), KANJI_SJIS)) + { + case KANJI_SJIS: + PointSJIS++; + break; + case KANJI_JIS: + PointJIS++; + break; + case KANJI_EUC: + PointEUC++; + break; + } + } + } + } + } + fclose(fd); + } + if(PointJIS >= Point) + { + NameKanjiCode = KANJI_JIS; + Point = PointJIS; + } + if(PointEUC >= Point) + { + NameKanjiCode = KANJI_EUC; + Point = PointEUC; + } + if(PointSJIS >= Point) + { + NameKanjiCode = KANJI_SJIS; + Point = PointSJIS; + } + if(PointUTF8N >= Point) + { + NameKanjiCode = KANJI_UTF8N; + Point = PointUTF8N; + } + return NameKanjiCode; +} +