Dependency.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef SE_INCL_DEPENDENCY_H
  13. #define SE_INCL_DEPENDENCY_H
  14. #ifdef PRAGMA_ONCE
  15. #pragma once
  16. #endif
  17. // adjust file path automatically for application path prefix
  18. void AdjustFilePath_t(CTFileName &fnm);
  19. class CDependInfo {
  20. public:
  21. // atributes
  22. CListNode di_Node;
  23. CTFileName di_fnFileName;
  24. time_t di_tTime;
  25. CTFileName di_fnParent;
  26. // default constructor
  27. CDependInfo( CTFileName fnFileName, CTFileName fnParent);
  28. // if this file is updated
  29. BOOL IsFileOnDiskUpdated(void);
  30. // if time of given file is same
  31. inline BOOL IsUpdated(const CDependInfo &diOther) {
  32. return( diOther.di_tTime == di_tTime);};
  33. // if given file is older
  34. inline BOOL IsOlder(const CDependInfo &diOther) {
  35. return( di_tTime < diOther.di_tTime);};
  36. // Comparison operator.
  37. inline BOOL operator==(const CDependInfo &diOther) const {
  38. return( diOther.di_fnFileName == di_fnFileName);};
  39. // read and write opertaions
  40. inline void Read_t( CTStream *istrFile) {
  41. *istrFile >> di_fnFileName;
  42. istrFile->Read_t( &di_tTime, sizeof( time_t));
  43. };
  44. inline void Write_t( CTStream *ostrFile) const {
  45. *ostrFile << di_fnFileName;
  46. ostrFile->Write_t( &di_tTime, sizeof( time_t));
  47. };
  48. };
  49. class CDependencyList {
  50. public:
  51. CListHead dl_ListHead;
  52. // operations
  53. void ExtractDependencies();
  54. // remove updated files from list
  55. void RemoveUpdatedFiles();
  56. // create list from ascii file
  57. void ImportASCII( CTFileName fnAsciiFile);
  58. // export list members into ascii file in form sutable for archivers
  59. void ExportASCII_t( CTFileName fnAsciiFile);
  60. // substracts given list from this
  61. void Substract( CDependencyList &dlToSubstract);
  62. // extract translation strings from all files in list
  63. void ExtractTranslations_t( const CTFileName &fnTranslations);
  64. // clear dependency list
  65. void Clear( void);
  66. // if given file allready has its own DependInfo object linked in list
  67. BOOL ExistsInList(CListHead &lh, CTFileName fnTestName) const;
  68. // read and write opertaions
  69. void Read_t( CTStream *istrFile); // throw char *
  70. void Write_t( CTStream *ostrFile); // throw char *
  71. };
  72. #endif /* include-once check. */