예제 #1
0
PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemSyncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& exceptionState)
{
    KURL completedURL = worker->completeURL(url);
    ExecutionContext* secureContext = worker->executionContext();
    if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContext->securityOrigin()->canRequest(completedURL)) {
        exceptionState.throwSecurityError(FileError::securityErrorMessage);
        return 0;
    }

    if (!completedURL.isValid()) {
        exceptionState.throwDOMException(EncodingError, "the URL '" + url + "' is invalid.");
        return 0;
    }

    EntrySyncCallbackHelper resolveURLHelper;
    OwnPtr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::create(resolveURLHelper.successCallback(), resolveURLHelper.errorCallback(), worker);
    callbacks->setShouldBlockUntilCompletion(true);

    LocalFileSystem::from(worker)->resolveURL(worker, completedURL, callbacks.release());

    RefPtr<EntrySync> entry = resolveURLHelper.getResult(exceptionState);
    if (!entry)
        return 0;
    return entry.release();
}
예제 #2
0
PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionState& es) const
{
    EntrySyncCallbackHelper helper;
    if (!m_fileSystem->copy(this, parent.get(), name, helper.successCallback(), helper.errorCallback(), DOMFileSystemBase::Synchronous)) {
        es.throwDOMException(InvalidModificationError, ExceptionMessages::failedToExecute("copyTo", "EntrySync"));
        return 0;
    }
    return helper.getResult(es);
}
예제 #3
0
FileEntrySync* DirectoryEntrySync::getFile(const String& path,
                                           const FileSystemFlags& options,
                                           ExceptionState& exceptionState) {
  EntrySyncCallbackHelper* helper = EntrySyncCallbackHelper::create();
  m_fileSystem->getFile(this, path, options, helper->getSuccessCallback(),
                        helper->getErrorCallback(),
                        DOMFileSystemBase::Synchronous);
  return static_cast<FileEntrySync*>(helper->getResult(exceptionState));
}