OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/url_request/url_request_file_dir_job.h" | 5 #include "net/url_request/url_request_file_dir_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // SysNativeMBToWide takes care of it at least for now. We can try something | 109 // SysNativeMBToWide takes care of it at least for now. We can try something |
110 // more sophisticated if necessary later. | 110 // more sophisticated if necessary later. |
111 const base::string16& title = WideToUTF16( | 111 const base::string16& title = WideToUTF16( |
112 base::SysNativeMBToWide(dir_path_.value())); | 112 base::SysNativeMBToWide(dir_path_.value())); |
113 #endif | 113 #endif |
114 data_.append(GetDirectoryListingHeader(title)); | 114 data_.append(GetDirectoryListingHeader(title)); |
115 wrote_header_ = true; | 115 wrote_header_ = true; |
116 } | 116 } |
117 | 117 |
118 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
119 std::string raw_bytes; // Empty on Windows means UTF-8 encoded name. | 119 int64 size = (static_cast<unsigned __int64>(data.info.nFileSizeHigh) << 32) | |
| 120 data.info.nFileSizeLow; |
| 121 |
| 122 // Note that we should not convert ftLastWriteTime to the local time because |
| 123 // ICU's datetime formatting APIs expect time in UTC and take into account |
| 124 // the timezone before formatting. |
| 125 data_.append(GetDirectoryListingEntry( |
| 126 data.info.cFileName, |
| 127 std::string(), |
| 128 ((data.info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0), |
| 129 size, |
| 130 base::Time::FromFileTime(data.info.ftLastWriteTime))); |
120 #elif defined(OS_POSIX) | 131 #elif defined(OS_POSIX) |
121 // TOOD(jungshik): The same issue as for the directory name. | 132 // TOOD(jungshik): The same issue as for the directory name. |
122 const std::string& raw_bytes = data.info.GetName().value(); | 133 data_.append(GetDirectoryListingEntry( |
| 134 WideToUTF16(base::SysNativeMBToWide(data.info.filename)), |
| 135 data.info.filename, |
| 136 S_ISDIR(data.info.stat.st_mode), |
| 137 data.info.stat.st_size, |
| 138 base::Time::FromTimeT(data.info.stat.st_mtime))); |
123 #endif | 139 #endif |
124 data_.append(GetDirectoryListingEntry( | |
125 data.info.GetName().LossyDisplayName(), | |
126 raw_bytes, | |
127 data.info.IsDirectory(), | |
128 data.info.GetSize(), | |
129 data.info.GetLastModifiedTime())); | |
130 | 140 |
131 // TODO(darin): coalesce more? | 141 // TODO(darin): coalesce more? |
132 CompleteRead(); | 142 CompleteRead(); |
133 } | 143 } |
134 | 144 |
135 void URLRequestFileDirJob::OnListDone(int error) { | 145 void URLRequestFileDirJob::OnListDone(int error) { |
136 DCHECK(!canceled_); | 146 DCHECK(!canceled_); |
137 if (error != OK) { | 147 if (error != OK) { |
138 read_pending_ = false; | 148 read_pending_ = false; |
139 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, error)); | 149 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, error)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 *bytes_read = count; | 188 *bytes_read = count; |
179 return true; | 189 return true; |
180 } else if (list_complete_) { | 190 } else if (list_complete_) { |
181 // EOF | 191 // EOF |
182 return true; | 192 return true; |
183 } | 193 } |
184 return false; | 194 return false; |
185 } | 195 } |
186 | 196 |
187 } // namespace net | 197 } // namespace net |
OLD | NEW |