| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 , m_hasBackingFile(true) | 158 , m_hasBackingFile(true) |
| 159 , m_userVisibility(File::IsNotUserVisible) | 159 , m_userVisibility(File::IsNotUserVisible) |
| 160 , m_name(decodeURLEscapeSequences(fileSystemURL.lastPathComponent())) | 160 , m_name(decodeURLEscapeSequences(fileSystemURL.lastPathComponent())) |
| 161 , m_fileSystemURL(fileSystemURL) | 161 , m_fileSystemURL(fileSystemURL) |
| 162 , m_snapshotSize(metadata.length) | 162 , m_snapshotSize(metadata.length) |
| 163 , m_snapshotModificationTime(metadata.modificationTime) | 163 , m_snapshotModificationTime(metadata.modificationTime) |
| 164 { | 164 { |
| 165 ScriptWrappable::init(this); | 165 ScriptWrappable::init(this); |
| 166 } | 166 } |
| 167 | 167 |
| 168 double File::lastModifiedDate() const | 168 double File::lastModifiedMS() const |
| 169 { | 169 { |
| 170 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime
)) | 170 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime
)) |
| 171 return m_snapshotModificationTime * msPerSecond; | 171 return m_snapshotModificationTime * msPerSecond; |
| 172 | 172 |
| 173 time_t modificationTime; | 173 time_t modificationTime; |
| 174 if (hasBackingFile() && getFileModificationTime(m_path, modificationTime) &&
isValidFileTime(modificationTime)) | 174 if (hasBackingFile() && getFileModificationTime(m_path, modificationTime) &&
isValidFileTime(modificationTime)) |
| 175 return modificationTime * msPerSecond; | 175 return modificationTime * msPerSecond; |
| 176 | 176 |
| 177 return currentTime() * msPerSecond; | 177 return currentTime() * msPerSecond; |
| 178 } | 178 } |
| 179 | 179 |
| 180 long long File::lastModified() const |
| 181 { |
| 182 double modifiedDate = lastModifiedMS(); |
| 183 |
| 184 // The getter should return the current time when the last modification time
isn't known. |
| 185 if (!isValidFileTime(modifiedDate)) |
| 186 modifiedDate = currentTimeMS(); |
| 187 |
| 188 // lastModified returns a number, not a Date instance, |
| 189 // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs |
| 190 return floor(modifiedDate); |
| 191 } |
| 192 |
| 193 double File::lastModifiedDate() const |
| 194 { |
| 195 double modifiedDate = lastModifiedMS(); |
| 196 |
| 197 // The getter should return the current time when the last modification time
isn't known. |
| 198 if (!isValidFileTime(modifiedDate)) |
| 199 modifiedDate = currentTimeMS(); |
| 200 |
| 201 // lastModifiedDate returns a Date instance, |
| 202 // http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate |
| 203 return modifiedDate; |
| 204 } |
| 205 |
| 180 unsigned long long File::size() const | 206 unsigned long long File::size() const |
| 181 { | 207 { |
| 182 if (hasValidSnapshotMetadata()) | 208 if (hasValidSnapshotMetadata()) |
| 183 return m_snapshotSize; | 209 return m_snapshotSize; |
| 184 | 210 |
| 185 // FIXME: JavaScript cannot represent sizes as large as unsigned long long,
we need to | 211 // FIXME: JavaScript cannot represent sizes as large as unsigned long long,
we need to |
| 186 // come up with an exception to throw if file size is not representable. | 212 // come up with an exception to throw if file size is not representable. |
| 187 long long size; | 213 long long size; |
| 188 if (!hasBackingFile() || !getFileSize(m_path, size)) | 214 if (!hasBackingFile() || !getFileSize(m_path, size)) |
| 189 return 0; | 215 return 0; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 captureSnapshot(size, modificationTime); | 296 captureSnapshot(size, modificationTime); |
| 271 if (!m_fileSystemURL.isEmpty()) { | 297 if (!m_fileSystemURL.isEmpty()) { |
| 272 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; | 298 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; |
| 273 return; | 299 return; |
| 274 } | 300 } |
| 275 ASSERT(!m_path.isEmpty()); | 301 ASSERT(!m_path.isEmpty()); |
| 276 blobData.appendFile(m_path, 0, size, modificationTime); | 302 blobData.appendFile(m_path, 0, size, modificationTime); |
| 277 } | 303 } |
| 278 | 304 |
| 279 } // namespace blink | 305 } // namespace blink |
| OLD | NEW |