/mordor/streams/temp.h

http://github.com/mozy/mordor · C Header · 46 lines · 24 code · 10 blank · 12 comment · 0 complexity · be8526b1cb740b9b123d127ef1bca687 MD5 · raw file

  1. #ifndef __MORDOR_TEMP_STREAM_H__
  2. #define __MORDOR_TEMP_STREAM_H__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include "file.h"
  5. namespace Mordor {
  6. #ifdef WINDOWS
  7. typedef FileStream TempStreamBase;
  8. #else
  9. typedef FDStream TempStreamBase;
  10. #endif
  11. class TempStream : public TempStreamBase
  12. {
  13. public:
  14. typedef boost::shared_ptr<TempStream> ptr;
  15. public:
  16. /// Create a stream representing a temporary file
  17. /// @param prefix The prefix for the temporary file. If it is an absolute
  18. /// path, the file will be created in that location. If it is relative, it
  19. /// will be relative to the system temporary directory. In either case,
  20. /// a suffix will be added to make it unique.
  21. /// @param deleteOnClose If the file will be created with
  22. /// FileStream::DELETE_ON_CLOSE flag, to guarantee the file will be cleaned
  23. /// up when the TempStream destructs (or the process dies).
  24. /// @param ioManager The IOManager to use for any asynchronous I/O, if
  25. /// possible
  26. /// @param scheduler The Scheduler to switchTo for any blocking I/O
  27. TempStream(const std::string &prefix = "", bool deleteOnClose = true,
  28. IOManager *ioManager = NULL, Scheduler *scheduler = NULL);
  29. #ifndef WINDOWS
  30. std::string path() const { return m_path; }
  31. private:
  32. std::string m_path;
  33. #endif
  34. };
  35. }
  36. #endif