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

Side by Side Diff: tools/gn/filesystem_utils.cc

Issue 1817533002: Make rebase_path() aware of Windows drive letter capitalization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | tools/gn/filesystem_utils_unittest.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "tools/gn/filesystem_utils.h" 5 #include "tools/gn/filesystem_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (IsPathAbsolute(input) && !IsSlash(input[0]) && IsSlash(dest[0])) { 522 if (IsPathAbsolute(input) && !IsSlash(input[0]) && IsSlash(dest[0])) {
523 std::string corrected_input(1, dest[0]); 523 std::string corrected_input(1, dest[0]);
524 corrected_input.append(input); 524 corrected_input.append(input);
525 return MakeRelativePath(corrected_input, dest); 525 return MakeRelativePath(corrected_input, dest);
526 } 526 }
527 if (IsPathAbsolute(dest) && !IsSlash(dest[0]) && IsSlash(input[0])) { 527 if (IsPathAbsolute(dest) && !IsSlash(dest[0]) && IsSlash(input[0])) {
528 std::string corrected_dest(1, input[0]); 528 std::string corrected_dest(1, input[0]);
529 corrected_dest.append(dest); 529 corrected_dest.append(dest);
530 return MakeRelativePath(input, corrected_dest); 530 return MakeRelativePath(input, corrected_dest);
531 } 531 }
532
533 // Make sure that both absolute paths use the same drive letter case.
534 if (IsPathAbsolute(input) && IsPathAbsolute(dest) && input.size() > 1 &&
535 dest.size() > 1) {
536 int letter_pos = base::IsAsciiAlpha(input[0]) ? 0 : 1;
537 if (input[letter_pos] != dest[letter_pos] &&
538 base::ToUpperASCII(input[letter_pos]) ==
539 base::ToUpperASCII(dest[letter_pos])) {
540 std::string corrected_input = input;
541 corrected_input[letter_pos] = dest[letter_pos];
542 return MakeRelativePath(corrected_input, dest);
543 }
544 }
532 #endif 545 #endif
533 546
534 std::string ret; 547 std::string ret;
535 548
536 // Skip the common prefixes of the source and dest as long as they end in 549 // Skip the common prefixes of the source and dest as long as they end in
537 // a [back]slash. 550 // a [back]slash.
538 size_t common_prefix_len = 0; 551 size_t common_prefix_len = 0;
539 size_t max_common_length = std::min(input.size(), dest.size()); 552 size_t max_common_length = std::min(input.size(), dest.size());
540 for (size_t i = common_prefix_len; i < max_common_length; i++) { 553 for (size_t i = common_prefix_len; i < max_common_length; i++) {
541 if (IsSlash(input[i]) && IsSlash(dest[i])) 554 if (IsSlash(input[i]) && IsSlash(dest[i]))
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 928
916 SourceDir GetCurrentOutputDir(const Scope* scope) { 929 SourceDir GetCurrentOutputDir(const Scope* scope) {
917 return GetOutputDirForSourceDirAsOutputFile( 930 return GetOutputDirForSourceDirAsOutputFile(
918 scope->settings(), scope->GetSourceDir()).AsSourceDir( 931 scope->settings(), scope->GetSourceDir()).AsSourceDir(
919 scope->settings()->build_settings()); 932 scope->settings()->build_settings());
920 } 933 }
921 934
922 SourceDir GetCurrentGenDir(const Scope* scope) { 935 SourceDir GetCurrentGenDir(const Scope* scope) {
923 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); 936 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir());
924 } 937 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/filesystem_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698