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

Side by Side Diff: base/file_util_win.cc

Issue 2153002: file_util: Convert the wstring version of IsDirectoryEmpty to FilePath. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: fix nit Created 10 years, 7 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
« no previous file with comments | « base/file_util_unittest.cc ('k') | chrome/installer/setup/uninstall.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <propvarutil.h> 8 #include <propvarutil.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) { 424 bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) {
425 // "Unpin from taskbar" is only supported after Win7. 425 // "Unpin from taskbar" is only supported after Win7.
426 if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) 426 if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7)
427 return false; 427 return false;
428 428
429 int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarunpin", 429 int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarunpin",
430 shortcut, NULL, NULL, 0)); 430 shortcut, NULL, NULL, 0));
431 return result > 32; 431 return result > 32;
432 } 432 }
433 433
434 bool IsDirectoryEmpty(const std::wstring& dir_path) {
435 FileEnumerator files(FilePath(dir_path), false,
436 static_cast<FileEnumerator::FILE_TYPE>(
437 FileEnumerator::FILES | FileEnumerator::DIRECTORIES));
438 if (files.Next().value().empty())
439 return true;
440 return false;
441 }
442
443 bool GetTempDir(FilePath* path) { 434 bool GetTempDir(FilePath* path) {
444 wchar_t temp_path[MAX_PATH + 1]; 435 wchar_t temp_path[MAX_PATH + 1];
445 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); 436 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
446 if (path_len >= MAX_PATH || path_len <= 0) 437 if (path_len >= MAX_PATH || path_len <= 0)
447 return false; 438 return false;
448 // TODO(evanm): the old behavior of this function was to always strip the 439 // TODO(evanm): the old behavior of this function was to always strip the
449 // trailing slash. We duplicate this here, but it shouldn't be necessary 440 // trailing slash. We duplicate this here, but it shouldn't be necessary
450 // when everyone is using the appropriate FilePath APIs. 441 // when everyone is using the appropriate FilePath APIs.
451 *path = FilePath(temp_path).StripTrailingSeparators(); 442 *path = FilePath(temp_path).StripTrailingSeparators();
452 return true; 443 return true;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 890 }
900 891
901 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, 892 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
902 const base::Time& cutoff_time) { 893 const base::Time& cutoff_time) {
903 long result = CompareFileTime(&find_info.ftLastWriteTime, 894 long result = CompareFileTime(&find_info.ftLastWriteTime,
904 &cutoff_time.ToFileTime()); 895 &cutoff_time.ToFileTime());
905 return result == 1 || result == 0; 896 return result == 1 || result == 0;
906 } 897 }
907 898
908 } // namespace file_util 899 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | chrome/installer/setup/uninstall.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698