Revision: 9338 https://osdn.net/projects/ttssh2/scm/svn/commits/9338 Author: zmatsuo Date: 2021-08-01 14:36:42 +0900 (Sun, 01 Aug 2021) Log Message: ----------- ExtractFilenameW() 追加 Modified Paths: -------------- trunk/teraterm/common/ttlib.h trunk/teraterm/common/ttlib_static_cpp.cpp -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2021-08-01 05:36:29 UTC (rev 9337) +++ trunk/teraterm/common/ttlib.h 2021-08-01 05:36:42 UTC (rev 9338) @@ -47,6 +47,7 @@ DllExport BOOL ExtractFileName(PCHAR PathName, PCHAR FileName, int destlen); DllExport BOOL ExtractDirName(PCHAR PathName, PCHAR DirName); wchar_t *ExtractDirNameW(const wchar_t *PathName); +wchar_t *ExtractFileNameW(const wchar_t *PathName); void FitFileName(PCHAR FileName, int destlen, const char *DefExt); void AppendSlash(PCHAR Path, int destlen); void AppendSlashW(wchar_t *Path, size_t destlen); Modified: trunk/teraterm/common/ttlib_static_cpp.cpp =================================================================== --- trunk/teraterm/common/ttlib_static_cpp.cpp 2021-08-01 05:36:29 UTC (rev 9337) +++ trunk/teraterm/common/ttlib_static_cpp.cpp 2021-08-01 05:36:42 UTC (rev 9338) @@ -799,7 +799,24 @@ } /** + * ExtractFileName() \x82\xCC wchar_t \x94\xC5 + * \x83t\x83\x8B\x83p\x83X\x82\xA9\x82\xE7\x83t\x83@\x83C\x83\x8B\x96\xBC\x95\x94\x95\xAA\x82\xF0\x8E\xE6\x82\xE8\x8Fo\x82\xB7 + * + * @return \x83t\x83@\x83C\x83\x8B\x96\xBC\x95\x94\x95\xAA(\x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7free()\x82\xB7\x82\xE9) + */ +wchar_t *ExtractFileNameW(const wchar_t *PathName) +{ + size_t i; + if (!GetFileNamePosW(PathName, NULL, &i)) + return NULL; + wchar_t *filename = _wcsdup(&PathName[i]); + return filename; +} + +/** * ExtractDirName() \x82\xCC wchar_t \x94\xC5 + * + * @return \x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x96\xBC\x95\x94\x95\xAA(\x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7free()\x82\xB7\x82\xE9) */ wchar_t *ExtractDirNameW(const wchar_t *PathName) {