DOMFileSystemBlackBerry.cpp [plain text]
#include "config.h"
#if ENABLE(FILE_SYSTEM)
#include "DOMFileSystem.h"
#include "DOMFilePath.h"
#include "ScriptExecutionContext.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const
{
ASSERT(DOMFilePath::isAbsolute(fullPath));
ASSERT(!m_filesystemRootURL.isEmpty());
return m_context->completeURL(m_filesystemRootURL.string() + encodeWithURLEscapeSequences(fullPath));
}
bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, FileSystemType& type, String& filePath)
{
if (!url.protocolIs("filesystem"))
return false;
if (url.innerURL()) {
String typeString = url.innerURL()->path().substring(1);
if (typeString == temporaryPathPrefix)
type = FileSystemTypeTemporary;
else if (typeString == persistentPathPrefix)
type = FileSystemTypePersistent;
else
return false;
filePath = decodeURLEscapeSequences(url.path());
} else {
KURL originURL(ParsedURLString, url.path());
String path = decodeURLEscapeSequences(originURL.path());
if (path.isEmpty() || path[0] != '/')
return false;
path = path.substring(1);
if (path.startsWith(temporaryPathPrefix)) {
type = FileSystemTypeTemporary;
path = path.substring(temporaryPathPrefixLength);
} else if (path.startsWith(persistentPathPrefix)) {
type = FileSystemTypePersistent;
path = path.substring(persistentPathPrefixLength);
} else
return false;
if (path.isEmpty() || path[0] != '/')
return false;
filePath.swap(path);
}
return true;
}
bool DOMFileSystemBase::supportsToURL() const
{
return true;
}
bool DOMFileSystemBase::isValidType(FileSystemType type)
{
return type == FileSystemTypeTemporary || type == FileSystemTypePersistent;
}
}
#endif // ENABLE(FILE_SYSTEM)