Skip to content
This repository
Browse code

Merge pull request #3199 from Karlson2k/win32_home_fix_02

Move Add/RemoveExtraLongPathPrefix functions to WIN32Util class
  • Loading branch information...
commit 1a8719806a38abdd09d90e81e869c525d7c7624b 2 parents 98d814c + 37a0c4f
wsoltys authored September 06, 2013
28  xbmc/Util.cpp
@@ -397,7 +397,7 @@ void CUtil::GetHomePath(CStdString& strPath, const CStdString& strTarget)
397 397
     //expand potential relative path to full path
398 398
     CStdStringW strPathW;
399 399
     g_charsetConverter.utf8ToW(strPath, strPathW, false);
400  
-    AddExtraLongPathPrefix(strPathW);
  400
+    CWIN32Util::AddExtraLongPathPrefix(strPathW);
401 401
     const unsigned int bufSize = GetFullPathNameW(strPathW, 0, NULL, NULL);
402 402
     if (bufSize != 0)
403 403
     {
@@ -405,7 +405,7 @@ void CUtil::GetHomePath(CStdString& strPath, const CStdString& strTarget)
405 405
       if (GetFullPathNameW(strPathW, bufSize, buf, NULL) <= bufSize-1)
406 406
       {
407 407
         std::wstring expandedPathW(buf);
408  
-        RemoveExtraLongPathPrefix(expandedPathW);
  408
+        CWIN32Util::RemoveExtraLongPathPrefix(expandedPathW);
409 409
         g_charsetConverter.wToUTF8(expandedPathW, strPath);
410 410
       }
411 411
 
@@ -1503,30 +1503,6 @@ bool CUtil::MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTex
1503 1503
   return true;
1504 1504
 }
1505 1505
 
1506  
-#ifdef TARGET_WINDOWS
1507  
-bool CUtil::AddExtraLongPathPrefix(std::wstring& path)
1508  
-{
1509  
-  const wchar_t* const str = path.c_str();
1510  
-  if (path.length() < 4 || str[0] != L'\\' || str[1] != L'\\' || str[3] != L'\\' || str[2] != L'?')
1511  
-  {
1512  
-    path.insert(0, L"\\\\?\\");
1513  
-    return true;
1514  
-  }
1515  
-  return false;
1516  
-}
1517  
-
1518  
-bool CUtil::RemoveExtraLongPathPrefix(std::wstring& path)
1519  
-{
1520  
-  const wchar_t* const str = path.c_str();
1521  
-  if (path.length() >= 4 && str[0] == L'\\' && str[1] == L'\\' && str[3] == L'\\' && str[2] == L'?')
1522  
-  {
1523  
-    path.erase(0, 4);
1524  
-    return true;
1525  
-  }
1526  
-  return false;
1527  
-}
1528  
-#endif // TARGET_WINDOWS
1529  
-
1530 1506
 bool CUtil::SupportsWriteFileOperations(const CStdString& strPath)
1531 1507
 {
1532 1508
   // currently only hd, smb, nfs, afp and dav support delete and rename
4  xbmc/Util.h
@@ -144,10 +144,6 @@ class CUtil
144 144
 
145 145
   static double AlbumRelevance(const CStdString& strAlbumTemp1, const CStdString& strAlbum1, const CStdString& strArtistTemp1, const CStdString& strArtist1);
146 146
   static bool MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTextMaxLength);
147  
-#ifdef TARGET_WINDOWS
148  
-  static bool AddExtraLongPathPrefix(std::wstring& path);
149  
-  static bool RemoveExtraLongPathPrefix(std::wstring& path);
150  
-#endif // TARGET_WINDOWS
151 147
   /*! \brief Checks wether the supplied path supports Write file operations (e.g. Rename, Delete, ...)
152 148
 
153 149
    \param strPath the path to be checked
22  xbmc/win32/WIN32Util.cpp
@@ -495,6 +495,28 @@ CStdString CWIN32Util::SmbToUnc(const CStdString &strPath)
495 495
   return strRetPath;
496 496
 }
497 497
 
  498
+bool CWIN32Util::AddExtraLongPathPrefix(std::wstring& path)
  499
+{
  500
+  const wchar_t* const str = path.c_str();
  501
+  if (path.length() < 4 || str[0] != L'\\' || str[1] != L'\\' || str[3] != L'\\' || str[2] != L'?')
  502
+  {
  503
+    path.insert(0, L"\\\\?\\");
  504
+    return true;
  505
+  }
  506
+  return false;
  507
+}
  508
+
  509
+bool CWIN32Util::RemoveExtraLongPathPrefix(std::wstring& path)
  510
+{
  511
+  const wchar_t* const str = path.c_str();
  512
+  if (path.length() >= 4 && str[0] == L'\\' && str[1] == L'\\' && str[3] == L'\\' && str[2] == L'?')
  513
+  {
  514
+    path.erase(0, 4);
  515
+    return true;
  516
+  }
  517
+  return false;
  518
+}
  519
+
498 520
 void CWIN32Util::ExtendDllPath()
499 521
 {
500 522
   CStdString strEnv;
2  xbmc/win32/WIN32Util.h
@@ -59,6 +59,8 @@ class CWIN32Util
59 59
   static CStdString GetProfilePath();
60 60
   static CStdString UncToSmb(const CStdString &strPath);
61 61
   static CStdString SmbToUnc(const CStdString &strPath);
  62
+  static bool AddExtraLongPathPrefix(std::wstring& path);
  63
+  static bool RemoveExtraLongPathPrefix(std::wstring& path);
62 64
   static void ExtendDllPath();
63 65
   static HRESULT ToggleTray(const char cDriveLetter='\0');
64 66
   static HRESULT EjectTray(const char cDriveLetter='\0');

0 notes on commit 1a87198

Please sign in to comment.
Something went wrong with that request. Please try again.