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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool normalizeLineEndingsToNative = options.endings() == "native"; | 105 bool normalizeLineEndingsToNative = options.endings() == "native"; |
106 | 106 |
107 OwnPtr<BlobData> blobData = BlobData::create(); | 107 OwnPtr<BlobData> blobData = BlobData::create(); |
108 blobData->setContentType(options.type().lower()); | 108 blobData->setContentType(options.type().lower()); |
109 populateBlobData(blobData.get(), fileBits, normalizeLineEndingsToNative); | 109 populateBlobData(blobData.get(), fileBits, normalizeLineEndingsToNative); |
110 | 110 |
111 long long fileSize = blobData->length(); | 111 long long fileSize = blobData->length(); |
112 return File::create(fileName, lastModified, BlobDataHandle::create(blobData.
release(), fileSize)); | 112 return File::create(fileName, lastModified, BlobDataHandle::create(blobData.
release(), fileSize)); |
113 } | 113 } |
114 | 114 |
115 File* File::create(const unsigned char* data, size_t bytes, const String& mimeTy
pe) | |
116 { | |
117 ASSERT(data); | |
118 | |
119 OwnPtr<BlobData> blobData = BlobData::create(); | |
120 blobData->setContentType(mimeType); | |
121 blobData->appendBytes(data, bytes); | |
122 long long blobSize = blobData->length(); | |
123 | |
124 // create blob as the type of file with two additional attributes -- name an
d lastModificationTime | |
125 return File::create("", currentTimeMS(), BlobDataHandle::create(blobData.rel
ease(), blobSize)); | |
126 } | |
127 | |
128 File* File::createWithRelativePath(const String& path, const String& relativePat
h) | 115 File* File::createWithRelativePath(const String& path, const String& relativePat
h) |
129 { | 116 { |
130 File* file = new File(path, File::AllContentTypes, File::IsUserVisible); | 117 File* file = new File(path, File::AllContentTypes, File::IsUserVisible); |
131 file->m_relativePath = relativePath; | 118 file->m_relativePath = relativePath; |
132 return file; | 119 return file; |
133 } | 120 } |
134 | 121 |
135 File::File(const String& path, ContentTypeLookupPolicy policy, UserVisibility us
erVisibility) | 122 File::File(const String& path, ContentTypeLookupPolicy policy, UserVisibility us
erVisibility) |
136 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) | 123 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) |
137 , m_hasBackingFile(true) | 124 , m_hasBackingFile(true) |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) | 354 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) |
368 return false; | 355 return false; |
369 | 356 |
370 if (!m_fileSystemURL.isEmpty()) | 357 if (!m_fileSystemURL.isEmpty()) |
371 return m_fileSystemURL == other.m_fileSystemURL; | 358 return m_fileSystemURL == other.m_fileSystemURL; |
372 | 359 |
373 return uuid() == other.uuid(); | 360 return uuid() == other.uuid(); |
374 } | 361 } |
375 | 362 |
376 } // namespace blink | 363 } // namespace blink |
OLD | NEW |