Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

  1. //
  2. // MCCPHTT.CPP
  3. //
  4. #include "precomp.h"
  5. static BOOL copyHttFileHelper(LPCTSTR pcszInsFile, LPCTSTR pcszHttWorkDir, LPCTSTR pcszHttFile, LPCTSTR pcszHttKey);
  6. BOOL WINAPI CopyHttFileA(LPCSTR pcszInsFile, LPCSTR pcszHttWorkDir, LPCSTR pcszHttFile, LPCSTR pcszHttKey)
  7. {
  8. USES_CONVERSION;
  9. return copyHttFileHelper(A2CT(pcszInsFile), A2CT(pcszHttWorkDir), A2CT(pcszHttFile), A2CT(pcszHttKey));
  10. }
  11. BOOL WINAPI CopyHttFileW(LPCWSTR pcwszInsFile, LPCWSTR pcwszHttWorkDir, LPCWSTR pcwszHttFile, LPCWSTR pcwszHttKey)
  12. {
  13. USES_CONVERSION;
  14. return copyHttFileHelper(W2CT(pcwszInsFile), W2CT(pcwszHttWorkDir), W2CT(pcwszHttFile), W2CT(pcwszHttKey));
  15. }
  16. static BOOL copyHttFileHelper(LPCTSTR pcszInsFile, LPCTSTR pcszHttWorkDir, LPCTSTR pcszHttFile, LPCTSTR pcszHttKey)
  17. {
  18. BOOL bRet = FALSE;
  19. TCHAR szOldHttFile[MAX_PATH];
  20. if (pcszInsFile == NULL || pcszHttWorkDir == NULL || pcszHttFile == NULL || pcszHttKey == NULL)
  21. return FALSE;
  22. // read the old entry for pcszHttKey
  23. GetPrivateProfileString(DESKTOP_OBJ_SECT, pcszHttKey, TEXT(""), szOldHttFile, ARRAYSIZE(szOldHttFile), pcszInsFile);
  24. // delete the old htt file and all the imgs, if any, in it from pcszHttWorkDir
  25. if (*szOldHttFile)
  26. {
  27. DeleteHtmlImgs(szOldHttFile, pcszHttWorkDir, NULL, NULL);
  28. DeleteFileInDir(szOldHttFile, pcszHttWorkDir);
  29. // clear out the entries in the INS file that correspond to this htt file
  30. WritePrivateProfileString(DESKTOP_OBJ_SECT, pcszHttKey, NULL, pcszInsFile);
  31. }
  32. // copy the htt file and all the imgs, if any, in it to pcszHttWorkDir
  33. if (*pcszHttFile && CopyFileToDir(pcszHttFile, pcszHttWorkDir))
  34. {
  35. CopyHtmlImgs(pcszHttFile, pcszHttWorkDir, NULL, NULL);
  36. WritePrivateProfileString(DESKTOP_OBJ_SECT, pcszHttKey, pcszHttFile, pcszInsFile);
  37. WritePrivateProfileString(DESKTOP_OBJ_SECT, OPTION, TEXT("1"), pcszInsFile);
  38. bRet = TRUE;
  39. }
  40. return (*pcszHttFile == TEXT('\0')) || bRet;
  41. }