TDE core libraries
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.

kctimefactory.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* This file is part of the KDE libraries
  2. * Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License version 2 as published by the Free Software Foundation;
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Library General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Library General Public License
  14. * along with this library; see the file COPYING.LIB. If not, write to
  15. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. * Boston, MA 02110-1301, USA.
  17. **/
  18. #include "kctimefactory.h"
  19. #include "tdesycoca.h"
  20. #include "tdesycocatype.h"
  21. #include <assert.h>
  22. KCTimeInfo::KCTimeInfo()
  23. : KSycocaFactory( KST_CTimeInfo ), ctimeDict(977)
  24. {
  25. ctimeDict.setAutoDelete(true);
  26. if (m_str)
  27. {
  28. (*m_str) >> m_dictOffset;
  29. }
  30. else
  31. {
  32. m_dictOffset = 0;
  33. }
  34. }
  35. KCTimeInfo::~KCTimeInfo()
  36. {
  37. }
  38. void
  39. KCTimeInfo::saveHeader(TQDataStream &str)
  40. {
  41. KSycocaFactory::saveHeader(str);
  42. str << m_dictOffset;
  43. }
  44. void
  45. KCTimeInfo::save(TQDataStream &str)
  46. {
  47. KSycocaFactory::save(str);
  48. m_dictOffset = str.device()->at();
  49. TQDictIterator<TQ_UINT32> it(ctimeDict);
  50. while( it.current())
  51. {
  52. str << it.currentKey() << *(it.current());
  53. ++it;
  54. }
  55. str << TQString::null << (TQ_UINT32) 0;
  56. int endOfFactoryData = str.device()->at();
  57. saveHeader(str);
  58. str.device()->at(endOfFactoryData);
  59. }
  60. void
  61. KCTimeInfo::addCTime(const TQString &path, TQ_UINT32 ctime)
  62. {
  63. assert(!path.isEmpty());
  64. ctimeDict.replace(path, new TQ_UINT32(ctime));
  65. }
  66. TQ_UINT32
  67. KCTimeInfo::ctime(const TQString &path)
  68. {
  69. TQ_UINT32 *ctimeP = ctimeDict[path];
  70. return ctimeP ? *ctimeP : 0;
  71. }
  72. void
  73. KCTimeInfo::fillCTimeDict(TQDict<TQ_UINT32> &dict)
  74. {
  75. assert(m_str);
  76. m_str->device()->at(m_dictOffset);
  77. TQString path;
  78. TQ_UINT32 ctime;
  79. while(true)
  80. {
  81. KSycocaEntry::read(*m_str, path);
  82. (*m_str) >> ctime;
  83. if (path.isEmpty()) break;
  84. dict.replace(path, new TQ_UINT32(ctime));
  85. }
  86. }