SQLiteFileSystem.cpp [plain text]
#define __STDC_FORMAT_MACROS
#include "config.h"
#include "SQLiteFileSystem.h"
#include "FileSystem.h"
#include "SQLiteDatabase.h"
#include "SQLiteStatement.h"
#include <inttypes.h>
#include <sqlite3.h>
#if PLATFORM(IOS)
#include <sqlite3_private.h>
#endif
namespace WebCore {
SQLiteFileSystem::SQLiteFileSystem()
{
}
int SQLiteFileSystem::openDatabase(const String& filename, sqlite3** database, bool)
{
return sqlite3_open(fileSystemRepresentation(filename).data(), database);
}
String SQLiteFileSystem::appendDatabaseFileNameToPath(const String& path, const String& fileName)
{
return pathByAppendingComponent(path, fileName);
}
bool SQLiteFileSystem::ensureDatabaseDirectoryExists(const String& path)
{
if (path.isEmpty())
return false;
return makeAllDirectories(path);
}
bool SQLiteFileSystem::ensureDatabaseFileExists(const String& fileName, bool checkPathOnly)
{
if (fileName.isEmpty())
return false;
if (checkPathOnly) {
String dir = directoryName(fileName);
return ensureDatabaseDirectoryExists(dir);
}
return fileExists(fileName);
}
bool SQLiteFileSystem::deleteEmptyDatabaseDirectory(const String& path)
{
return deleteEmptyDirectory(path);
}
bool SQLiteFileSystem::deleteDatabaseFile(const String& fileName)
{
return deleteFile(fileName);
}
#if PLATFORM(IOS)
bool SQLiteFileSystem::truncateDatabaseFile(sqlite3* database)
{
return sqlite3_file_control(database, 0, SQLITE_TRUNCATE_DATABASE, 0) == SQLITE_OK;
}
#endif
long long SQLiteFileSystem::getDatabaseFileSize(const String& fileName)
{
long long size;
return getFileSize(fileName, size) ? size : 0;
}
double SQLiteFileSystem::databaseCreationTime(const String& fileName)
{
time_t time;
return getFileCreationTime(fileName, time) ? time : 0;
}
double SQLiteFileSystem::databaseModificationTime(const String& fileName)
{
time_t time;
return getFileModificationTime(fileName, time) ? time : 0;
}
}