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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 enum ContentTypeLookupPolicy { | 42 enum ContentTypeLookupPolicy { |
43 WellKnownContentTypes, | 43 WellKnownContentTypes, |
44 AllContentTypes, | 44 AllContentTypes, |
45 }; | 45 }; |
46 | 46 |
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 static PassRefPtr<File> create(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> blobDataHandle) | |
53 { | |
54 return adoptRef(new File(name, modificationTime, blobDataHandle)); | |
55 } | |
56 | |
52 // For deserialization. | 57 // For deserialization. |
53 static PassRefPtr<File> create(const String& path, PassRefPtr<BlobDataHandle > blobDataHandle) | 58 static PassRefPtr<File> create(const String& path, PassRefPtr<BlobDataHandle > blobDataHandle) |
54 { | 59 { |
55 return adoptRef(new File(path, blobDataHandle)); | 60 return adoptRef(new File(path, blobDataHandle)); |
56 } | 61 } |
57 | 62 |
58 static PassRefPtr<File> createWithRelativePath(const String& path, const Str ing& relativePath); | 63 static PassRefPtr<File> createWithRelativePath(const String& path, const Str ing& relativePath); |
59 | 64 |
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. | 65 // 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 // | 66 // |
(...skipping 13 matching lines...) Expand all Loading... | |
75 // Create a file with a name exposed to the author (via File.name and associ ated DOM properties) that differs from the one provided in the path. | 80 // Create a file with a name exposed to the author (via File.name and associ ated DOM properties) that differs from the one provided in the path. |
76 static PassRefPtr<File> createWithName(const String& path, const String& nam e, ContentTypeLookupPolicy policy = WellKnownContentTypes) | 81 static PassRefPtr<File> createWithName(const String& path, const String& nam e, ContentTypeLookupPolicy policy = WellKnownContentTypes) |
77 { | 82 { |
78 if (name.isEmpty()) | 83 if (name.isEmpty()) |
79 return adoptRef(new File(path, policy)); | 84 return adoptRef(new File(path, policy)); |
80 return adoptRef(new File(path, name, policy)); | 85 return adoptRef(new File(path, name, policy)); |
81 } | 86 } |
82 | 87 |
83 virtual unsigned long long size() const; | 88 virtual unsigned long long size() const; |
84 virtual bool isFile() const { return true; } | 89 virtual bool isFile() const { return true; } |
90 virtual bool isOnFilesystem() const { return m_isOnFilesystem; } | |
kinuko
2013/11/05 11:20:29
nit: the term FileSystem is often used to note Fil
pwnall-personal
2013/11/05 11:44:35
I agree that the name isn't very good, and will ch
| |
85 | 91 |
86 const String& path() const { return m_path; } | 92 const String& path() const { return m_path; } |
87 const String& name() const { return m_name; } | 93 const String& name() const { return m_name; } |
88 | 94 |
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). | 95 // 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). |
90 double lastModifiedDate() const; | 96 double lastModifiedDate() const; |
91 | 97 |
92 // Returns the relative path of this file in the context of a directory sele ction. | 98 // Returns the relative path of this file in the context of a directory sele ction. |
93 const String& webkitRelativePath() const { return m_relativePath; } | 99 const String& webkitRelativePath() const { return m_relativePath; } |
94 | 100 |
95 // Note that this involves synchronous file operation. Think twice before ca lling this function. | 101 // Note that this involves synchronous file operation. Think twice before ca lling this function. |
96 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi me) const; | 102 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi me) const; |
97 | 103 |
98 private: | 104 private: |
99 File(const String& path, ContentTypeLookupPolicy); | 105 File(const String& path, ContentTypeLookupPolicy); |
100 File(const String& path, const String& name, ContentTypeLookupPolicy); | 106 File(const String& path, const String& name, ContentTypeLookupPolicy); |
101 File(const String& path, PassRefPtr<BlobDataHandle>); | 107 File(const String& path, PassRefPtr<BlobDataHandle>); |
108 File(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> ); | |
102 File(const String& name, const FileMetadata&); | 109 File(const String& name, const FileMetadata&); |
103 File(const KURL& fileSystemURL, const FileMetadata&); | 110 File(const KURL& fileSystemURL, const FileMetadata&); |
104 | 111 |
105 // 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). |
106 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } | 113 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } |
107 | 114 |
115 bool m_isOnFilesystem; | |
108 String m_path; | 116 String m_path; |
109 String m_name; | 117 String m_name; |
110 | 118 |
111 KURL m_fileSystemURL; | 119 KURL m_fileSystemURL; |
112 | 120 |
113 // If m_snapshotSize is negative (initialized to -1 by default), the snapsho t metadata is invalid and we retrieve the latest metadata synchronously in size( ), lastModifiedTime() and slice(). | 121 // If m_snapshotSize is negative (initialized to -1 by default), the snapsho t metadata is invalid and we retrieve the latest metadata synchronously in size( ), lastModifiedTime() and slice(). |
114 // Otherwise, the snapshot metadata are used directly in those methods. | 122 // Otherwise, the snapshot metadata are used directly in those methods. |
115 const long long m_snapshotSize; | 123 const long long m_snapshotSize; |
116 const double m_snapshotModificationTime; | 124 const double m_snapshotModificationTime; |
117 | 125 |
118 String m_relativePath; | 126 String m_relativePath; |
119 }; | 127 }; |
120 | 128 |
121 inline File* toFile(Blob* blob) | 129 inline File* toFile(Blob* blob) |
122 { | 130 { |
123 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); | 131 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); |
124 return static_cast<File*>(blob); | 132 return static_cast<File*>(blob); |
125 } | 133 } |
126 | 134 |
127 inline const File* toFile(const Blob* blob) | 135 inline const File* toFile(const Blob* blob) |
128 { | 136 { |
129 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); | 137 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); |
130 return static_cast<const File*>(blob); | 138 return static_cast<const File*>(blob); |
131 } | 139 } |
132 | 140 |
133 } // namespace WebCore | 141 } // namespace WebCore |
134 | 142 |
135 #endif // File_h | 143 #endif // File_h |
OLD | NEW |