This source file includes following definitions.
- MoveCache
- DeleteCacheFile
#include "net/disk_cache/cache_util.h"
#include <windows.h>
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/win/scoped_handle.h"
namespace disk_cache {
bool MoveCache(const base::FilePath& from_path, const base::FilePath& to_path) {
if (!MoveFileEx(from_path.value().c_str(), to_path.value().c_str(), 0)) {
LOG(ERROR) << "Unable to move the cache: " << GetLastError();
return false;
}
return true;
}
bool DeleteCacheFile(const base::FilePath& name) {
if (!DeleteFile(name.value().c_str())) {
DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
DWORD access = SYNCHRONIZE;
base::win::ScopedHandle file(CreateFile(
name.value().c_str(), access, sharing, NULL, OPEN_EXISTING, 0, NULL));
if (file.IsValid())
return false;
}
return true;
}
}