KDirStat – a graphical disk usage utility
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * File name: kdirsaver.cpp
  3. * Summary: Utility object to save current working directory
  4. * License: LGPL - See file COPYING.LIB for details.
  5. * Author: Stefan Hundhammer <sh@suse.de>
  6. *
  7. * Updated: 2003-01-07
  8. */
  9. #include <unistd.h>
  10. #include <kdebug.h>
  11. #include "kdirsaver.h"
  12. KDirSaver::KDirSaver( const TQString & newPath )
  13. {
  14. /*
  15. * No need to actually save the current working directory: This object
  16. * includes a TQDir whose default constructor constructs a directory object
  17. * that contains the current working directory. Just what is needed here.
  18. */
  19. cd( newPath );
  20. }
  21. KDirSaver::KDirSaver( const KURL & url )
  22. {
  23. if ( url.isLocalFile() )
  24. {
  25. cd( url.path() );
  26. }
  27. else
  28. {
  29. kdError() << k_funcinfo << "Can't change dir to remote location " << url.url() << endl;
  30. }
  31. }
  32. KDirSaver::~KDirSaver()
  33. {
  34. restore();
  35. }
  36. void
  37. KDirSaver::cd( const TQString & newPath )
  38. {
  39. if ( ! newPath.isEmpty() )
  40. {
  41. chdir( newPath.local8Bit() );
  42. }
  43. }
  44. TQString
  45. KDirSaver::currentDirPath() const
  46. {
  47. return TQDir::currentDirPath();
  48. }
  49. void
  50. KDirSaver::restore()
  51. {
  52. chdir( oldWorkingDir.path().local8Bit() );
  53. }
  54. // EOF