diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-04 15:20:21 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-04 15:20:21 +0000 |
commit | 947cf2858d18fc95f76c71622f58cc8957c26799 (patch) | |
tree | b41255b2175d73c1e0719a01eaf1fe07d7da1d86 | |
parent | 419f192d3e4c52ace067722bcfd85904b7c2628b (diff) |
mir_core:
- third parameter pBase added to PathToRelative/PathToRelativeW;
- missing export 'db_mc_notifyDefChange' added to the .def file;
- path utils moved to _tcsncpy_s function;
- useless variables removed;
- libraries regenerated;
git-svn-id: http://svn.miranda-ng.org/main/trunk@9676 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | bin10/lib/mir_core.lib | bin | 59526 -> 59540 bytes | |||
-rw-r--r-- | bin12/lib/mir_core.lib | bin | 59526 -> 59540 bytes | |||
-rw-r--r-- | bin12/lib/mir_core64.lib | bin | 54486 -> 54486 bytes | |||
-rw-r--r-- | include/delphi/m_core.inc | 4 | ||||
-rw-r--r-- | include/m_core.h | 16 | ||||
-rw-r--r-- | src/mir_core/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/path.cpp | 81 |
7 files changed, 53 insertions, 49 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex 5efba8dd33..5a6a8b1260 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib Binary files differindex 8fb46230f7..58b404145c 100644 --- a/bin12/lib/mir_core.lib +++ b/bin12/lib/mir_core.lib diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib Binary files differindex 697864a54b..a3d066d042 100644 --- a/bin12/lib/mir_core64.lib +++ b/bin12/lib/mir_core64.lib diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index 71ca89150f..ffb00ae3e8 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -655,7 +655,7 @@ function PathIsAbsolute(const pSrc:PAnsiChar):int; stdcall; external CoreDLL name 'PathIsAbsolute';
function PathToAbsolute(const pSrc:PAnsiChar; pOut:PAnsiChar; base:PAnsiChar=nil):int; stdcall;
external CoreDLL name 'PathToAbsolute';
-function PathToRelative(const pSrc:PAnsiChar; pOut:PAnsiChar):int; stdcall;
+function PathToRelative(const pSrc:PAnsiChar; pOut:PAnsiChar; base:PAnsiChar=nil):int; stdcall;
external CoreDLL name 'PathToRelative';
procedure CreatePathToFileW(wszFilePath:PWideChar); stdcall;
@@ -666,7 +666,7 @@ function PathIsAbsoluteW(const pSrc:PWideChar):int; stdcall; external CoreDLL name 'PathIsAbsoluteW';
function PathToAbsoluteW(const pSrc:PWideChar; pOut:PWideChar; base:PWideChar=nil):int; stdcall;
external CoreDLL name 'PathToAbsoluteW';
-function PathToRelativeW(const pSrc:PWideChar; pOut:PWideChar):int; stdcall;
+function PathToRelativeW(const pSrc:PWideChar; pOut:PWideChar; base:PWideChar=nil):int; stdcall;
external CoreDLL name 'PathToRelativeW';
diff --git a/include/m_core.h b/include/m_core.h index 6bb86f68a6..6d4dfbbd55 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -588,20 +588,24 @@ MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr); MIR_CORE_DLL(void) CreatePathToFile(char* wszFilePath);
MIR_CORE_DLL(int) CreateDirectoryTree(const char* szDir);
-MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut);
MIR_CORE_DLL(int) PathIsAbsolute(const char *pSrc);
MIR_CORE_DLL(void) CreatePathToFileW(WCHAR* wszFilePath);
MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR* szDir);
-MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut);
MIR_CORE_DLL(int) PathIsAbsoluteW(const WCHAR *pSrc);
#if defined( __cplusplus )
- MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base=0);
- MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, WCHAR* base=0);
+ MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, const char* base=0);
+ MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR* base = 0);
+
+ MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut, const char* base = 0);
+ MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR* base = 0);
#else
- MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base);
- MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, WCHAR* base);
+ MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, const char* base);
+ MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR* base);
+
+ MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut, const char* base);
+ MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR* base);
#endif
#define CreatePathToFileT CreatePathToFileW
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def index 4fd9df1b85..651e71ee90 100644 --- a/src/mir_core/mir_core.def +++ b/src/mir_core/mir_core.def @@ -264,3 +264,4 @@ db_mc_isEnabled @261 LoadLangPackDescr @262
PathIsAbsolute @263
PathIsAbsoluteW @264
+db_mc_notifyDefChange @265
diff --git a/src/mir_core/path.cpp b/src/mir_core/path.cpp index fd57404195..e3d6093bb2 100644 --- a/src/mir_core/path.cpp +++ b/src/mir_core/path.cpp @@ -21,12 +21,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
#include "commonheaders.h"
static char szMirandaPath[MAX_PATH];
-static char szMirandaPathLower[MAX_PATH];
static TCHAR szMirandaPathW[MAX_PATH];
-static TCHAR szMirandaPathWLower[MAX_PATH];
+
+/////////////////////////////////////////////////////////////////////////////////////////
MIR_CORE_DLL(int) PathIsAbsolute(const char *path)
{
@@ -37,30 +38,30 @@ MIR_CORE_DLL(int) PathIsAbsolute(const char *path) return 0;
}
-MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut)
+MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut, const char *pBase)
{
- if ( !pSrc || !strlen(pSrc) || strlen(pSrc)>MAX_PATH) return 0;
- if ( !PathIsAbsolute(pSrc)) {
- mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
- return (int)strlen(pOut);
- }
+ if (!pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH) return 0;
- char szTmp[MAX_PATH];
- mir_snprintf(szTmp, SIZEOF(szTmp), "%s", pSrc);
- _strlwr(szTmp);
- if (strstr(szTmp, szMirandaPathLower)) {
- mir_snprintf(pOut, MAX_PATH, "%s", pSrc+strlen(szMirandaPathLower));
- return (int)strlen(pOut);
- }
+ if (!PathIsAbsolute(pSrc))
+ strncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
else {
- mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
- return (int)strlen(pOut);
+ if (pBase == NULL)
+ pBase = szMirandaPath;
+ char *szTmp = NEWSTR_ALLOCA(pSrc); strlwr(szTmp);
+ char *szBase = NEWSTR_ALLOCA(pBase); strlwr(szBase);
+
+ if (strstr(szTmp, szBase))
+ strncpy_s(pOut, MAX_PATH, pSrc + lstrlenA(szBase), _TRUNCATE);
+ else
+ strncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
}
+
+ return (int)strlen(pOut);
}
-MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base)
+MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, const char *base)
{
- if ( !pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH) {
+ if (!pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH) {
*pOut = 0;
return 0;
}
@@ -78,14 +79,14 @@ MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base) if (pSrc[0] != '\\')
mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc);
else
- mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc+1);
+ mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc + 1);
return GetFullPathNameA(buf, MAX_PATH, pOut, NULL);
}
-MIR_CORE_DLL(void) CreatePathToFile(char* szFilePath)
+MIR_CORE_DLL(void) CreatePathToFile(char *szFilePath)
{
- char* pszLastBackslash = strrchr(szFilePath, '\\');
+ char *pszLastBackslash = strrchr(szFilePath, '\\');
if (pszLastBackslash == NULL)
return;
@@ -97,7 +98,7 @@ MIR_CORE_DLL(void) CreatePathToFile(char* szFilePath) MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir)
{
DWORD dwAttributes;
- char *pszLastBackslash, szTestDir[ MAX_PATH ];
+ char *pszLastBackslash, szTestDir[MAX_PATH];
lstrcpynA(szTestDir, szDir, SIZEOF(szTestDir));
if ((dwAttributes = GetFileAttributesA(szTestDir)) != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
@@ -113,7 +114,7 @@ MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir) return (CreateDirectoryA(szTestDir, NULL) == 0) ? GetLastError() : 0;
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
MIR_CORE_DLL(int) PathIsAbsoluteW(const TCHAR *path)
{
@@ -124,27 +125,29 @@ MIR_CORE_DLL(int) PathIsAbsoluteW(const TCHAR *path) return 0;
}
-MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut)
+MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR *pBase)
{
if (!pSrc || !lstrlen(pSrc) || lstrlen(pSrc) > MAX_PATH)
return 0;
if (!PathIsAbsoluteW(pSrc))
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
+ wcsncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
else {
- TCHAR szTmp[MAX_PATH];
+ if (pBase == NULL)
+ pBase = szMirandaPathW;
+
+ WCHAR *wszTmp = NEWWSTR_ALLOCA(pSrc); wcslwr(wszTmp);
+ WCHAR *wszBase = NEWWSTR_ALLOCA(pBase); wcslwr(wszBase);
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s"), pSrc);
- _tcslwr(szTmp);
- if (_tcsstr(szTmp, szMirandaPathWLower))
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc + lstrlen(szMirandaPathWLower));
+ if (wcsstr(wszTmp, wszBase))
+ wcsncpy_s(pOut, MAX_PATH, pSrc + lstrlen(wszBase), _TRUNCATE);
else
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
+ wcsncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
}
return lstrlen(pOut);
}
-MIR_CORE_DLL(int) PathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base)
+MIR_CORE_DLL(int) PathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, const TCHAR *base)
{
if (!pSrc || !wcslen(pSrc) || wcslen(pSrc) > MAX_PATH) {
*pOut = 0;
@@ -168,7 +171,7 @@ MIR_CORE_DLL(int) PathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base) return GetFullPathName(buf, MAX_PATH, pOut, NULL);
}
-MIR_CORE_DLL(void) CreatePathToFileW(WCHAR* wszFilePath)
+MIR_CORE_DLL(void) CreatePathToFileW(WCHAR *wszFilePath)
{
WCHAR *pszLastBackslash = wcsrchr(wszFilePath, '\\');
if (pszLastBackslash == NULL)
@@ -179,7 +182,7 @@ MIR_CORE_DLL(void) CreatePathToFileW(WCHAR* wszFilePath) *pszLastBackslash = '\\';
}
-MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR* szDir)
+MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR *szDir)
{
DWORD dwAttributes;
WCHAR *pszLastBackslash, szTestDir[MAX_PATH];
@@ -205,14 +208,10 @@ int InitPathUtils(void) p = strrchr(szMirandaPath, '\\');
if (p)
p[1] = 0;
- mir_snprintf(szMirandaPathLower, MAX_PATH, "%s", szMirandaPath);
- _strlwr(szMirandaPathLower);
- GetModuleFileName(hInst, szMirandaPathW, SIZEOF(szMirandaPathW));
- TCHAR *tp = _tcsrchr(szMirandaPathW, '\\');
+ GetModuleFileNameW(hInst, szMirandaPathW, SIZEOF(szMirandaPathW));
+ WCHAR *tp = wcsrchr(szMirandaPathW, '\\');
if (tp)
tp[1] = 0;
- mir_sntprintf(szMirandaPathWLower, SIZEOF(szMirandaPathWLower), _T("%s"), szMirandaPathW);
- _tcslwr(szMirandaPathWLower);
return 0;
}
|