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 15 matching lines...) Expand all Loading... |
26 #include "config.h" | 26 #include "config.h" |
27 #include "File.h" | 27 #include "File.h" |
28 | 28 |
29 #include "FileSystem.h" | 29 #include "FileSystem.h" |
30 #include "MIMETypeRegistry.h" | 30 #include "MIMETypeRegistry.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 File::File(const String& path) | 34 File::File(const String& path) |
35 : Blob(path) | 35 : Blob(path) |
36 , m_name(pathGetFileName(path)) | |
37 { | 36 { |
38 // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "a
pplication/octet-stream" upon failure. | 37 // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "a
pplication/octet-stream" upon failure. |
39 int index = m_name.reverseFind('.'); | 38 const String& fileName = name(); |
| 39 int index = fileName.reverseFind('.'); |
40 if (index != -1) | 40 if (index != -1) |
41 m_type = MIMETypeRegistry::getMIMETypeForExtension(m_name.substring(inde
x + 1)); | 41 m_type = MIMETypeRegistry::getMIMETypeForExtension(fileName.substring(in
dex + 1)); |
| 42 } |
| 43 |
| 44 const String& File::name() const |
| 45 { |
| 46 return items().at(0)->toFileBlobItem()->name(); |
42 } | 47 } |
43 | 48 |
44 } // namespace WebCore | 49 } // namespace WebCore |
OLD | NEW |