| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/filesystem/DirectoryEntrySync.h" | 32 #include "modules/filesystem/DirectoryEntrySync.h" |
| 33 | 33 |
| 34 #include "core/fileapi/FileException.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "modules/filesystem/DirectoryReaderSync.h" | 35 #include "modules/filesystem/DirectoryReaderSync.h" |
| 36 #include "modules/filesystem/EntrySync.h" | 36 #include "modules/filesystem/EntrySync.h" |
| 37 #include "modules/filesystem/FileEntrySync.h" | 37 #include "modules/filesystem/FileEntrySync.h" |
| 38 #include "modules/filesystem/SyncCallbackHelper.h" | 38 #include "modules/filesystem/SyncCallbackHelper.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 DirectoryEntrySync::DirectoryEntrySync(PassRefPtr<DOMFileSystemBase> fileSystem,
const String& fullPath) | 42 DirectoryEntrySync::DirectoryEntrySync(PassRefPtr<DOMFileSystemBase> fileSystem,
const String& fullPath) |
| 43 : EntrySync(fileSystem, fullPath) | 43 : EntrySync(fileSystem, fullPath) |
| 44 { | 44 { |
| 45 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
| 46 } | 46 } |
| 47 | 47 |
| 48 PassRefPtr<DirectoryReaderSync> DirectoryEntrySync::createReader() | 48 PassRefPtr<DirectoryReaderSync> DirectoryEntrySync::createReader() |
| 49 { | 49 { |
| 50 return DirectoryReaderSync::create(m_fileSystem, m_fullPath); | 50 return DirectoryReaderSync::create(m_fileSystem, m_fullPath); |
| 51 } | 51 } |
| 52 | 52 |
| 53 PassRefPtr<FileEntrySync> DirectoryEntrySync::getFile(const String& path, const
Dictionary& options, ExceptionCode& ec) | 53 PassRefPtr<FileEntrySync> DirectoryEntrySync::getFile(const String& path, const
Dictionary& options, ExceptionCode& ec) |
| 54 { | 54 { |
| 55 ec = 0; | 55 ec = 0; |
| 56 FileSystemFlags flags(options); | 56 FileSystemFlags flags(options); |
| 57 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 57 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 58 if (!m_fileSystem->getFile(this, path, flags, helper.successCallback(), help
er.errorCallback())) { | 58 if (!m_fileSystem->getFile(this, path, flags, helper.successCallback(), help
er.errorCallback())) { |
| 59 ec = FileException::INVALID_MODIFICATION_ERR; | 59 ec = FSInvalidModificationError; |
| 60 return 0; | 60 return 0; |
| 61 } | 61 } |
| 62 return static_pointer_cast<FileEntrySync>(helper.getResult(ec)); | 62 return static_pointer_cast<FileEntrySync>(helper.getResult(ec)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String& pa
th, const Dictionary& options, ExceptionCode& ec) | 65 PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String& pa
th, const Dictionary& options, ExceptionCode& ec) |
| 66 { | 66 { |
| 67 ec = 0; | 67 ec = 0; |
| 68 FileSystemFlags flags(options); | 68 FileSystemFlags flags(options); |
| 69 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 69 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 70 if (!m_fileSystem->getDirectory(this, path, flags, helper.successCallback(),
helper.errorCallback())) { | 70 if (!m_fileSystem->getDirectory(this, path, flags, helper.successCallback(),
helper.errorCallback())) { |
| 71 ec = FileException::INVALID_MODIFICATION_ERR; | 71 ec = FSInvalidModificationError; |
| 72 return 0; | 72 return 0; |
| 73 } | 73 } |
| 74 return static_pointer_cast<DirectoryEntrySync>(helper.getResult(ec)); | 74 return static_pointer_cast<DirectoryEntrySync>(helper.getResult(ec)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DirectoryEntrySync::removeRecursively(ExceptionCode& ec) | 77 void DirectoryEntrySync::removeRecursively(ExceptionCode& ec) |
| 78 { | 78 { |
| 79 ec = 0; | 79 ec = 0; |
| 80 VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 80 VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 81 if (!m_fileSystem->removeRecursively(this, helper.successCallback(), helper.
errorCallback())) { | 81 if (!m_fileSystem->removeRecursively(this, helper.successCallback(), helper.
errorCallback())) { |
| 82 ec = FileException::INVALID_MODIFICATION_ERR; | 82 ec = FSInvalidModificationError; |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 helper.getResult(ec); | 85 helper.getResult(ec); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } | 88 } |
| OLD | NEW |