DirectoryService.pas 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. unit DirectoryService;
  2. interface
  3. uses
  4. Classes, SysUtils;
  5. type
  6. TDirectoryService = class
  7. private
  8. public
  9. function GetUserDir: string;
  10. function GetHeadImageDir: string;
  11. function GetCustomFaceDir: string;
  12. function GetReceivedFaceDir: string;
  13. function GetCacheFaceDir: string;
  14. function GetDownloadFileDir: string;
  15. function GetFileExtImagesDir: string;
  16. function GetUserInformationDir: string;
  17. function GetBackgroundDir: string;
  18. class function GetService: TDirectoryService; static;
  19. end;
  20. implementation
  21. uses
  22. UsersService, Forms, RealICQUtility, CurrentContentService;
  23. var
  24. ADirectoryService: TDirectoryService;
  25. function TDirectoryService.GetUserDir: string;
  26. var
  27. FilePath: string;
  28. ALoginName: string;
  29. begin
  30. FilePath := ExtractFilePath(Application.ExeName) + 'Users\';
  31. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  32. ALoginName := TRealICQUtility.ClearCenterServerID(TCurrentContentService.GetService.GetMe.LoginName);
  33. FilePath := FilePath + ALoginName + '\';
  34. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  35. Result := FilePath;
  36. end;
  37. function TDirectoryService.GetDownloadFileDir: String;
  38. var
  39. FilePath: string;
  40. begin
  41. FilePath := GetUserDir + 'DownloadFiles\';
  42. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  43. Result := FilePath;
  44. end;
  45. function TDirectoryService.GetFileExtImagesDir: String;
  46. var
  47. FilePath: string;
  48. begin
  49. FilePath := GetUserDir + 'FileExtImages\';
  50. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  51. Result := FilePath;
  52. end;
  53. function TDirectoryService.GetCacheFaceDir: String;
  54. var
  55. FilePath: string;
  56. begin
  57. FilePath := GetCustomFaceDir + 'CacheFaces\';
  58. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  59. Result := FilePath;
  60. end;
  61. function TDirectoryService.GetReceivedFaceDir: String;
  62. var
  63. FilePath: string;
  64. begin
  65. FilePath := GetUserDir + 'ReceivedFaces\';
  66. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  67. Result := FilePath;
  68. end;
  69. function TDirectoryService.GetCustomFaceDir: String;
  70. var
  71. FilePath: string;
  72. begin
  73. FilePath := GetUserDir + 'MyFaces\';
  74. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  75. Result := FilePath;
  76. end;
  77. function TDirectoryService.GetBackgroundDir: String;
  78. var
  79. FilePath: string;
  80. begin
  81. FilePath := GetUserDir + 'BackGroundImages\';
  82. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  83. Result := FilePath;
  84. end;
  85. function TDirectoryService.GetHeadImageDir: String;
  86. var
  87. FilePath: string;
  88. begin
  89. FilePath := GetUserDir + 'HeadImages\';
  90. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  91. Result := FilePath;
  92. end;
  93. function TDirectoryService.GetUserInformationDir: String;
  94. var
  95. FilePath: string;
  96. begin
  97. FilePath := GetUserDir + 'UserInformations\';
  98. if not DirectoryExists(FilePath) then CreateDir(FilePath);
  99. Result := FilePath;
  100. end;
  101. class function TDirectoryService.GetService: TDirectoryService;
  102. begin
  103. if ADirectoryService = nil then
  104. ADirectoryService := TDirectoryService.Create;
  105. Result := ADirectoryService;
  106. end;
  107. initialization
  108. finalization
  109. if ADirectoryService <> nil then
  110. FreeAndNil(ADirectoryService);
  111. end.