예제 #1
0
void DOMFileSystemBase::getDirectory(const EntryBase* entry,
                                     const String& path,
                                     const FileSystemFlags& flags,
                                     EntryCallback* successCallback,
                                     ErrorCallbackBase* errorCallback,
                                     SynchronousType synchronousType) {
  if (!fileSystem()) {
    reportError(errorCallback, FileError::kAbortErr);
    return;
  }

  String absolutePath;
  if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) {
    reportError(errorCallback, FileError::kInvalidModificationErr);
    return;
  }

  std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(
      successCallback, errorCallback, m_context, this, absolutePath, true));
  callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);

  if (flags.createFlag())
    fileSystem()->createDirectory(createFileSystemURL(absolutePath),
                                  flags.exclusive(), std::move(callbacks));
  else
    fileSystem()->directoryExists(createFileSystemURL(absolutePath),
                                  std::move(callbacks));
}
void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
{
    if (!fileSystem()) {
        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
        return;
    }

    String absolutePath;
    if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) {
        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
        return;
    }

    std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCallback, errorCallback, m_context, this, absolutePath, false));
    callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);

    if (flags.createFlag())
        fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclusive(), std::move(callbacks));
    else
        fileSystem()->fileExists(createFileSystemURL(absolutePath), std::move(callbacks));
}