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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 static PassRefPtr<File> create(const String& path, ContentTypeLookupPolicy p
olicy = WellKnownContentTypes) | 47 static PassRefPtr<File> create(const String& path, ContentTypeLookupPolicy p
olicy = WellKnownContentTypes) |
48 { | 48 { |
49 return adoptRef(new File(path, policy)); | 49 return adoptRef(new File(path, policy)); |
50 } | 50 } |
51 | 51 |
52 // For deserialization. | 52 // For deserialization. |
53 static PassRefPtr<File> create(const String& path, const KURL& srcURL, const
String& type) | 53 static PassRefPtr<File> create(const String& path, const KURL& srcURL, const
String& type) |
54 { | 54 { |
55 return adoptRef(new File(path, srcURL, type)); | 55 return adoptRef(new File(path, srcURL, type)); |
56 } | 56 } |
| 57 static PassRefPtr<File> create(const String& path, const String& name, const
KURL& srcURL, const String& type, double lastModified, long long size) |
| 58 { |
| 59 return adoptRef(new File(path, name, srcURL, type, lastModified, size)); |
| 60 } |
57 | 61 |
58 static PassRefPtr<File> createWithRelativePath(const String& path, const Str
ing& relativePath); | 62 static PassRefPtr<File> createWithRelativePath(const String& path, const Str
ing& relativePath); |
59 | 63 |
60 // If filesystem files live in the remote filesystem, the port might pass th
e valid metadata (whose length field is non-negative) and cache in the File obje
ct. | 64 // If filesystem files live in the remote filesystem, the port might pass th
e valid metadata (whose length field is non-negative) and cache in the File obje
ct. |
61 // | 65 // |
62 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous
ly query the file metadata. | 66 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous
ly query the file metadata. |
63 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi
leMetadata& metadata) | 67 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi
leMetadata& metadata) |
64 { | 68 { |
65 return adoptRef(new File(name, metadata)); | 69 return adoptRef(new File(name, metadata)); |
66 } | 70 } |
(...skipping 12 matching lines...) Expand all Loading... |
79 return adoptRef(new File(path, policy)); | 83 return adoptRef(new File(path, policy)); |
80 return adoptRef(new File(path, name, policy)); | 84 return adoptRef(new File(path, name, policy)); |
81 } | 85 } |
82 | 86 |
83 virtual unsigned long long size() const; | 87 virtual unsigned long long size() const; |
84 virtual bool isFile() const { return true; } | 88 virtual bool isFile() const { return true; } |
85 | 89 |
86 const String& path() const { return m_path; } | 90 const String& path() const { return m_path; } |
87 const String& name() const { return m_name; } | 91 const String& name() const { return m_name; } |
88 | 92 |
89 // This returns the current date and time if the file's last modifiecation d
ate is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate). | 93 // This returns the current date and time if the file's last modification da
te is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate). |
90 double lastModifiedDate() const; | 94 double lastModifiedDate() const; |
91 | 95 |
92 // Returns the relative path of this file in the context of a directory sele
ction. | 96 // Returns the relative path of this file in the context of a directory sele
ction. |
93 const String& webkitRelativePath() const { return m_relativePath; } | 97 const String& webkitRelativePath() const { return m_relativePath; } |
94 | 98 |
95 // Note that this involves synchronous file operation. Think twice before ca
lling this function. | 99 // Note that this involves synchronous file operation. Think twice before ca
lling this function. |
96 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi
me) const; | 100 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi
me) const; |
97 | 101 |
98 private: | 102 private: |
99 File(const String& path, ContentTypeLookupPolicy); | 103 File(const String& path, ContentTypeLookupPolicy); |
100 | 104 |
101 // For deserialization. | 105 // For deserialization. |
102 File(const String& path, const KURL& srcURL, const String& type); | 106 File(const String& path, const KURL& srcURL, const String& type); |
| 107 File(const String& path, const String& name, const KURL&, const String& type
, double lastModified, long long size); |
103 File(const String& path, const String& name, ContentTypeLookupPolicy); | 108 File(const String& path, const String& name, ContentTypeLookupPolicy); |
104 File(const String& name, const FileMetadata&); | 109 File(const String& name, const FileMetadata&); |
105 File(const KURL& fileSystemURL, const FileMetadata&); | 110 File(const KURL& fileSystemURL, const FileMetadata&); |
106 | 111 |
107 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >
= 0). | 112 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >
= 0). |
108 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } | 113 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } |
109 | 114 |
110 String m_path; | 115 String m_path; |
111 String m_name; | 116 String m_name; |
112 | 117 |
(...skipping 15 matching lines...) Expand all Loading... |
128 | 133 |
129 inline const File* toFile(const Blob* blob) | 134 inline const File* toFile(const Blob* blob) |
130 { | 135 { |
131 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); | 136 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); |
132 return static_cast<const File*>(blob); | 137 return static_cast<const File*>(blob); |
133 } | 138 } |
134 | 139 |
135 } // namespace WebCore | 140 } // namespace WebCore |
136 | 141 |
137 #endif // File_h | 142 #endif // File_h |
OLD | NEW |