OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library entry; | 5 library entry; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'archive.dart' as archive; | 8 import 'archive.dart' as archive; |
9 import 'entry_request.dart'; | 9 import 'entry_request.dart'; |
10 import 'read_request.dart' as read; | 10 import 'read_request.dart' as read; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 /** The major number of the device ID of this entry. */ | 165 /** The major number of the device ID of this entry. */ |
166 int get rdevmajor => _properties[23]; | 166 int get rdevmajor => _properties[23]; |
167 set rdevmajor(int value) => _set(SET_RDEVMAJOR, 23, value); | 167 set rdevmajor(int value) => _set(SET_RDEVMAJOR, 23, value); |
168 | 168 |
169 /** The minor number of the device ID of this entry. */ | 169 /** The minor number of the device ID of this entry. */ |
170 int get rdevminor => _properties[24]; | 170 int get rdevminor => _properties[24]; |
171 set rdevminor(int value) => _set(SET_RDEVMINOR, 24, value); | 171 set rdevminor(int value) => _set(SET_RDEVMINOR, 24, value); |
172 | 172 |
173 /** The last time this entry was accessed, or null if it's unset. */ | 173 /** The last time this entry was accessed, or null if it's unset. */ |
174 Date get atime => _fromMs(_properties[25]); | 174 DateTime get atime => _fromMs(_properties[25]); |
175 set atime(Date value) => _set(SET_ATIME, 25, _toMs(value)); | 175 set atime(DateTime value) => _set(SET_ATIME, 25, _toMs(value)); |
176 | 176 |
177 /** The time this entry was created, or null if it's unset. */ | 177 /** The time this entry was created, or null if it's unset. */ |
178 Date get birthtime => _fromMs(_properties[26]); | 178 DateTime get birthtime => _fromMs(_properties[26]); |
179 set birthtime(Date value) => _set(SET_BIRTHTIME, 26, _toMs(value)); | 179 set birthtime(DateTime value) => _set(SET_BIRTHTIME, 26, _toMs(value)); |
180 | 180 |
181 /** | 181 /** |
182 * The last time an inode property of this entry was changed, or null if it's | 182 * The last time an inode property of this entry was changed, or null if it's |
183 * unset. | 183 * unset. |
184 */ | 184 */ |
185 Date get ctime => _fromMs(_properties[27]); | 185 DateTime get ctime => _fromMs(_properties[27]); |
186 set ctime(Date value) => _set(SET_CTIME, 27, _toMs(value)); | 186 set ctime(DateTime value) => _set(SET_CTIME, 27, _toMs(value)); |
187 | 187 |
188 /** The last time this entry was modified, or null if it's unset. */ | 188 /** The last time this entry was modified, or null if it's unset. */ |
189 Date get mtime => _fromMs(_properties[28]); | 189 DateTime get mtime => _fromMs(_properties[28]); |
190 set mtime(Date value) => _set(SET_MTIME, 28, _toMs(value)); | 190 set mtime(DateTime value) => _set(SET_MTIME, 28, _toMs(value)); |
191 | 191 |
192 /** Whether [openInputStream] has been called. */ | 192 /** Whether [openInputStream] has been called. */ |
193 bool get isInputOpen => _input != null; | 193 bool get isInputOpen => _input != null; |
194 | 194 |
195 /** Create a deep copy of this [ArchiveEntry]. */ | 195 /** Create a deep copy of this [ArchiveEntry]. */ |
196 Future<ArchiveEntry> clone() { | 196 Future<ArchiveEntry> clone() { |
197 return call(CLONE, _id). | 197 return call(CLONE, _id). |
198 transform((array) => new archive.ArchiveEntry.internal(array, null)); | 198 transform((array) => new archive.ArchiveEntry.internal(array, null)); |
199 } | 199 } |
200 | 200 |
(...skipping 23 matching lines...) Expand all Loading... |
224 */ | 224 */ |
225 void _set(int requestType, int index, value) { | 225 void _set(int requestType, int index, value) { |
226 _properties[index] = value; | 226 _properties[index] = value; |
227 // Since the native code processes messages in order, the SET_* messages | 227 // Since the native code processes messages in order, the SET_* messages |
228 // will be received and processed before any further messages. | 228 // will be received and processed before any further messages. |
229 call(requestType, _id, [value]).then((_) {}); | 229 call(requestType, _id, [value]).then((_) {}); |
230 } | 230 } |
231 | 231 |
232 /** | 232 /** |
233 * Converts [ms], the (possibly null) number of milliseconds since the epoch | 233 * Converts [ms], the (possibly null) number of milliseconds since the epoch |
234 * into a Date object (which may also be null). | 234 * into a DateTime object (which may also be null). |
235 */ | 235 */ |
236 Date _fromMs(int ms) { | 236 DateTime _fromMs(int ms) { |
237 if (ms == null) return null; | 237 if (ms == null) return null; |
238 return new Date.fromMillisecondsSinceEpoch(ms); | 238 return new DateTime.fromMillisecondsSinceEpoch(ms); |
239 } | 239 } |
240 | 240 |
241 /** | 241 /** |
242 * Converts [date], which may be null, into the number of milliseconds since | 242 * Converts [date], which may be null, into the number of milliseconds since |
243 * the epoch (which may also be null). | 243 * the epoch (which may also be null). |
244 */ | 244 */ |
245 int _toMs(Date date) { | 245 int _toMs(DateTime date) { |
246 if (date == null) return null; | 246 if (date == null) return null; |
247 return date.millisecondsSinceEpoch; | 247 return date.millisecondsSinceEpoch; |
248 } | 248 } |
249 | 249 |
250 /** | 250 /** |
251 * Creates a new input stream for reading the contents of this entry. | 251 * Creates a new input stream for reading the contents of this entry. |
252 * | 252 * |
253 * The contents of an entry must be consumed before the next entry is read | 253 * The contents of an entry must be consumed before the next entry is read |
254 * from the parent [ArchiveInputStream]. This means that [openInputStream] | 254 * from the parent [ArchiveInputStream]. This means that [openInputStream] |
255 * must be called from the [ArchiveInputStream.onEntry] callback, or before | 255 * must be called from the [ArchiveInputStream.onEntry] callback, or before |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 class CompleteArchiveEntry extends ArchiveEntry { | 328 class CompleteArchiveEntry extends ArchiveEntry { |
329 /** The contents of the entry as bytes. */ | 329 /** The contents of the entry as bytes. */ |
330 final List<int> contentBytes; | 330 final List<int> contentBytes; |
331 | 331 |
332 /** The contents of the entry as a string. */ | 332 /** The contents of the entry as a string. */ |
333 String get contents => new String.fromCharCodes(contentBytes); | 333 String get contents => new String.fromCharCodes(contentBytes); |
334 | 334 |
335 CompleteArchiveEntry._(List properties, this.contentBytes) | 335 CompleteArchiveEntry._(List properties, this.contentBytes) |
336 : super.internal(properties, null); | 336 : super.internal(properties, null); |
337 } | 337 } |
OLD | NEW |