Esempio n. 1
0
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;
}
Esempio n. 3
0
double File::lastModifiedDate() const
{
    time_t modificationTime;
    if (getFileModificationTime(m_path, modificationTime) && isValidFileTime(modificationTime))
        return modificationTime * msPerSecond;

    return currentTime() * msPerSecond;
}
Esempio n. 4
0
void V8File::lastModifiedAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
    File* file = V8File::toNative(info.Holder());
    double lastModified = file->lastModifiedDate();
    if (!isValidFileTime(lastModified))
        lastModified = currentTimeMS();

    // lastModified returns a number, not a Date instance.
    // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs
    v8SetReturnValue(info, floor(lastModified));
}
Esempio n. 5
0
double File::lastModifiedDate() const {
  double modifiedDate = lastModifiedMS();

  // The getter should return the current time when the last modification time
  // isn't known.
  if (!isValidFileTime(modifiedDate))
    modifiedDate = currentTimeMS();

  // lastModifiedDate returns a Date instance,
  // http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate
  return modifiedDate;
}
Esempio n. 6
0
long long File::lastModified() const {
  double modifiedDate = lastModifiedMS();

  // The getter should return the current time when the last modification time
  // isn't known.
  if (!isValidFileTime(modifiedDate))
    modifiedDate = currentTimeMS();

  // lastModified returns a number, not a Date instance,
  // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs
  return floor(modifiedDate);
}
Esempio n. 7
0
// Return false if we cannot advance the stream. Currently the only possible failure is that the underlying file has been removed or changed since File.slice.
static bool advanceCurrentStream(FormStreamFields* form)
{
    closeCurrentStream(form);

    if (form->remainingElements.isEmpty())
        return true;

    // Create the new stream.
    FormDataElement& nextInput = form->remainingElements.last();

    if (nextInput.m_type == FormDataElement::data) {
        size_t size = nextInput.m_data.size();
        MallocPtr<char> data = nextInput.m_data.releaseBuffer();
        form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data.get()), size, kCFAllocatorNull);
        form->currentData = std::move(data);
    } else {
#if ENABLE(BLOB)
        // Check if the file has been changed or not if required.
        if (isValidFileTime(nextInput.m_expectedFileModificationTime)) {
            time_t fileModificationTime;
            if (!getFileModificationTime(nextInput.m_filename, fileModificationTime) || fileModificationTime != static_cast<time_t>(nextInput.m_expectedFileModificationTime))
                return false;
        }
#endif
        const String& path = nextInput.m_shouldGenerateFile ? nextInput.m_generatedFilename : nextInput.m_filename;
        form->currentStream = CFReadStreamCreateWithFile(0, pathAsURL(path).get());
        if (!form->currentStream) {
            // The file must have been removed or become unreadable.
            return false;
        }
#if ENABLE(BLOB)
        if (nextInput.m_fileStart > 0) {
            RetainPtr<CFNumberRef> position = adoptCF(CFNumberCreate(0, kCFNumberLongLongType, &nextInput.m_fileStart));
            CFReadStreamSetProperty(form->currentStream, kCFStreamPropertyFileCurrentOffset, position.get());
        }
        form->currentStreamRangeLength = nextInput.m_fileLength;
#endif
    }
    form->remainingElements.removeLast();

    // Set up the callback.
    CFStreamClientContext context = { 0, form, 0, 0, 0 };
    CFReadStreamSetClient(form->currentStream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered,
        formEventCallback, &context);

    // Schedule with the current set of run loops.
    SchedulePairHashSet::iterator end = form->scheduledRunLoopPairs.end();
    for (SchedulePairHashSet::iterator it = form->scheduledRunLoopPairs.begin(); it != end; ++it)
        CFReadStreamScheduleWithRunLoop(form->currentStream, (*it)->runLoop(), (*it)->mode());

    return true;
}
Esempio n. 8
0
void V8File::lastModifiedDateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
    // The auto-generated getters return null when the method in the underlying
    // implementation returns NaN. The File API says we should return the
    // current time when the last modification time is unknown.
    // Section 7.2 of the File API spec. http://dev.w3.org/2006/webapi/FileAPI/

    File* file = V8File::toNative(info.Holder());
    double lastModified = file->lastModifiedDate();
    if (!isValidFileTime(lastModified))
        lastModified = currentTimeMS();

    // lastModifiedDate returns a Date instance.
    // http://www.w3.org/TR/FileAPI/#file-attrs
    v8SetReturnValue(info, v8::Date::New(info.GetIsolate(), lastModified));
}
Esempio n. 9
0
void FormDataIODevice::openFileForCurrentElement()
{
    if (!m_currentFile)
        m_currentFile = new QFile;

    m_currentFile->setFileName(m_formElements[0].m_filename);
    m_currentFile->open(QFile::ReadOnly);
#if ENABLE(BLOB)
    if (isValidFileTime(m_formElements[0].m_expectedFileModificationTime)) {
        QFileInfo info(*m_currentFile);
        if (!info.exists() || static_cast<time_t>(m_formElements[0].m_expectedFileModificationTime) < info.lastModified().toTime_t()) {
            moveToNextElement();
            return;
        }
    }
    if (m_formElements[0].m_fileStart)
        m_currentFile->seek(m_formElements[0].m_fileStart);
#endif
}