#ifndef File_h
#define File_h
#include "Blob.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class URL;
class File final : public Blob {
public:
static PassRefPtr<File> create(const String& path)
{
return adoptRef(new File(path));
}
static PassRefPtr<File> deserialize(const String& path, const URL& srcURL, const String& type, const String& name)
{
return adoptRef(new File(deserializationContructor, path, srcURL, type, name));
}
static PassRefPtr<File> createWithName(const String& path, const String& nameOverride)
{
if (nameOverride.isEmpty())
return adoptRef(new File(path));
return adoptRef(new File(path, nameOverride));
}
virtual bool isFile() const override { return true; }
const String& path() const { return m_path; }
const String& name() const { return m_name; }
double lastModifiedDate() const;
static String contentTypeForFile(const String& path);
#if ENABLE(FILE_REPLACEMENT)
static bool shouldReplaceFile(const String& path);
#endif
private:
explicit File(const String& path);
File(const String& path, const String& nameOverride);
File(DeserializationContructor, const String& path, const URL& srcURL, const String& type, const String& name);
static void computeNameAndContentType(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType);
#if ENABLE(FILE_REPLACEMENT)
static void computeNameAndContentTypeForReplacedFile(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType);
#endif
String m_path;
String m_name;
};
inline File* toFile(Blob* blob)
{
ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile());
return static_cast<File*>(blob);
}
inline const File* toFile(const Blob* blob)
{
ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile());
return static_cast<const File*>(blob);
}
}
#endif // File_h