00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "list.h"
00008
00009 #ifndef FDM_DLDR__RAWCODEONLY
00010 #include "DownloadsWnd.h"
00011 #endif
00012
00013 #include "downloadproperties.h"
00014 #include "fsDownloadMgr.h"
00015 #include "system.h"
00016
00017 #ifndef FDM_DLDR__RAWCODEONLY
00018 extern CDownloadsWnd* _pwndDownloads;
00019 #endif
00020
00021 void DrawVerticalFrame (HDC hdc, int xStart, int xEnd, int yStart, int height)
00022 {
00023 HPEN hLightPen, hHilightPen, hShadowPen, hOldPen;
00024
00025 hLightPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DLIGHT));
00026 hHilightPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DHILIGHT));
00027 hShadowPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DSHADOW));
00028
00029 int yEnd = yStart + height;
00030
00031 hOldPen = (HPEN) SelectObject (hdc, hLightPen);
00032 MoveToEx (hdc, xStart, yStart, NULL);
00033 LineTo (hdc, xStart, yEnd);
00034
00035 SelectObject (hdc, hHilightPen);
00036 MoveToEx (hdc, xStart+1, yStart, NULL);
00037 LineTo (hdc, xStart+1, yEnd);
00038
00039 SelectObject (hdc, hShadowPen);
00040 MoveToEx (hdc, xEnd, yStart, NULL);
00041 LineTo (hdc, xEnd, yEnd);
00042
00043 SelectObject (hdc, hOldPen);
00044
00045 DeleteObject (hLightPen);
00046 DeleteObject (hHilightPen);
00047 DeleteObject (hShadowPen);
00048 }
00049
00050 void DrawHorizontalFrame (HDC hdc, int yStart, int yEnd, int xStart, int width)
00051 {
00052 HPEN hLightPen, hDarkPen, hHilightPen, hShadowPen, hOldPen;
00053
00054 hLightPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DLIGHT));
00055 hDarkPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DDKSHADOW));
00056 hHilightPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DHILIGHT));
00057 hShadowPen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_3DSHADOW));
00058
00059 int xEnd = xStart + width;
00060
00061 hOldPen = (HPEN) SelectObject (hdc, hLightPen);
00062 MoveToEx (hdc, xStart, yStart, NULL);
00063 LineTo (hdc, xEnd, yStart);
00064
00065 SelectObject (hdc, hHilightPen);
00066 MoveToEx (hdc, xStart, yStart+1, NULL);
00067 LineTo (hdc, xEnd, yStart+1);
00068
00069 SelectObject (hdc, hShadowPen);
00070 MoveToEx (hdc, xStart, yEnd, NULL);
00071 LineTo (hdc, xEnd, yEnd);
00072
00073 SelectObject (hdc, hOldPen);
00074
00075 DeleteObject (hLightPen);
00076 DeleteObject (hDarkPen);
00077 DeleteObject (hHilightPen);
00078 DeleteObject (hShadowPen);
00079 }
00080
00081 void BytesToXBytes (UINT64 uBytes, float* pfXBytes, LPSTR pszXVal)
00082 {
00083 LPCSTR ppszX [] = {LS (L_B), LS (L_KB), LS (L_MB), "GB"};
00084 int i = 0;
00085 double dBytes = (double) (INT64)uBytes;
00086
00087 while (dBytes > 9999)
00088 {
00089 dBytes /= 1024;
00090 i++;
00091 }
00092
00093 if (pszXVal)
00094 {
00095 if (i > 3)
00096 strcpy (pszXVal, "?");
00097 else
00098 strcpy (pszXVal, ppszX [i]);
00099 }
00100
00101 *pfXBytes = (FLOAT) dBytes;
00102 }
00103
00104 #ifndef FDM_DLDR__RAWCODEONLY
00105 CString BytesToString (UINT64 uSize)
00106 {
00107 CString str;
00108
00109 if (_pwndDownloads != NULL && FALSE == _pwndDownloads->IsSizesInBytes ())
00110 {
00111 float val;
00112 char szDim [10];
00113 BytesToXBytes (uSize, &val, szDim);
00114 str.Format ("%.*g %s", val > 999 ? 4 : 3, val, szDim);
00115 }
00116 else
00117 str = fsBytesToStr (uSize);
00118
00119 return str;
00120 }
00121 #endif
00122
00123 void SystemTimeToStr (SYSTEMTIME *time, LPSTR pszDate, LPSTR pszTime, BOOL bSeconds)
00124 {
00125 if (pszDate)
00126 GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, time, NULL, pszDate, 100);
00127
00128 if (pszTime)
00129 {
00130 if (bSeconds)
00131 GetTimeFormat (LOCALE_USER_DEFAULT, 0, time, NULL, pszTime, 100);
00132 else
00133 GetTimeFormat (LOCALE_USER_DEFAULT, TIME_NOSECONDS, time, NULL, pszTime, 100);
00134 }
00135 }
00136
00137 void FileTimeToStr (FILETIME *time, LPSTR pszDate, LPSTR pszTime, BOOL bSeconds)
00138 {
00139 SYSTEMTIME s;
00140 FileTimeToSystemTime (time, &s);
00141 SystemTimeToStr (&s, pszDate, pszTime, bSeconds);
00142 }
00143
00144 BOOL fsErrorToStr (LPSTR pszErr, DWORD dwMaxSize, DWORD* pdwLastError)
00145 {
00146 LPCSTR pszDesc;
00147 CString str;
00148
00149 *pszErr = 0;
00150
00151 switch (pdwLastError ? *pdwLastError : GetLastError ())
00152 {
00153 case ERROR_FILE_NOT_FOUND:
00154 pszDesc = LS (L_FILENOTFOUND);
00155 break;
00156
00157 case ERROR_PATH_NOT_FOUND:
00158 pszDesc = LS (L_PATHNOTFOUND);
00159 break;
00160
00161 case ERROR_BAD_FORMAT:
00162 pszDesc = LS (L_BADEXE);
00163 break;
00164
00165 case ERROR_SHARING_VIOLATION:
00166 pszDesc = LS (L_FILEINUSE);
00167 break;
00168
00169 case ERROR_ACCESS_DENIED:
00170 pszDesc = LS (L_ACCDENIED);
00171 break;
00172
00173 case ERROR_NOT_READY:
00174 pszDesc = LS (L_DEVNOTREADY);
00175 break;
00176
00177 case ERROR_DISK_FULL:
00178 pszDesc = LS (L_DISKFULL);
00179 break;
00180
00181 case ERROR_INVALID_NAME:
00182 pszDesc = LS (L_BADFILENAME);
00183 break;
00184
00185 case ERROR_ALREADY_EXISTS:
00186 pszDesc = LS (L_ALREXISTS);
00187 break;
00188
00189 case ERROR_DIRECTORY:
00190 pszDesc = LS (L_INVALIDDIRNAME);
00191 break;
00192
00193 default:
00194 str.Format ("%s - [%d]", LS (L_UNKERR), pdwLastError ? *pdwLastError : GetLastError ());
00195 pszDesc = str;
00196 }
00197
00198 if (strlen (pszDesc) >= dwMaxSize)
00199 return FALSE;
00200
00201 strcpy (pszErr, pszDesc);
00202
00203 return TRUE;
00204 }
00205
00206 void fsGetPath (LPCSTR pszFile, LPSTR pszPath)
00207 {
00208 strcpy (pszPath, pszFile);
00209
00210 int len = strlen (pszPath) - 1;
00211
00212 while (len >= 0 && pszPath [len] != '\\' && pszPath [len] != '/')
00213 len--;
00214
00215 pszPath [len+1] = 0;
00216 }
00217
00218 void fsGetFileName (LPCSTR pszFilePath, LPSTR pszFileName)
00219 {
00220 CHAR szPath [MY_MAX_PATH];
00221 fsGetPath (pszFilePath, szPath);
00222 strcpy (pszFileName, pszFilePath + strlen (szPath));
00223 }
00224
00225 BOOL fsBuildPathToFile (LPCSTR pszFileName)
00226 {
00227 CHAR szPath [MY_MAX_PATH];
00228
00229 fsGetPath (pszFileName, szPath);
00230
00231 int len = strlen (szPath);
00232 int start = 0;
00233
00234
00235 if (szPath [0] == '\\' && szPath [1] == '\\')
00236 {
00237
00238 LPCSTR psz = strchr (szPath + 2, '\\');
00239
00240 if (psz)
00241 psz = strchr (psz+1, '\\');
00242 if (psz)
00243 psz++;
00244 if (psz == NULL)
00245 {
00246
00247 SetLastError (ERROR_PATH_NOT_FOUND);
00248 return FALSE;
00249 }
00250
00251 start = psz - szPath;
00252 }
00253 else
00254 {
00255 if (szPath [1] == ':')
00256 start = 3;
00257 }
00258
00259 for (int i = start; i < len; i++)
00260 {
00261 if (szPath [i] == '\\' || szPath [i] == '/')
00262 {
00263 CHAR szPath2 [MY_MAX_PATH];
00264
00265 CopyMemory (szPath2, szPath, i);
00266 szPath2 [i] = 0;
00267
00268 if (FALSE == CreateDirectory (szPath2, NULL))
00269 {
00270 if (GetLastError () != ERROR_ALREADY_EXISTS)
00271 return FALSE;
00272 }
00273 }
00274 }
00275
00276 return TRUE;
00277 }
00278
00279 BOOL fsBuildPathToFileW (LPCWSTR pwszFileName)
00280 {
00281 LPCWSTR pwsz = pwszFileName;
00282
00283 for (;;)
00284 {
00285 pwsz = wcschr (pwsz + 1, '\\');
00286 if (pwsz == NULL)
00287 break;
00288 if (pwsz - pwszFileName == 2)
00289 continue;
00290 wchar_t wsz [MY_MAX_PATH];
00291 wcsncpy (wsz, pwszFileName, pwsz - pwszFileName);
00292 wsz [pwsz - pwszFileName] = 0;
00293 CreateDirectoryW (wsz, NULL);
00294 }
00295
00296 return TRUE;
00297 }
00298
00299 #ifndef FDM_DLDR__RAWCODEONLY
00300 BOOL DPEntry_IsAllEqual (DLDS_LIST *pv, int offset, int size, BOOL bString)
00301 {
00302 int cDlds = pv->size ();
00303
00304 if (cDlds == 0)
00305 return FALSE;
00306
00307 LPVOID dp0 = LPBYTE (pv->at (0)->pMgr->GetDownloadMgr ()->GetDP ()) + offset;
00308 LPVOID dpn;
00309
00310 for (int i = 1; i < cDlds; i++)
00311 {
00312 dpn = LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDP ()) + offset;
00313
00314 if (bString)
00315 {
00316 LPCSTR psz1 = *((LPCSTR*) dp0);
00317 LPCSTR psz2 = *((LPCSTR*) dpn);
00318
00319 if (strcmp (psz1, psz2))
00320 return FALSE;
00321 }
00322 else
00323 {
00324 if (memcmp (dp0, dpn, size))
00325 return FALSE;
00326 }
00327 }
00328
00329 return TRUE;
00330 }
00331
00332 BOOL DNPEntry_IsAllEqual (DLDS_LIST *pv, int offset, int size, BOOL bString)
00333 {
00334 int cDlds = pv->size ();
00335
00336 if (cDlds == 0)
00337 return FALSE;
00338
00339 LPVOID dp0 = LPBYTE (pv->at (0)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset;
00340 LPVOID dpn;
00341
00342 for (int i = 1; i < cDlds; i++)
00343 {
00344 dpn = LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset;
00345
00346 if (bString)
00347 {
00348 LPCSTR psz1 = *((LPCSTR*) dp0);
00349 LPCSTR psz2 = *((LPCSTR*) dpn);
00350
00351 if (strcmp (psz1, psz2))
00352 return FALSE;
00353 }
00354 else
00355 {
00356 if (memcmp (dp0, dpn, size))
00357 return FALSE;
00358 }
00359 }
00360
00361 return TRUE;
00362 }
00363
00364 BOOL DPEntry_IsAllEqual_BitMask (DLDS_LIST *pv, int offset, DWORD dwBitMask)
00365 {
00366 int cDlds = pv->size ();
00367
00368 if (cDlds == 0)
00369 return FALSE;
00370
00371 LPDWORD dp0 = (LPDWORD) (LPBYTE (pv->at (0)->pMgr->GetDownloadMgr ()->GetDP ()) + offset);
00372 LPDWORD dpn;
00373
00374 for (int i = 1; i < cDlds; i++)
00375 {
00376 dpn = (LPDWORD) (LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDP ()) + offset);
00377
00378 if ((*dp0 & dwBitMask) != (*dpn & dwBitMask))
00379 return FALSE;
00380 }
00381
00382 return TRUE;
00383 }
00384
00385 void DPEntry_SetValue (DLDS_LIST *pv, int offset, int size, BOOL bString, const void* lpNewVal)
00386 {
00387 LPCSTR pszNewVal = (LPCSTR) lpNewVal;
00388 int len = 0;
00389
00390 if (bString)
00391 len = strlen (pszNewVal);
00392
00393 for (int i = pv->size () - 1; i >= 0; i--)
00394 {
00395 LPVOID dp = LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDP ()) + offset;
00396
00397 if (bString)
00398 {
00399 LPSTR *ppszVal = (LPSTR*) dp;
00400
00401 SAFE_DELETE_ARRAY (*ppszVal);
00402
00403 fsnew (*ppszVal, CHAR, len+1);
00404 strcpy (*ppszVal, pszNewVal);
00405 }
00406 else
00407 {
00408 memcpy (dp, lpNewVal, size);
00409 }
00410 }
00411 }
00412
00413 void DPEntry_SetValue_BitMask (DLDS_LIST *pv, int offset, DWORD dwMask)
00414 {
00415 for (int i = pv->size () - 1; i >= 0; i--)
00416 {
00417 LPDWORD dp = (LPDWORD) (LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDP ()) + offset);
00418 *dp |= dwMask;
00419 }
00420 }
00421
00422 void DPEntry_UnsetValue_BitMask (DLDS_LIST *pv, int offset, DWORD dwMask)
00423 {
00424 for (int i = pv->size () - 1; i >= 0; i--)
00425 {
00426 LPDWORD dp = (LPDWORD) (LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDP ()) + offset);
00427 *dp &= ~dwMask;
00428 }
00429 }
00430
00431 void DNPEntry_SetValue (DLDS_LIST *pv, int offset, int size, BOOL bString, const void* lpNewVal)
00432 {
00433 LPCSTR pszNewVal = (LPCSTR) lpNewVal;
00434 int len = 0;
00435
00436 if (bString)
00437 len = strlen (pszNewVal);
00438
00439 for (int i = pv->size () - 1; i >= 0; i--)
00440 {
00441 LPVOID dnp = LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset;
00442
00443 if (bString)
00444 {
00445 LPSTR *ppszVal = (LPSTR*) dnp;
00446
00447 SAFE_DELETE_ARRAY (*ppszVal);
00448
00449 fsnew (*ppszVal, CHAR, len+1);
00450 strcpy (*ppszVal, pszNewVal);
00451 }
00452 else
00453 {
00454 memcpy (dnp, lpNewVal, size);
00455 }
00456 }
00457 }
00458
00459 BOOL DNPEntry_IsAllEqual_BitMask (DLDS_LIST *pv, int offset, DWORD dwBitMask)
00460 {
00461 int cDlds = pv->size ();
00462
00463 if (cDlds == 0)
00464 return FALSE;
00465
00466 LPDWORD dnp0 = (LPDWORD) (LPBYTE (pv->at (0)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset);
00467 LPDWORD dnpn;
00468
00469 for (int i = 1; i < cDlds; i++)
00470 {
00471 dnpn = (LPDWORD) (LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset);
00472
00473 if ((*dnp0 & dwBitMask) != (*dnpn & dwBitMask))
00474 return FALSE;
00475 }
00476
00477 return TRUE;
00478 }
00479
00480 void DNPEntry_SetValue_BitMask (DLDS_LIST *pv, int offset, DWORD dwMask)
00481 {
00482 for (int i = pv->size () - 1; i >= 0; i--)
00483 {
00484 LPDWORD dnp = (LPDWORD) (LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset);
00485 *dnp |= dwMask;
00486 }
00487 }
00488
00489 void DNPEntry_UnsetValue_BitMask (DLDS_LIST *pv, int offset, DWORD dwMask)
00490 {
00491 for (int i = pv->size () - 1; i >= 0; i--)
00492 {
00493 LPDWORD dnp = (LPDWORD) (LPBYTE (pv->at (i)->pMgr->GetDownloadMgr ()->GetDNP ()) + offset);
00494 *dnp &= ~dwMask;
00495 }
00496 }
00497
00498 #endif
00499
00500 LPCSTR strcmp_m (LPCSTR pszWhere, LPCSTR pszWhat)
00501 {
00502 if (*pszWhere == 0)
00503 return *pszWhat == 0 ? pszWhere : NULL;
00504
00505 if (*pszWhat == 0)
00506 return NULL;
00507
00508 if (*pszWhat == '*')
00509 {
00510
00511 if (pszWhat [1] == 0)
00512 return pszWhere;
00513
00514 LPCSTR psz = strcmp_m (pszWhere, pszWhat+1);
00515 if (psz)
00516 return psz;
00517
00518 return strcmp_m (pszWhere+1, pszWhat);
00519 }
00520
00521 if (*pszWhat != '?')
00522 {
00523
00524 if (*pszWhere != *pszWhat)
00525 return NULL;
00526 }
00527
00528 return strcmp_m (pszWhere+1, pszWhat+1) ? pszWhere : NULL;
00529 }
00530
00531 LPCSTR strcmpi_m (LPCSTR pszWhere, LPCSTR pszWhat)
00532 {
00533 char *psz1 = new char [lstrlen (pszWhere) + 1];
00534 char *psz2 = new char [lstrlen (pszWhat) + 1];
00535
00536 lstrcpy (psz1, pszWhere);
00537 lstrcpy (psz2, pszWhat);
00538
00539 CharLower (psz1);
00540 CharLower (psz2);
00541
00542 LPCSTR psz = strcmp_m (psz1, psz2);
00543 LPCSTR pszRet = NULL;
00544
00545 if (psz)
00546 pszRet = pszWhere + (psz - psz1);
00547
00548 delete [] psz1;
00549 delete [] psz2;
00550
00551 return pszRet;
00552 }
00553
00554 BOOL IsExtStrEq (LPCSTR pszMasked, LPCSTR psz2)
00555 {
00556 return strcmpi_m (psz2, pszMasked) != NULL;
00557 }
00558
00559 BOOL IsExtInExtsStr (LPCSTR pszExts, LPCSTR pszExt)
00560 {
00561 if (pszExt == NULL)
00562 return FALSE;
00563
00564 int len = lstrlen (pszExts);
00565 int i = 0;
00566 CHAR szExt [1000];
00567
00568 do
00569 {
00570 int j = 0;
00571
00572 while (i < len && pszExts [i] != ' ')
00573 szExt [j++] = pszExts [i++];
00574
00575 szExt [j] = 0;
00576 i++;
00577
00578 if (IsExtStrEq (szExt, pszExt))
00579 return TRUE;
00580
00581 } while (i < len);
00582
00583 return FALSE;
00584 }
00585
00586 BOOL fsSaveStrToFile(LPCSTR pszStr, HANDLE hFile)
00587 {
00588 int len;
00589
00590 if (pszStr == NULL)
00591 len = -1;
00592 else
00593 len = strlen (pszStr);
00594
00595 DWORD dw;
00596
00597 if (!WriteFile (hFile, &len, sizeof (len), &dw, NULL))
00598 return FALSE;
00599
00600 if (len != -1)
00601 return WriteFile (hFile, pszStr, len, &dw, NULL);
00602
00603 return TRUE;
00604 }
00605
00606 BOOL fsReadStrFromFile(LPSTR *ppszStr, HANDLE hFile)
00607 {
00608 int len;
00609
00610 DWORD dw;
00611
00612 if (!ReadFile (hFile, &len, sizeof (len), &dw, NULL) || dw != sizeof (len))
00613 return FALSE;
00614
00615 if (len != -1)
00616 {
00617 if (UINT (len) > 100000)
00618 return FALSE;
00619
00620 fsnew (*ppszStr, char, len+1);
00621 if (!ReadFile (hFile, *ppszStr, len, &dw, NULL))
00622 return FALSE;
00623
00624 if (len != int (dw))
00625 return FALSE;
00626
00627 (*ppszStr) [len] = 0;
00628 }
00629 else
00630 *ppszStr = NULL;
00631
00632 return TRUE;
00633 }
00634
00635 BOOL fsReadStringFromFile (HANDLE hFile, fsString &str)
00636 {
00637 SAFE_DELETE_ARRAY (str.pszString);
00638 return fsReadStrFromFile (&str.pszString, hFile);
00639 }
00640
00641 typedef ULONGLONG* LPULONGLONG;
00642
00643 DWORD fsGetTimeDelta (FILETIME *t1, FILETIME *t2)
00644 {
00645 return DWORD ((*LPULONGLONG (t1) - *LPULONGLONG (t2)) / 10000000);
00646 }
00647
00648 DWORD fsGetTimeDelta (const SYSTEMTIME *t1, const SYSTEMTIME *t2)
00649 {
00650 FILETIME ft1, ft2;
00651 SystemTimeToFileTime (t1, &ft1);
00652 SystemTimeToFileTime (t2, &ft2);
00653 return fsGetTimeDelta (&ft1, &ft2);
00654 }
00655
00656 CString fsTimeInSecondsToStr (DWORD dwAmount)
00657 {
00658 CString strResult;
00659
00660 strResult.Format (_T ("%02d:%02d:%02d"),
00661 (int)(dwAmount / 3600),
00662 (int)((dwAmount % 3600) / 60),
00663 (int)(dwAmount % 60));
00664
00665 return strResult;
00666 }
00667
00668 #pragma warning (disable:4706)
00669 void fsPathToGoodPath (LPSTR pszPath)
00670 {
00671 LPSTR pszBad = pszPath;
00672
00673 while (pszBad = strchr (pszBad, '/'))
00674 *pszBad = '\\';
00675 }
00676
00677 void fsPathToGoodUrlPath (LPSTR pszPath)
00678 {
00679 LPSTR pszBad = pszPath;
00680
00681 while (pszBad = strchr (pszBad, '\\'))
00682 *pszBad = '/';
00683 }
00684 #pragma warning (default:4706)
00685
00686 #ifndef FDM_DLDR__RAWCODEONLY
00687 void fsOpenBuyPage ()
00688 {
00689
00690 #ifdef WGET_AFFILIATE_ID
00691 #pragma message ("================================ AFFILIATE IS ACTIVE!!! ==========================")
00692 CString str;
00693 str.Format ("https://www.regnow.com/softsell/nph-softsell.cgi?item=9752-1&affiliate=%d", WGET_AFFILIATE_ID);
00694 fsOpenUrlInBrowser (str);
00695 #else
00696 if (stricmp (_LngMgr.GetLngName (_LngMgr.GetCurLng ()), "Russian"))
00697 fsOpenUrlInBrowser ("http://www.opendownloadmanager.org/buy.html");
00698 else
00699 fsOpenUrlInBrowser ("http://www.opendownloadmanager.org/buy.html");
00700 #endif
00701 }
00702
00703 CString fsBytesToStr (UINT64 uBytes)
00704 {
00705 CString strBytes = " ";
00706 strBytes += LS (L_B);
00707 CString str;
00708 UINT u;
00709
00710 do
00711 {
00712 if (uBytes > 1000)
00713 u = UINT (uBytes % 1000);
00714 else
00715 u = 0;
00716
00717 if (u)
00718 {
00719 str.Format (",%d", u);
00720 if (str.GetLength () == 2)
00721 str.Insert (1, "00");
00722 else if (str.GetLength () == 3)
00723 str.Insert (1, "0");
00724 }
00725 else
00726 {
00727 if (uBytes < 1000)
00728 str.Format ("%d", (UINT)uBytes);
00729 else
00730 {
00731 str = ",000";
00732 }
00733 }
00734
00735 uBytes /= 1000;
00736
00737 strBytes.Insert (0, str);
00738 }
00739 while (uBytes);
00740
00741 return strBytes;
00742 }
00743
00744 CString fsGetGrpOTHEROutFolder ()
00745 {
00746 return _DldsGrps.FindGroup (GRP_OTHER_ID)->strOutFolder;
00747 }
00748 #endif
00749
00750 void vmsUtf8ToAscii (LPSTR psz)
00751 {
00752 wchar_t wsz [100000] = L"";
00753 int len = lstrlen (psz);
00754 MultiByteToWideChar (CP_UTF8, 0, psz, len, wsz, 99999);
00755 WideCharToMultiByte (CP_ACP, 0, wsz, -1, psz, len+1, NULL, NULL);
00756 }
00757
00758 std::wstring vmsUtf8Unicode (LPCSTR psz)
00759 {
00760 wchar_t wsz [100000] = L"";
00761 MultiByteToWideChar (CP_UTF8, 0, psz, -1, wsz, 99999);
00762 return wsz;
00763 }