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

Side by Side Diff: base/file_util_win.cc

Issue 2081007: Enable warning 4389 as an error on windows builds. This will make... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « base/event_trace_provider_win_unittest.cc ('k') | base/iat_patch.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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 ScopedHandle file(CreateFile(filename.value().c_str(), 649 ScopedHandle file(CreateFile(filename.value().c_str(),
650 GENERIC_READ, 650 GENERIC_READ,
651 FILE_SHARE_READ | FILE_SHARE_WRITE, 651 FILE_SHARE_READ | FILE_SHARE_WRITE,
652 NULL, 652 NULL,
653 OPEN_EXISTING, 653 OPEN_EXISTING,
654 FILE_FLAG_SEQUENTIAL_SCAN, 654 FILE_FLAG_SEQUENTIAL_SCAN,
655 NULL)); 655 NULL));
656 if (file == INVALID_HANDLE_VALUE) 656 if (file == INVALID_HANDLE_VALUE)
657 return -1; 657 return -1;
658 658
659 int ret_value;
660 DWORD read; 659 DWORD read;
661 if (::ReadFile(file, data, size, &read, NULL) && read == size) { 660 if (::ReadFile(file, data, size, &read, NULL) &&
662 ret_value = static_cast<int>(read); 661 static_cast<int>(read) == size)
663 } else { 662 return read;
664 ret_value = -1; 663 return -1;
665 }
666
667 return ret_value;
668 } 664 }
669 665
670 int WriteFile(const FilePath& filename, const char* data, int size) { 666 int WriteFile(const FilePath& filename, const char* data, int size) {
671 ScopedHandle file(CreateFile(filename.value().c_str(), 667 ScopedHandle file(CreateFile(filename.value().c_str(),
672 GENERIC_WRITE, 668 GENERIC_WRITE,
673 0, 669 0,
674 NULL, 670 NULL,
675 CREATE_ALWAYS, 671 CREATE_ALWAYS,
676 0, 672 0,
677 NULL)); 673 NULL));
678 if (file == INVALID_HANDLE_VALUE) { 674 if (file == INVALID_HANDLE_VALUE) {
679 LOG(WARNING) << "CreateFile failed for path " << filename.value() << 675 LOG(WARNING) << "CreateFile failed for path " << filename.value() <<
680 " error code=" << GetLastError() << 676 " error code=" << GetLastError() <<
681 " error text=" << win_util::FormatLastWin32Error(); 677 " error text=" << win_util::FormatLastWin32Error();
682 return -1; 678 return -1;
683 } 679 }
684 680
685 DWORD written; 681 DWORD written;
686 BOOL result = ::WriteFile(file, data, size, &written, NULL); 682 BOOL result = ::WriteFile(file, data, size, &written, NULL);
687 if (result && written == size) 683 if (result && static_cast<int>(written) == size)
688 return static_cast<int>(written); 684 return written;
689 685
690 if (!result) { 686 if (!result) {
691 // WriteFile failed. 687 // WriteFile failed.
692 LOG(WARNING) << "writing file " << filename.value() << 688 LOG(WARNING) << "writing file " << filename.value() <<
693 " failed, error code=" << GetLastError() << 689 " failed, error code=" << GetLastError() <<
694 " description=" << win_util::FormatLastWin32Error(); 690 " description=" << win_util::FormatLastWin32Error();
695 } else { 691 } else {
696 // Didn't write all the bytes. 692 // Didn't write all the bytes.
697 LOG(WARNING) << "wrote" << written << " bytes to " << 693 LOG(WARNING) << "wrote" << written << " bytes to " <<
698 filename.value() << " expected " << size; 694 filename.value() << " expected " << size;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 895 }
900 896
901 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, 897 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
902 const base::Time& cutoff_time) { 898 const base::Time& cutoff_time) {
903 long result = CompareFileTime(&find_info.ftLastWriteTime, 899 long result = CompareFileTime(&find_info.ftLastWriteTime,
904 &cutoff_time.ToFileTime()); 900 &cutoff_time.ToFileTime());
905 return result == 1 || result == 0; 901 return result == 1 || result == 0;
906 } 902 }
907 903
908 } // namespace file_util 904 } // namespace file_util
OLDNEW
« no previous file with comments | « base/event_trace_provider_win_unittest.cc ('k') | base/iat_patch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698