From 92be070586e97f44892da28a592aa1c0925a40d1 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Wed, 7 Apr 2010 00:07:56 +0000 Subject: Fixed updating issues git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@502 4f64403b-2f21-0410-a795-97e2b3489a10 --- updater/utils.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'updater/utils.cpp') diff --git a/updater/utils.cpp b/updater/utils.cpp index 6e1afad..98d57be 100644 --- a/updater/utils.cpp +++ b/updater/utils.cpp @@ -47,11 +47,26 @@ int CheckForFileID(char *update_url, char *version_url, char *name) { return -1; } -bool CreatePath(const TCHAR *path) +bool CreatePath(const TCHAR *szDir) { - if (!path) return false; - CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); - return true; + if (!szDir) return false; + + DWORD dwAttributes; + TCHAR *pszLastBackslash, szTestDir[ MAX_PATH ]; + + lstrcpyn( szTestDir, szDir, SIZEOF( szTestDir )); + if (( dwAttributes = GetFileAttributes( szTestDir )) != INVALID_FILE_ATTRIBUTES && ( dwAttributes & FILE_ATTRIBUTE_DIRECTORY )) + return true; + + pszLastBackslash = _tcsrchr( szTestDir, '\\' ); + if ( pszLastBackslash == NULL ) + return true; + + *pszLastBackslash = '\0'; + CreatePath( szTestDir ); + *pszLastBackslash = '\\'; + + return CreateDirectory( szTestDir, NULL ) != 0; } // must 'mir_free' return val -- cgit v1.2.3