Ejemplo n.º 1
0
void DOMFileSystemBase::copy(const EntryBase* source,
                             EntryBase* parent,
                             const String& newName,
                             EntryCallback* successCallback,
                             ErrorCallbackBase* errorCallback,
                             SynchronousType synchronousType) {
  if (!fileSystem()) {
    reportError(errorCallback, FileError::kAbortErr);
    return;
  }

  String destinationPath;
  if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName,
                                                destinationPath)) {
    reportError(errorCallback, FileError::kInvalidModificationErr);
    return;
  }

  std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(
      successCallback, errorCallback, m_context, parent->filesystem(),
      destinationPath, source->isDirectory()));
  callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);

  fileSystem()->copy(createFileSystemURL(source),
                     parent->filesystem()->createFileSystemURL(destinationPath),
                     std::move(callbacks));
}
Ejemplo n.º 2
0
bool DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
{
    String destinationPath;
    if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath))
        return false;

    m_asyncFileSystem->copy(source->fullPath(), destinationPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
    return true;
}
Ejemplo n.º 3
0
bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
{
    String destinationPath;
    if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath))
        return false;

    String sourcePlatformPath = m_asyncFileSystem->virtualToPlatformPath(source->fullPath());
    String destinationPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destinationPath);
    m_asyncFileSystem->move(sourcePlatformPath, destinationPlatformPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
    return true;
}
void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const String& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
{
    if (!fileSystem()) {
        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
        return;
    }

    String destinationPath;
    if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath)) {
        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
        return;
    }

    OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCallback, errorCallback, m_context, parent->filesystem(), destinationPath, source->isDirectory()));
    callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);

    fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->createFileSystemURL(destinationPath), callbacks.release());
}