diff --git a/APIHook.cpp b/APIHook.cpp index ebc6a9d..2dac90a 100644 --- a/APIHook.cpp +++ b/APIHook.cpp @@ -364,6 +364,23 @@ class ChronosFileOpenDialog : public IFileOpenDialog } } + int maxFileLength = theApp.m_AppSettings.GetMaxUploadFileLength(); + if (maxFileLength > 0) + { + WCHAR* ptrFile = NULL; + ptrFile = PathFindFileNameW((LPCWSTR)strSelPathOriginal); + CString fileName(ptrFile); + int fileLength = fileName.GetLength(); + if (fileLength > maxFileLength) + { + CString strCaption(theApp.m_strThisAppName); + CString strMsg; + strMsg.Format(L"ファイル名が長すぎるためアップロードできません。\n\n選択したファイルの名前: %d文字\n指定可能なファイル名の最大値: %d文字", fileLength, maxFileLength); + ::MessageBoxW(hwndOwner, strMsg, strCaption, MB_OK | MB_ICONWARNING); + continue; + } + } + if (theApp.m_AppSettings.IsEnableLogging() && theApp.m_AppSettings.IsEnableUploadLogging()) { WCHAR* ptrFile = NULL; @@ -997,6 +1014,21 @@ static BOOL WINAPI Hook_GetOpenFileNameW( } } + int maxFileLength = theApp.m_AppSettings.GetMaxUploadFileLength(); + if (maxFileLength > 0) + { + WCHAR* ptrFile = NULL; + ptrFile = PathFindFileNameW(lpofn->lpstrFile); + CString fileName(ptrFile); + int fileLength = fileName.GetLength(); + if (fileLength > maxFileLength) + { + strMsg.Format(L"ファイル名が長すぎるためアップロードできません。\n\n選択したファイルの名前: %d文字\n指定可能なファイル名の最大値: %d文字", fileLength, maxFileLength); + ::MessageBoxW(lpofn->hwndOwner, strMsg, strCaption, MB_OK | MB_ICONWARNING); + continue; + } + } + PathRemoveFileSpec(strSelPath.GetBuffer()); strSelPath.ReleaseBuffer(); theApp.m_strLastSelectUploadFolderPath = strSelPath; diff --git a/sbcommon.h b/sbcommon.h index ba242c6..c48bf23 100644 --- a/sbcommon.h +++ b/sbcommon.h @@ -951,6 +951,7 @@ class AppSettings WindowCountLimit = 0; EnableMediaAccessByApproval = static_cast(AppSettings::MediaAccessPermission::NO_MEDIA_ACCESS); EnableMediaAccessPermission = static_cast(AppSettings::MediaAccessPermission::NO_MEDIA_ACCESS); + MaxUploadFileLength = 0; EnableDownloadRestriction = 0; EnableUploadRestriction = 0; @@ -1035,6 +1036,7 @@ class AppSettings Data.MemoryUsageLimit = MemoryUsageLimit; Data.WindowCountLimit = WindowCountLimit; Data.EnableMediaAccessPermission = EnableMediaAccessPermission; + Data.MaxUploadFileLength = MaxUploadFileLength; Data.EnableDownloadRestriction = EnableDownloadRestriction; Data.EnableUploadRestriction = EnableUploadRestriction; @@ -1122,6 +1124,7 @@ class AppSettings int WindowCountLimit; int EnableMediaAccessByApproval; // deprecated int EnableMediaAccessPermission; + int MaxUploadFileLength; //リダイレクト設定 int EnableURLRedirect; @@ -1229,6 +1232,7 @@ class AppSettings MemoryUsageLimit = 2040; WindowCountLimit = 60; EnableMediaAccessPermission = static_cast(AppSettings::MediaAccessPermission::NO_MEDIA_ACCESS); + MaxUploadFileLength = 0; ///////////////////////////////////////////////////////////////////////////////////////////////// //リダイレクト設定 @@ -1657,6 +1661,17 @@ class AppSettings continue; } + if (strTemp2.CompareNoCase(_T("MaxUploadFileLength")) == 0) + { + int iW = 0; + iW = _ttoi(strTemp3); + if (0 <= iW && iW <= MAX_PATH - 1) + MaxUploadFileLength = iW; + else + MaxUploadFileLength = 0; + continue; + } + if (strTemp2.CompareNoCase(_T("EnableDownloadRestriction")) == 0) { EnableDownloadRestriction = (strTemp3 == _T("1")) ? TRUE : FALSE; @@ -2020,6 +2035,7 @@ class AppSettings strRet += _T("# non GUI parameters\n"); strRet += EXTVAL(EnableMediaAccessPermission); + strRet += EXTVAL(MaxUploadFileLength); strRet += EXTVAL(UploadBasePath); strRet += EXTVAL(ExitMessage); strRet += EXTVAL(unZipMessage); @@ -2078,6 +2094,7 @@ class AppSettings inline int GetMemoryUsageLimit() { return MemoryUsageLimit; } inline int GetWindowCountLimit() { return WindowCountLimit; } inline int GetMediaAccessPermission() { return EnableMediaAccessPermission; } + inline int GetMaxUploadFileLength() { return MaxUploadFileLength; } inline BOOL IsEnableDownloadRestriction() { return EnableDownloadRestriction; } inline BOOL IsEnableUploadRestriction() { return EnableUploadRestriction; }