OLD | NEW |
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 <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/scoped_handle.h" | 10 #include "base/scoped_handle.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 std::wstring current(adjusted_path); | 31 std::wstring current(adjusted_path); |
32 current += data.cFileName; | 32 current += data.cFileName; |
33 DeleteFile(current.c_str()); | 33 DeleteFile(current.c_str()); |
34 } while (FindNextFile(handle, &data)); | 34 } while (FindNextFile(handle, &data)); |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 namespace disk_cache { | 39 namespace disk_cache { |
40 | 40 |
41 int64 GetFreeDiskSpace(const std::wstring& path) { | |
42 ULARGE_INTEGER available, total, free; | |
43 if (!GetDiskFreeSpaceExW(path.c_str(), &available, &total, &free)) { | |
44 return -1; | |
45 } | |
46 int64 rv = static_cast<int64>(available.QuadPart); | |
47 if (rv < 0) | |
48 rv = kint64max; | |
49 return rv; | |
50 } | |
51 | |
52 bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { | 41 bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) { |
53 // I don't want to use the shell version of move because if something goes | 42 // I don't want to use the shell version of move because if something goes |
54 // wrong, that version will attempt to move file by file and fail at the end. | 43 // wrong, that version will attempt to move file by file and fail at the end. |
55 if (!MoveFileEx(from_path.c_str(), to_path.c_str(), 0)) { | 44 if (!MoveFileEx(from_path.c_str(), to_path.c_str(), 0)) { |
56 LOG(ERROR) << "Unable to move the cache: " << GetLastError(); | 45 LOG(ERROR) << "Unable to move the cache: " << GetLastError(); |
57 return false; | 46 return false; |
58 } | 47 } |
59 return true; | 48 return true; |
60 } | 49 } |
61 | 50 |
(...skipping 16 matching lines...) Expand all Loading... |
78 // The idea is to let other threads do usefull work and at the same time | 67 // The idea is to let other threads do usefull work and at the same time |
79 // allow more than one IO to finish... 20 mS later, we process all queued | 68 // allow more than one IO to finish... 20 mS later, we process all queued |
80 // APCs and see if we have to repeat the wait. | 69 // APCs and see if we have to repeat the wait. |
81 Sleep(20); | 70 Sleep(20); |
82 SleepEx(0, TRUE); | 71 SleepEx(0, TRUE); |
83 } | 72 } |
84 } | 73 } |
85 | 74 |
86 } // namespace disk_cache | 75 } // namespace disk_cache |
87 | 76 |
OLD | NEW |