unsigned long long File::size() const { if (hasValidSnapshotMetadata()) return m_snapshotSize; // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we // need to come up with an exception to throw if file size is not // representable. long long size; if (!hasBackingFile() || !getFileSize(m_path, size)) return 0; return static_cast<unsigned long long>(size); }
double File::lastModifiedMS() const { if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTimeMS)) return m_snapshotModificationTimeMS; double modificationTimeMS; if (hasBackingFile() && getFileModificationTime(m_path, modificationTimeMS) && isValidFileTime(modificationTimeMS)) return modificationTimeMS; return currentTimeMS(); }
double File::lastModifiedDate() const { #if ENABLE(FILE_SYSTEM) if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime)) return m_snapshotModificationTime * msPerSecond; #endif time_t modificationTime; if (getFileModificationTime(m_path, modificationTime) && isValidFileTime(modificationTime)) return modificationTime * msPerSecond; return currentTime() * msPerSecond; }
unsigned long long File::size() const { #if ENABLE(FILE_SYSTEM) if (hasValidSnapshotMetadata()) return m_snapshotSize; #endif // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to // come up with an exception to throw if file size is not representable. long long size; if (!getFileSize(m_path, size)) return 0; return static_cast<unsigned long long>(size); }
double File::lastModifiedDate() const { #if ENABLE(FILE_SYSTEM) if (hasValidSnapshotMetadata()) return m_snapshotModificationTime * 1000.0; #endif time_t modificationTime; if (!getFileModificationTime(m_path, modificationTime)) return invalidFileTime(); // Needs to return epoch time in milliseconds for Date. return modificationTime * 1000.0; }
void File::captureSnapshot(long long& snapshotSize, double& snapshotModificationTime) const { #if ENABLE(FILE_SYSTEM) if (hasValidSnapshotMetadata()) { snapshotSize = m_snapshotSize; snapshotModificationTime = m_snapshotModificationTime; return; } #endif // Obtains a snapshot of the file by capturing its current size and modification time. This is used when we slice a file for the first time. // If we fail to retrieve the size or modification time, probably due to that the file has been deleted, 0 size is returned. FileMetadata metadata; if (!getFileMetadata(m_path, metadata)) { snapshotSize = 0; snapshotModificationTime = invalidFileTime(); return; } snapshotSize = metadata.length; snapshotModificationTime = metadata.modificationTime; }