| 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 if (!isValidFileTime(modifiedDate)) |
| 184 modifiedDate = currentTimeMS(); |
| 185 |
| 186 // lastModified returns a number, not a Date instance. |
| 187 // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs |
| 188 return floor(modifiedDate); |
| 189 } |
| 190 |
| 191 double File::lastModifiedDate() const |
| 192 { |
| 193 double modifiedDate = lastModifiedMS(); |
| 194 if (!isValidFileTime(modifiedDate)) |
| 195 modifiedDate = currentTimeMS(); |
| 196 |
| 197 // lastModifiedDate returns a Date instance. |
| 198 // http://www.w3.org/TR/FileAPI/#file-attrs |
| 199 return modifiedDate; |
| 200 } |
| 201 |
| 180 unsigned long long File::size() const | 202 unsigned long long File::size() const |
| 181 { | 203 { |
| 182 if (hasValidSnapshotMetadata()) | 204 if (hasValidSnapshotMetadata()) |
| 183 return m_snapshotSize; | 205 return m_snapshotSize; |
| 184 | 206 |
| 185 // FIXME: JavaScript cannot represent sizes as large as unsigned long long,
we need to | 207 // 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. | 208 // come up with an exception to throw if file size is not representable. |
| 187 long long size; | 209 long long size; |
| 188 if (!hasBackingFile() || !getFileSize(m_path, size)) | 210 if (!hasBackingFile() || !getFileSize(m_path, size)) |
| 189 return 0; | 211 return 0; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 captureSnapshot(size, modificationTime); | 292 captureSnapshot(size, modificationTime); |
| 271 if (!m_fileSystemURL.isEmpty()) { | 293 if (!m_fileSystemURL.isEmpty()) { |
| 272 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; | 294 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; |
| 273 return; | 295 return; |
| 274 } | 296 } |
| 275 ASSERT(!m_path.isEmpty()); | 297 ASSERT(!m_path.isEmpty()); |
| 276 blobData.appendFile(m_path, 0, size, modificationTime); | 298 blobData.appendFile(m_path, 0, size, modificationTime); |
| 277 } | 299 } |
| 278 | 300 |
| 279 } // namespace blink | 301 } // namespace blink |
| OLD | NEW |