Chromium Code Reviews| Index: bin/dartutils.cc |
| =================================================================== |
| --- bin/dartutils.cc (revision 7254) |
| +++ bin/dartutils.cc (working copy) |
| @@ -232,31 +232,32 @@ |
| return strdup(filename); |
| } |
| - char* path = strdup(reference_dir); |
| - if (path == NULL) { |
| - return NULL; |
| + char* canonical_path = File::GetCanonicalPath(reference_dir); |
| + if (canonical_path == NULL) { |
| + canonical_path = strdup(reference_dir); |
| + ASSERT(canonical_path != NULL); |
| } |
| - char* path_sep = strrchr(path, File::PathSeparator()[0]); |
| + char* path_sep = strrchr(canonical_path, File::PathSeparator()[0]); |
|
cshapiro
2012/05/03 00:17:21
Since there is no equivalent of the STL string .rf
siva
2012/05/03 00:46:05
Done.
|
| if (path_sep == NULL) { |
| // No separator found: Reference is a file in local directory. |
| + free(canonical_path); |
| return strdup(filename); |
| } |
| *path_sep = '\0'; |
| intptr_t len = snprintf(NULL, 0, "%s%s%s", |
|
cshapiro
2012/05/03 00:17:21
As an aside, we really need an abstraction to do t
siva
2012/05/03 00:46:05
Agree, maybe we could add a method in utils.
On 2
|
| - path, File::PathSeparator(), filename); |
| + canonical_path, File::PathSeparator(), filename); |
| char* absolute_filename = reinterpret_cast<char*>(malloc(len + 1)); |
| ASSERT(absolute_filename != NULL); |
| snprintf(absolute_filename, len + 1, "%s%s%s", |
| - path, File::PathSeparator(), filename); |
| - |
| - free(path); |
| - char* canonical_filename = File::GetCanonicalPath(absolute_filename); |
| - if (canonical_filename == NULL) { |
| + canonical_path, File::PathSeparator(), filename); |
| + free(canonical_path); |
| + canonical_path = File::GetCanonicalPath(absolute_filename); |
| + if (canonical_path == NULL) { |
|
cshapiro
2012/05/03 00:17:21
horizontal whitespace
siva
2012/05/03 00:46:05
Removed.
On 2012/05/03 00:17:21, cshapiro wrote:
|
| return absolute_filename; |
| } |
| free(absolute_filename); |
| - return canonical_filename; |
| + return canonical_path; |
| } |