1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/parsers/metadata_parser_filebase.h"
7 #include "base/file_util.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h"
11 FileMetadataParser::FileMetadataParser(const base::FilePath& path)
12 : MetadataParser(path),
16 FileMetadataParser::~FileMetadataParser() {}
18 bool FileMetadataParser::Parse() {
21 if (file_util::GetFileSize(path_, &size)) {
22 properties_[MetadataParser::kPropertyFilesize] = base::Int64ToString(size);
25 value = WideToUTF8(path_.BaseName().value());
26 properties_[MetadataParser::kPropertyTitle] = value;
27 #elif defined(OS_POSIX)
28 properties_[MetadataParser::kPropertyTitle] = path_.BaseName().value();
33 bool FileMetadataParser::GetProperty(const std::string& key,
35 PropertyMap::iterator it = properties_.find(key.c_str());
36 if (it == properties_.end()) {
40 *value = properties_[key.c_str()];
44 MetadataPropertyIterator* FileMetadataParser::GetPropertyIterator() {
45 return new FileMetadataPropertyIterator(properties_);
48 FileMetadataPropertyIterator::FileMetadataPropertyIterator(
49 PropertyMap& properties) : properties_(properties) {
50 it = properties_.begin();
53 FileMetadataPropertyIterator::~FileMetadataPropertyIterator() {}
55 bool FileMetadataPropertyIterator::GetNext(std::string* key,
57 if (it == properties_.end()) {
66 int FileMetadataPropertyIterator::Length() {
67 return properties_.size();
70 bool FileMetadataPropertyIterator::IsEnd() {
71 if (it == properties_.end()) {