KDirStat – a graphical disk usage utility
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

kdirsaver.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File name: kdirsaver.h
  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. #ifndef KDirSaver_h
  10. #define KDirSaver_h
  11. #ifdef HAVE_CONFIG_H
  12. #include <config.h>
  13. #endif
  14. #include <kurl.h>
  15. #include <tqdir.h>
  16. /**
  17. * Helper class to change directories without losing the current context.
  18. * Will change back to the old working directory when destroyed.
  19. *
  20. * @short Directory changer with automatic restore
  21. **/
  22. class KDirSaver
  23. {
  24. public:
  25. /**
  26. * Constructor. Will save the current working directory and change to the
  27. * path supplied. The old working directory will be restored when this
  28. * object is destroyed.
  29. **/
  30. KDirSaver( const TQString & newPath = "" );
  31. /**
  32. * Constructor from a KURL. Will issue error messages on stdout for
  33. * non-local objects.
  34. **/
  35. KDirSaver( const KURL & url );
  36. /**
  37. * Destructor. Restores the original working directory.
  38. **/
  39. virtual ~KDirSaver();
  40. /**
  41. * Change directory. Unlike @ref TQDir::cd(), this method really performs a
  42. * system chdir() so subsequent system calls will have the directory
  43. * specified as the new current working directory.
  44. **/
  45. void cd( const TQString & newPath );
  46. /**
  47. * Obtain the current working directory's absolute path.
  48. * This is useful for resolving/simplifying relative paths.
  49. **/
  50. TQString currentDirPath() const;
  51. /**
  52. * (Prematurely) restore the working directory. Unnecessary when this
  53. * object will be destroyed anyway since the destructor does exactly that.
  54. **/
  55. void restore();
  56. protected:
  57. TQDir oldWorkingDir;
  58. };
  59. #endif // KDirSaver_h
  60. // EOF