media_clip_implementation.cpp 831 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "media/clip/media_clip_implementation.h"
  8. #include "core/file_location.h"
  9. namespace Media {
  10. namespace Clip {
  11. namespace internal {
  12. void ReaderImplementation::initDevice() {
  13. if (_data->isEmpty()) {
  14. if (_file.isOpen()) _file.close();
  15. _file.setFileName(_location->name());
  16. _dataSize = _file.size();
  17. } else {
  18. if (_buffer.isOpen()) _buffer.close();
  19. _buffer.setBuffer(_data);
  20. _dataSize = _data->size();
  21. }
  22. _device = _data->isEmpty() ? static_cast<QIODevice*>(&_file) : static_cast<QIODevice*>(&_buffer);
  23. }
  24. } // namespace internal
  25. } // namespace Clip
  26. } // namespace Media