This source file includes following definitions.
- is_index_ready_
- Next
- Size
- IsDirectory
- LastModifiedTime
- GetEntryId
- HasMoreEntries
- IsIndexReadyAndInRange
#include "chrome/browser/media_galleries/linux/mtp_device_object_enumerator.h"
#include "base/logging.h"
MTPDeviceObjectEnumerator::MTPDeviceObjectEnumerator(
const std::vector<MtpFileEntry>& entries)
: file_entries_(entries),
index_(0U),
is_index_ready_(false) {
}
MTPDeviceObjectEnumerator::~MTPDeviceObjectEnumerator() {
}
base::FilePath MTPDeviceObjectEnumerator::Next() {
if (IsIndexReadyAndInRange())
++index_;
else if (!is_index_ready_)
is_index_ready_ = true;
if (!HasMoreEntries())
return base::FilePath();
return base::FilePath(file_entries_[index_].file_name());
}
int64 MTPDeviceObjectEnumerator::Size() {
if (!IsIndexReadyAndInRange())
return 0;
return file_entries_[index_].file_size();
}
bool MTPDeviceObjectEnumerator::IsDirectory() {
if (!IsIndexReadyAndInRange())
return false;
return file_entries_[index_].file_type() == MtpFileEntry::FILE_TYPE_FOLDER;
}
base::Time MTPDeviceObjectEnumerator::LastModifiedTime() {
if (!IsIndexReadyAndInRange())
return base::Time();
return base::Time::FromTimeT(file_entries_[index_].modification_time());
}
bool MTPDeviceObjectEnumerator::GetEntryId(uint32_t* entry_id) const {
DCHECK(entry_id);
if (!IsIndexReadyAndInRange())
return false;
*entry_id = file_entries_[index_].item_id();
return true;
}
bool MTPDeviceObjectEnumerator::HasMoreEntries() const {
return index_ < file_entries_.size();
}
bool MTPDeviceObjectEnumerator::IsIndexReadyAndInRange() const {
return is_index_ready_ && HasMoreEntries();
}