Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: net/disk_cache/cache_util_posix.cc

Issue 3141: Move GetFreeDiskSpace to SysInfo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/cache_util.h ('k') | net/disk_cache/cache_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/disk_cache/cache_util.h" 5 #include "net/disk_cache/cache_util.h"
6 6
7 #include <errno.h>
8 #include <sys/statvfs.h>
9 #include <unistd.h>
10
11 #include "base/file_util.h" 7 #include "base/file_util.h"
12 #include "base/logging.h" 8 #include "base/logging.h"
13 #include "base/string_util.h" 9 #include "base/string_util.h"
14 10
15 #if defined(OS_MACOSX)
16 #include <mach/mach_host.h>
17 #include <mach/mach_init.h>
18 #endif
19
20 namespace disk_cache { 11 namespace disk_cache {
21 12
22 int64 GetFreeDiskSpace(const std::wstring& path) {
23 struct statvfs stats;
24 if (statvfs(WideToUTF8(path).c_str(), &stats) != 0) {
25 return -1;
26 }
27 return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
28 }
29
30 bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { 13 bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) {
31 // Just use the version from base. 14 // Just use the version from base.
32 return file_util::Move(from_path.c_str(), to_path.c_str()); 15 return file_util::Move(from_path.c_str(), to_path.c_str());
33 } 16 }
34 17
35 void DeleteCache(const std::wstring& path, bool remove_folder) { 18 void DeleteCache(const std::wstring& path, bool remove_folder) {
36 if (remove_folder) { 19 if (remove_folder) {
37 file_util::Delete(path, false); 20 file_util::Delete(path, false);
38 } else { 21 } else {
39 std::wstring name(path); 22 std::wstring name(path);
40 // TODO(rvargas): Fix this after file_util::delete is fixed. 23 // TODO(rvargas): Fix this after file_util::delete is fixed.
41 // file_util::AppendToPath(&name, L"*"); 24 // file_util::AppendToPath(&name, L"*");
42 file_util::Delete(name, true); 25 file_util::Delete(name, true);
43 } 26 }
44 } 27 }
45 28
46 bool DeleteCacheFile(const std::wstring& name) { 29 bool DeleteCacheFile(const std::wstring& name) {
47 return file_util::Delete(name, false); 30 return file_util::Delete(name, false);
48 } 31 }
49 32
50 void WaitForPendingIO(int* num_pending_io) { 33 void WaitForPendingIO(int* num_pending_io) {
51 if (*num_pending_io) { 34 if (*num_pending_io) {
52 NOTIMPLEMENTED(); 35 NOTIMPLEMENTED();
53 } 36 }
54 } 37 }
55 38
56 } // namespace disk_cache 39 } // namespace disk_cache
57 40
OLDNEW
« no previous file with comments | « net/disk_cache/cache_util.h ('k') | net/disk_cache/cache_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698