| 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", prefix: "archive"); | 8 #import("archive.dart", prefix: "archive"); |
| 9 #import("entry_request.dart"); | 9 #import("entry_request.dart"); |
| 10 #import("read_request.dart", prefix: 'read'); | 10 #import("read_request.dart", prefix: 'read'); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** Create a new [ArchiveEntry] with default values for all of its fields. */ | 51 /** Create a new [ArchiveEntry] with default values for all of its fields. */ |
| 52 static Future<ArchiveEntry> create() { | 52 static Future<ArchiveEntry> create() { |
| 53 return call(NEW).transform((properties) { | 53 return call(NEW).transform((properties) { |
| 54 return new archive.ArchiveEntry.internal(properties, null); | 54 return new archive.ArchiveEntry.internal(properties, null); |
| 55 }); | 55 }); |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** The id of the underlying archive entry. */ | 58 /** The id of the underlying archive entry. */ |
| 59 int get _id() => _properties[0]; | 59 int get _id => _properties[0]; |
| 60 | 60 |
| 61 /** If this entry is a hardlink, this is the destination. Otherwise, null. */ | 61 /** If this entry is a hardlink, this is the destination. Otherwise, null. */ |
| 62 String get hardlink() => _properties[1]; | 62 String get hardlink => _properties[1]; |
| 63 set hardlink(String value) => _set(SET_HARDLINK, 1, value); | 63 set hardlink(String value) => _set(SET_HARDLINK, 1, value); |
| 64 | 64 |
| 65 /** The path to this entry in the archive. */ | 65 /** The path to this entry in the archive. */ |
| 66 String get pathname() => _properties[2]; | 66 String get pathname => _properties[2]; |
| 67 set pathname(String value) => _set(SET_PATHNAME, 2, value); | 67 set pathname(String value) => _set(SET_PATHNAME, 2, value); |
| 68 | 68 |
| 69 /** The path to this entry on disk, */ | 69 /** The path to this entry on disk, */ |
| 70 String get sourcepath() => _properties[3]; | 70 String get sourcepath => _properties[3]; |
| 71 | 71 |
| 72 /** If this entry is a symlink, this is the destination. Otherwise, null. */ | 72 /** If this entry is a symlink, this is the destination. Otherwise, null. */ |
| 73 String get symlink() => _properties[4]; | 73 String get symlink => _properties[4]; |
| 74 set symlink(String value) => _set(SET_SYMLINK, 4, value); | 74 set symlink(String value) => _set(SET_SYMLINK, 4, value); |
| 75 | 75 |
| 76 /** The group identifier for this entry. */ | 76 /** The group identifier for this entry. */ |
| 77 int get gid() => _properties[5]; | 77 int get gid => _properties[5]; |
| 78 set gid(int value) => _set(SET_GID, 5, value); | 78 set gid(int value) => _set(SET_GID, 5, value); |
| 79 | 79 |
| 80 /** The user identifier for this entry. */ | 80 /** The user identifier for this entry. */ |
| 81 int get uid() => _properties[6]; | 81 int get uid => _properties[6]; |
| 82 set uid(int value) => _set(SET_UID, 6, value); | 82 set uid(int value) => _set(SET_UID, 6, value); |
| 83 | 83 |
| 84 /** The permissions bitmask for this entry. */ | 84 /** The permissions bitmask for this entry. */ |
| 85 int get perm_mask() => _properties[7]; | 85 int get perm_mask => _properties[7]; |
| 86 set perm_mask(int value) => _set(SET_PERM, 7, value); | 86 set perm_mask(int value) => _set(SET_PERM, 7, value); |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * The String representation of the permissions for this entry. | 89 * The String representation of the permissions for this entry. |
| 90 * | 90 * |
| 91 * Note that if you set [perm_mask], this value will not change. | 91 * Note that if you set [perm_mask], this value will not change. |
| 92 */ | 92 */ |
| 93 String get strmode() => _properties[8]; | 93 String get strmode => _properties[8]; |
| 94 | 94 |
| 95 /** The name of the group this entry belongs to. */ | 95 /** The name of the group this entry belongs to. */ |
| 96 String get gname() => _properties[9]; | 96 String get gname => _properties[9]; |
| 97 set gname(String value) => _set(SET_GNAME, 9, value); | 97 set gname(String value) => _set(SET_GNAME, 9, value); |
| 98 | 98 |
| 99 /** The name of the user this entry belongs to. */ | 99 /** The name of the user this entry belongs to. */ |
| 100 String get uname() => _properties[10]; | 100 String get uname => _properties[10]; |
| 101 set uname(String value) => _set(SET_UNAME, 10, value); | 101 set uname(String value) => _set(SET_UNAME, 10, value); |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * The file flag bits that should be set for this entry. | 104 * The file flag bits that should be set for this entry. |
| 105 * | 105 * |
| 106 * Note that if you set [fflags_text], this value will not change, and vice | 106 * Note that if you set [fflags_text], this value will not change, and vice |
| 107 * versa. | 107 * versa. |
| 108 */ | 108 */ |
| 109 int get fflags_set() => _properties[11]; | 109 int get fflags_set => _properties[11]; |
| 110 set fflags_set(int value) => _set(SET_FFLAGS_SET, 11, value); | 110 set fflags_set(int value) => _set(SET_FFLAGS_SET, 11, value); |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * The file flag bits that should be cleared for this entry. | 113 * The file flag bits that should be cleared for this entry. |
| 114 * | 114 * |
| 115 * Note that if you set [fflags_text], this value will not change, and vice | 115 * Note that if you set [fflags_text], this value will not change, and vice |
| 116 * versa. | 116 * versa. |
| 117 */ | 117 */ |
| 118 int get fflags_clear() => _properties[12]; | 118 int get fflags_clear => _properties[12]; |
| 119 set fflags_clear(int value) => _set(SET_FFLAGS_CLEAR, 12, value); | 119 set fflags_clear(int value) => _set(SET_FFLAGS_CLEAR, 12, value); |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * The textual representation of the file flags for this entry. | 122 * The textual representation of the file flags for this entry. |
| 123 * | 123 * |
| 124 * Note that if you set [fflags_set] or [fflags_clear], this value will not | 124 * Note that if you set [fflags_set] or [fflags_clear], this value will not |
| 125 * change, and vice versa. | 125 * change, and vice versa. |
| 126 */ | 126 */ |
| 127 String get fflags_text() => _properties[13]; | 127 String get fflags_text => _properties[13]; |
| 128 | 128 |
| 129 /** The filetype bitmask for this entry. */ | 129 /** The filetype bitmask for this entry. */ |
| 130 int get filetype_mask() => _properties[14]; | 130 int get filetype_mask => _properties[14]; |
| 131 set filetype_mask(int value) => _set(SET_FILETYPE, 14, value); | 131 set filetype_mask(int value) => _set(SET_FILETYPE, 14, value); |
| 132 | 132 |
| 133 /** The filetype and permissions bitmask for this entry. */ | 133 /** The filetype and permissions bitmask for this entry. */ |
| 134 int get mode_mask() => _properties[15]; | 134 int get mode_mask => _properties[15]; |
| 135 set mode_mask(int value) => _set(SET_MODE, 15, value); | 135 set mode_mask(int value) => _set(SET_MODE, 15, value); |
| 136 | 136 |
| 137 /** The size of this entry in bytes, or null if it's unset. */ | 137 /** The size of this entry in bytes, or null if it's unset. */ |
| 138 int get size() => _properties[16]; | 138 int get size => _properties[16]; |
| 139 set size(int value) => _set(SET_SIZE, 16, value); | 139 set size(int value) => _set(SET_SIZE, 16, value); |
| 140 | 140 |
| 141 /** The ID of the device containing this entry, or null if it's unset. */ | 141 /** The ID of the device containing this entry, or null if it's unset. */ |
| 142 int get dev() => _properties[17]; | 142 int get dev => _properties[17]; |
| 143 set dev(int value) => _set(SET_DEV, 17, value); | 143 set dev(int value) => _set(SET_DEV, 17, value); |
| 144 | 144 |
| 145 /** The major number of the ID of the device containing this entry. */ | 145 /** The major number of the ID of the device containing this entry. */ |
| 146 int get devmajor() => _properties[18]; | 146 int get devmajor => _properties[18]; |
| 147 set devmajor(int value) => _set(SET_DEVMAJOR, 18, value); | 147 set devmajor(int value) => _set(SET_DEVMAJOR, 18, value); |
| 148 | 148 |
| 149 /** The minor number of the ID of the device containing this entry. */ | 149 /** The minor number of the ID of the device containing this entry. */ |
| 150 int get devminor() => _properties[19]; | 150 int get devminor => _properties[19]; |
| 151 set devminor(int value) => _set(SET_DEVMINOR, 19, value); | 151 set devminor(int value) => _set(SET_DEVMINOR, 19, value); |
| 152 | 152 |
| 153 /** The inode number of this entry, or null if it's unset. */ | 153 /** The inode number of this entry, or null if it's unset. */ |
| 154 int get ino() => _properties[20]; | 154 int get ino => _properties[20]; |
| 155 set ino(int value) => _set(SET_INO, 20, value); | 155 set ino(int value) => _set(SET_INO, 20, value); |
| 156 | 156 |
| 157 /** The number of references to this entry. */ | 157 /** The number of references to this entry. */ |
| 158 int get nlink() => _properties[21]; | 158 int get nlink => _properties[21]; |
| 159 set nlink(int value) => _set(SET_NLINK, 21, value); | 159 set nlink(int value) => _set(SET_NLINK, 21, value); |
| 160 | 160 |
| 161 /** The device ID of this entry. */ | 161 /** The device ID of this entry. */ |
| 162 int get rdev() => _properties[22]; | 162 int get rdev => _properties[22]; |
| 163 set rdev(int value) => _set(SET_RDEV, 22, value); | 163 set rdev(int value) => _set(SET_RDEV, 22, value); |
| 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 Date get atime => _fromMs(_properties[25]); |
| 175 set atime(Date value) => _set(SET_ATIME, 25, _toMs(value)); | 175 set atime(Date 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 Date get birthtime => _fromMs(_properties[26]); |
| 179 set birthtime(Date value) => _set(SET_BIRTHTIME, 26, _toMs(value)); | 179 set birthtime(Date 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 Date get ctime => _fromMs(_properties[27]); |
| 186 set ctime(Date value) => _set(SET_CTIME, 27, _toMs(value)); | 186 set ctime(Date 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 Date get mtime => _fromMs(_properties[28]); |
| 190 set mtime(Date value) => _set(SET_MTIME, 28, _toMs(value)); | 190 set mtime(Date 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 |
| 201 /** | 201 /** |
| 202 * Consumes the entire contents of this entry at once and returns it wrapped | 202 * Consumes the entire contents of this entry at once and returns it wrapped |
| 203 * in a [CompleteArchiveEntry]. All metadata fields in the returned entry are | 203 * in a [CompleteArchiveEntry]. All metadata fields in the returned entry are |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 /** | 324 /** |
| 325 * An [ArchiveEntry] that contains the complete decompressed contents of the | 325 * An [ArchiveEntry] that contains the complete decompressed contents of the |
| 326 * file. | 326 * file. |
| 327 */ | 327 */ |
| 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 |