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()); }
void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) { if (!fileSystem()) { reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); return; } ASSERT(entry && entry->isDirectory()); // We don't allow calling remove() on the root directory. if (entry->fullPath() == String(DOMFilePath::root)) { reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR)); return; } std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCallback, errorCallback, m_context, this)); callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); fileSystem()->removeRecursively(createFileSystemURL(entry), std::move(callbacks)); }
int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String& path, EntriesCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType) { if (!fileSystem()) { reportError(errorCallback, FileError::kAbortErr); return 0; } ASSERT(DOMFilePath::isAbsolute(path)); std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create( successCallback, errorCallback, m_context, reader, path)); callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); return fileSystem()->readDirectory(createFileSystemURL(path), std::move(callbacks)); }
void DOMFileSystem::createWriter(const FileEntry* fileEntry, FileWriterCallback* successCallback, ErrorCallbackBase* errorCallback) { ASSERT(fileEntry); if (!fileSystem()) { reportError(errorCallback, FileError::kAbortErr); return; } FileWriter* fileWriter = FileWriter::create(getExecutionContext()); FileWriterBaseCallback* conversionCallback = ConvertToFileWriterCallback::create(successCallback); std::unique_ptr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create(fileWriter, conversionCallback, errorCallback, m_context); fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, std::move(callbacks)); }
FileWriterSync* DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry, ExceptionState& exceptionState) { ASSERT(fileEntry); FileWriterSync* fileWriter = FileWriterSync::create(); ReceiveFileWriterCallback* successCallback = ReceiveFileWriterCallback::create(); FileError::ErrorCode errorCode = FileError::OK; LocalErrorCallback* errorCallback = LocalErrorCallback::create(errorCode); OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create(fileWriter, successCallback, errorCallback, m_context); callbacks->setShouldBlockUntilCompletion(true); fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, callbacks.release()); if (errorCode != FileError::OK) { FileError::throwDOMException(exceptionState, errorCode); return 0; } return fileWriter; }
void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType) { if (!fileSystem()) { reportError(errorCallback, FileError::kAbortErr); return; } ASSERT(entry); // We don't allow calling remove() on the root directory. if (entry->fullPath() == String(DOMFilePath::root)) { reportError(errorCallback, FileError::kInvalidModificationErr); return; } std::unique_ptr<AsyncFileSystemCallbacks> callbacks( VoidCallbacks::create(successCallback, errorCallback, m_context, this)); callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks)); }
KURL DOMFileSystemBase::createFileSystemURL(const EntryBase* entry) const { return createFileSystemURL(entry->fullPath()); }
void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) { KURL fileSystemURL = createFileSystemURL(fileEntry); m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, SnapshotFileCallback::create(this, fileEntry->name(), fileSystemURL, successCallback, errorCallback)); }
bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) { m_asyncFileSystem->readMetadata(createFileSystemURL(entry), MetadataCallbacks::create(successCallback, errorCallback)); return true; }
bool DOMFileSystemBase::readDirectory(PassRefPtr<DirectoryReaderBase> reader, const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) { ASSERT(DOMFilePath::isAbsolute(path)); m_asyncFileSystem->readDirectory(createFileSystemURL(path), EntriesCallbacks::create(successCallback, errorCallback, reader, path)); return true; }