| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/fileapi/file_system_file_util_base.h" |
| 6 #include "webkit/fileapi/file_system_operation_context.h" |
| 7 |
| 8 #include "base/file_util.h" |
| 9 |
| 10 namespace fileapi { |
| 11 |
| 12 // static |
| 13 QuotaFileUtil* QuotaFileUtil::GetInstance() { |
| 14 QuotaFileUtil* self = Singleton<QuotaFileUtil>::get(); |
| 15 self->next_file_util_to_quota = FileSystemFileUtilBase::GetInstance(); |
| 16 return self; |
| 17 } |
| 18 |
| 19 base::PlatformFileError QuotaFileUtil::Copy( |
| 20 const FileSystemOperationContext& fs_context, |
| 21 const FilePath& src_file_path, |
| 22 const FilePath& dest_file_path) { |
| 23 int allowed_growth = fs_context.GetAllowedGrowth(); |
| 24 |
| 25 if (allowed_growth < SIZE_MAX) { |
| 26 const char* path_str = src_file_path.value().c_str(); |
| 27 stat_wrapper_t file_info; |
| 28 int test = CallStat(path_str, &file_info); |
| 29 if (test != 0) |
| 30 return base::PLATFORM_FILE_ERROR_FAILED; |
| 31 if (file_info.st_size > allowed_growth) |
| 32 return base::PLATFORM_FILE_ERROR_NO_SPACE; |
| 33 } |
| 34 |
| 35 return next_file_util_to_quota->Copy( |
| 36 fs_context, src_file_path, dest_file_path); |
| 37 } |
| 38 |
| 39 } // namespace fileapi |
| OLD | NEW |