FFFTPのソースコードです。
Revisão | 08cb92f946f548cab1ed9738b6bdda9e65247935 (tree) |
---|---|
Hora | 2011-12-04 01:21:09 |
Autor | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Fix bugs of UTF-8 to UTF-16 API bridge.
Change the temporary directory.
@@ -1730,6 +1730,8 @@ LONGLONG MakeLongLong(DWORD High, DWORD Low); | ||
1730 | 1730 | char *MakeNumString(LONGLONG Num, char *Buf, BOOL Comma); |
1731 | 1731 | // 異なるファイルが表示されるバグ修正 |
1732 | 1732 | char* MakeDistinguishableFileName(char* Out, char* In); |
1733 | +// 環境依存の不具合対策 | |
1734 | +char* GetAppTempPath(char* Buf); | |
1733 | 1735 | |
1734 | 1736 | /*===== dlgsize.c =====*/ |
1735 | 1737 |
@@ -462,10 +462,15 @@ static void doTransferRemoteFile(void) | ||
462 | 462 | |
463 | 463 | // アプリを多重起動してもコンフリクトしないように、テンポラリフォルダ名にプロセスID |
464 | 464 | // を付加する。(2007.9.13 yutaka) |
465 | - GetTempPath(sizeof(TmpDir), TmpDir); | |
466 | - pid = GetCurrentProcessId(); | |
467 | - _snprintf_s(buf, sizeof(buf), _TRUNCATE, "ffftp%d", pid); | |
468 | - strncat_s(TmpDir, sizeof(TmpDir), buf, _TRUNCATE); | |
465 | + // 環境依存の不具合対策 | |
466 | +// GetTempPath(sizeof(TmpDir), TmpDir); | |
467 | +// pid = GetCurrentProcessId(); | |
468 | +// _snprintf_s(buf, sizeof(buf), _TRUNCATE, "ffftp%d", pid); | |
469 | +// strncat_s(TmpDir, sizeof(TmpDir), buf, _TRUNCATE); | |
470 | + GetAppTempPath(TmpDir); | |
471 | + _mkdir(TmpDir); | |
472 | + SetYenTail(TmpDir); | |
473 | + strcat(TmpDir, "transfer"); | |
469 | 474 | _mkdir(TmpDir); |
470 | 475 | #if 0 |
471 | 476 | if (TmpDir[strlen(TmpDir) - 1] == '\\') { |
@@ -415,7 +415,11 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) | ||
415 | 415 | { |
416 | 416 | Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel)); |
417 | 417 | |
418 | - GetTempPath(FMAX_PATH, TmpPath); | |
418 | + // 環境依存の不具合対策 | |
419 | +// GetTempPath(FMAX_PATH, TmpPath); | |
420 | + GetAppTempPath(TmpPath); | |
421 | + _mkdir(TmpPath); | |
422 | + SetYenTail(TmpPath); | |
419 | 423 | |
420 | 424 | GetModuleFileName(NULL, HelpPath, FMAX_PATH); |
421 | 425 | strcpy(GetFileName(HelpPath), "ffftp.chm"); |
@@ -2019,6 +2023,9 @@ static char *GetToken(char *Str, char *Buf) | ||
2019 | 2023 | |
2020 | 2024 | static void ExitProc(HWND hWnd) |
2021 | 2025 | { |
2026 | + // 環境依存の不具合対策 | |
2027 | + char Tmp[FMAX_PATH+1]; | |
2028 | + | |
2022 | 2029 | CancelFlg = YES; |
2023 | 2030 | |
2024 | 2031 | CloseTransferThread(); |
@@ -2047,6 +2054,10 @@ static void ExitProc(HWND hWnd) | ||
2047 | 2054 | else |
2048 | 2055 | DeleteCache(); |
2049 | 2056 | |
2057 | + // 環境依存の不具合対策 | |
2058 | + GetAppTempPath(Tmp); | |
2059 | + _rmdir(Tmp); | |
2060 | + | |
2050 | 2061 | if(RasClose == YES) |
2051 | 2062 | { |
2052 | 2063 | DisconnectRas(RasCloseNotify); |
@@ -2109,7 +2109,7 @@ END_ROUTINE | ||
2109 | 2109 | |
2110 | 2110 | int mkdirM(const char * _Path) |
2111 | 2111 | { |
2112 | - int r = 0; | |
2112 | + int r = -1; | |
2113 | 2113 | wchar_t* pw0 = NULL; |
2114 | 2114 | START_ROUTINE |
2115 | 2115 | pw0 = DuplicateMtoW(_Path, -1); |
@@ -2121,7 +2121,7 @@ END_ROUTINE | ||
2121 | 2121 | |
2122 | 2122 | int _mkdirM(const char * _Path) |
2123 | 2123 | { |
2124 | - int r = 0; | |
2124 | + int r = -1; | |
2125 | 2125 | wchar_t* pw0 = NULL; |
2126 | 2126 | START_ROUTINE |
2127 | 2127 | pw0 = DuplicateMtoW(_Path, -1); |
@@ -2133,7 +2133,7 @@ END_ROUTINE | ||
2133 | 2133 | |
2134 | 2134 | int rmdirM(const char * _Path) |
2135 | 2135 | { |
2136 | - int r = 0; | |
2136 | + int r = -1; | |
2137 | 2137 | wchar_t* pw0 = NULL; |
2138 | 2138 | START_ROUTINE |
2139 | 2139 | pw0 = DuplicateMtoW(_Path, -1); |
@@ -2145,7 +2145,7 @@ END_ROUTINE | ||
2145 | 2145 | |
2146 | 2146 | int _rmdirM(const char * _Path) |
2147 | 2147 | { |
2148 | - int r = 0; | |
2148 | + int r = -1; | |
2149 | 2149 | wchar_t* pw0 = NULL; |
2150 | 2150 | START_ROUTINE |
2151 | 2151 | pw0 = DuplicateMtoW(_Path, -1); |
@@ -2155,6 +2155,42 @@ END_ROUTINE | ||
2155 | 2155 | return r; |
2156 | 2156 | } |
2157 | 2157 | |
2158 | +int removeM(const char * _Filename) | |
2159 | +{ | |
2160 | + int r = -1; | |
2161 | + wchar_t* pw0 = NULL; | |
2162 | +START_ROUTINE | |
2163 | + pw0 = DuplicateMtoW(_Filename, -1); | |
2164 | + r = _wremove(pw0); | |
2165 | +END_ROUTINE | |
2166 | + FreeDuplicatedString(pw0); | |
2167 | + return r; | |
2168 | +} | |
2169 | + | |
2170 | +int _removeM(const char * _Filename) | |
2171 | +{ | |
2172 | + int r = -1; | |
2173 | + wchar_t* pw0 = NULL; | |
2174 | +START_ROUTINE | |
2175 | + pw0 = DuplicateMtoW(_Filename, -1); | |
2176 | + r = _wremove(pw0); | |
2177 | +END_ROUTINE | |
2178 | + FreeDuplicatedString(pw0); | |
2179 | + return r; | |
2180 | +} | |
2181 | + | |
2182 | +int _unlinkM(const char * _Filename) | |
2183 | +{ | |
2184 | + int r = -1; | |
2185 | + wchar_t* pw0 = NULL; | |
2186 | +START_ROUTINE | |
2187 | + pw0 = DuplicateMtoW(_Filename, -1); | |
2188 | + r = _wunlink(pw0); | |
2189 | +END_ROUTINE | |
2190 | + FreeDuplicatedString(pw0); | |
2191 | + return r; | |
2192 | +} | |
2193 | + | |
2158 | 2194 | size_t _mbslenM(const unsigned char * _Str) |
2159 | 2195 | { |
2160 | 2196 | size_t r = 0; |
@@ -182,6 +182,15 @@ int rmdirM(const char * _Path); | ||
182 | 182 | #undef _rmdir |
183 | 183 | #define _rmdir _rmdirM |
184 | 184 | int _rmdirM(const char * _Path); |
185 | +#undef remove | |
186 | +#define remove removeM | |
187 | +int removeM(const char * _Filename); | |
188 | +#undef _remove | |
189 | +#define _remove _removeM | |
190 | +int _removeM(const char * _Filename); | |
191 | +#undef _unlink | |
192 | +#define _unlink _unlinkM | |
193 | +int _unlinkM(const char * _Filename); | |
185 | 194 | #undef _mbslen |
186 | 195 | #define _mbslen _mbslenM |
187 | 196 | size_t _mbslenM(const unsigned char * _Str); |
@@ -1777,3 +1777,14 @@ char* MakeDistinguishableFileName(char* Out, char* In) | ||
1777 | 1777 | return Out; |
1778 | 1778 | } |
1779 | 1779 | |
1780 | +// 環境依存の不具合対策 | |
1781 | +char* GetAppTempPath(char* Buf) | |
1782 | +{ | |
1783 | + char Temp[32]; | |
1784 | + GetTempPath(MAX_PATH, Buf); | |
1785 | + SetYenTail(Buf); | |
1786 | + sprintf(Temp, "ffftp%08x", GetCurrentProcessId()); | |
1787 | + strcat(Buf, Temp); | |
1788 | + return Buf; | |
1789 | +} | |
1790 | + |
@@ -1537,7 +1537,10 @@ static INT_PTR CALLBACK MiscSettingProc(HWND hDlg, UINT message, WPARAM wParam, | ||
1537 | 1537 | break; |
1538 | 1538 | |
1539 | 1539 | case MISC_CACHEDIR_DEF : |
1540 | - GetTempPath(FMAX_PATH, Tmp); | |
1540 | + // 環境依存の不具合対策 | |
1541 | +// GetTempPath(FMAX_PATH, Tmp); | |
1542 | + GetAppTempPath(Tmp); | |
1543 | + SetYenTail(Tmp); | |
1541 | 1544 | SendDlgItemMessage(hDlg, MISC_CACHEDIR, WM_SETTEXT, 0, (LPARAM)Tmp); |
1542 | 1545 | break; |
1543 | 1546 | } |
@@ -422,7 +422,10 @@ void SaveRegistory(void) | ||
422 | 422 | |
423 | 423 | WriteMultiStringToReg(hKey4, "DefAttr", DefAttrList); |
424 | 424 | |
425 | - GetTempPath(FMAX_PATH, Str); | |
425 | + // 環境依存の不具合対策 | |
426 | +// GetTempPath(FMAX_PATH, Str); | |
427 | + GetAppTempPath(Str); | |
428 | + SetYenTail(Str); | |
426 | 429 | SaveStr(hKey4, "Tmp", TmpPath, Str); |
427 | 430 | |
428 | 431 | WriteBinaryToReg(hKey4, "Hdlg", &HostDlgSize, sizeof(SIZE)); |