| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 OwnPtr<BlobData> blobData = BlobData::create(); | 74 OwnPtr<BlobData> blobData = BlobData::create(); |
| 75 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We
llKnownContentTypes)); | 75 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We
llKnownContentTypes)); |
| 76 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod
ificationTime); | 76 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod
ificationTime); |
| 77 return blobData.release(); | 77 return blobData.release(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste
mURL, const FileMetadata& metadata) | 80 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste
mURL, const FileMetadata& metadata) |
| 81 { | 81 { |
| 82 OwnPtr<BlobData> blobData = BlobData::create(); | 82 OwnPtr<BlobData> blobData = BlobData::create(); |
| 83 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi
le::WellKnownContentTypes)); | 83 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi
le::WellKnownContentTypes)); |
| 84 blobData->appendURL(fileSystemURL, 0, metadata.length, metadata.modification
Time); | 84 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo
dificationTime); |
| 85 return blobData.release(); | 85 return blobData.release(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 PassRefPtr<File> File::createWithRelativePath(const String& path, const String&
relativePath) | 88 PassRefPtr<File> File::createWithRelativePath(const String& path, const String&
relativePath) |
| 89 { | 89 { |
| 90 RefPtr<File> file = adoptRef(new File(path, AllContentTypes)); | 90 RefPtr<File> file = adoptRef(new File(path, AllContentTypes)); |
| 91 file->m_relativePath = relativePath; | 91 file->m_relativePath = relativePath; |
| 92 return file.release(); | 92 return file.release(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 File::File(const String& path, ContentTypeLookupPolicy policy) | 95 File::File(const String& path, ContentTypeLookupPolicy policy) |
| 96 : Blob(createBlobDataForFile(path, policy), -1) | 96 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) |
| 97 , m_path(path) | 97 , m_path(path) |
| 98 , m_name(WebKit::Platform::current()->fileUtilities()->baseName(path)) | 98 , m_name(WebKit::Platform::current()->fileUtilities()->baseName(path)) |
| 99 , m_snapshotSize(-1) | 99 , m_snapshotSize(-1) |
| 100 , m_snapshotModificationTime(invalidFileTime()) | 100 , m_snapshotModificationTime(invalidFileTime()) |
| 101 { | 101 { |
| 102 ScriptWrappable::init(this); | 102 ScriptWrappable::init(this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 File::File(const String& path, const KURL& url, const String& type) | |
| 106 : Blob(url, type, -1) | |
| 107 , m_path(path) | |
| 108 , m_snapshotSize(-1) | |
| 109 , m_snapshotModificationTime(invalidFileTime()) | |
| 110 { | |
| 111 ScriptWrappable::init(this); | |
| 112 m_name = WebKit::Platform::current()->fileUtilities()->baseName(path); | |
| 113 // FIXME: File object serialization/deserialization does not include | |
| 114 // newer file object data members: m_name and m_relativePath. | |
| 115 // See SerializedScriptValue.cpp for js and v8. | |
| 116 } | |
| 117 | |
| 118 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic
y) | 105 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic
y) |
| 119 : Blob(createBlobDataForFileWithName(path, name, policy), -1) | 106 : Blob(BlobDataHandle::create(createBlobDataForFileWithName(path, name, poli
cy), -1)) |
| 120 , m_path(path) | 107 , m_path(path) |
| 121 , m_name(name) | 108 , m_name(name) |
| 122 , m_snapshotSize(-1) | 109 , m_snapshotSize(-1) |
| 123 , m_snapshotModificationTime(invalidFileTime()) | 110 , m_snapshotModificationTime(invalidFileTime()) |
| 124 { | 111 { |
| 125 ScriptWrappable::init(this); | 112 ScriptWrappable::init(this); |
| 126 } | 113 } |
| 127 | 114 |
| 115 File::File(const String& path, PassRefPtr<BlobDataHandle> blobDataHandle) |
| 116 : Blob(blobDataHandle) |
| 117 , m_path(path) |
| 118 , m_name(WebKit::Platform::current()->fileUtilities()->baseName(path)) |
| 119 , m_snapshotSize(-1) |
| 120 , m_snapshotModificationTime(invalidFileTime()) |
| 121 { |
| 122 ScriptWrappable::init(this); |
| 123 // FIXME: File object serialization/deserialization does not include |
| 124 // newer file object data members: m_name and m_relativePath. |
| 125 // See SerializedScriptValue.cpp. |
| 126 } |
| 127 |
| 128 File::File(const String& name, const FileMetadata& metadata) | 128 File::File(const String& name, const FileMetadata& metadata) |
| 129 : Blob(createBlobDataForFileWithMetadata(name, metadata), metadata.length) | 129 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada
ta), metadata.length)) |
| 130 , m_path(metadata.platformPath) | 130 , m_path(metadata.platformPath) |
| 131 , m_name(name) | 131 , m_name(name) |
| 132 , m_snapshotSize(metadata.length) | 132 , m_snapshotSize(metadata.length) |
| 133 , m_snapshotModificationTime(metadata.modificationTime) | 133 , m_snapshotModificationTime(metadata.modificationTime) |
| 134 { | 134 { |
| 135 ScriptWrappable::init(this); | 135 ScriptWrappable::init(this); |
| 136 } | 136 } |
| 137 | 137 |
| 138 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) | 138 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) |
| 139 : Blob(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.len
gth) | 139 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL,
metadata), metadata.length)) |
| 140 , m_fileSystemURL(fileSystemURL) | 140 , m_fileSystemURL(fileSystemURL) |
| 141 , m_snapshotSize(metadata.length) | 141 , m_snapshotSize(metadata.length) |
| 142 , m_snapshotModificationTime(metadata.modificationTime) | 142 , m_snapshotModificationTime(metadata.modificationTime) |
| 143 { | 143 { |
| 144 ScriptWrappable::init(this); | 144 ScriptWrappable::init(this); |
| 145 } | 145 } |
| 146 | 146 |
| 147 double File::lastModifiedDate() const | 147 double File::lastModifiedDate() const |
| 148 { | 148 { |
| 149 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime
)) | 149 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime
)) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 snapshotSize = 0; | 184 snapshotSize = 0; |
| 185 snapshotModificationTime = invalidFileTime(); | 185 snapshotModificationTime = invalidFileTime(); |
| 186 return; | 186 return; |
| 187 } | 187 } |
| 188 | 188 |
| 189 snapshotSize = metadata.length; | 189 snapshotSize = metadata.length; |
| 190 snapshotModificationTime = metadata.modificationTime; | 190 snapshotModificationTime = metadata.modificationTime; |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace WebCore | 193 } // namespace WebCore |
| OLD | NEW |