| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <fstream> | 9 #include <fstream> |
| 10 | 10 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 *path_str = path.ToWStringHack(); | 374 *path_str = path.ToWStringHack(); |
| 375 return true; | 375 return true; |
| 376 } | 376 } |
| 377 bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { | 377 bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { |
| 378 return GetFileInfo(FilePath::FromWStringHack(file_path), results); | 378 return GetFileInfo(FilePath::FromWStringHack(file_path), results); |
| 379 } | 379 } |
| 380 std::wstring GetFilenameFromPath(const std::wstring& path) { | 380 std::wstring GetFilenameFromPath(const std::wstring& path) { |
| 381 if (path.empty() || EndsWithSeparator(path)) | 381 if (path.empty() || EndsWithSeparator(path)) |
| 382 return std::wstring(); | 382 return std::wstring(); |
| 383 | 383 |
| 384 #if defined(OS_WIN) | 384 return FilePath::FromWStringHack(path).BaseName().ToWStringHack(); |
| 385 return FilePath::FromWStringHack(path).BaseName(); | |
| 386 #elif defined(OS_POSIX) | |
| 387 return UTF8ToWide(FilePath::FromWStringHack(path).BaseName()); | |
| 388 #endif | |
| 389 } | 385 } |
| 390 bool GetFileSize(const std::wstring& file_path, int64* file_size) { | 386 bool GetFileSize(const std::wstring& file_path, int64* file_size) { |
| 391 return GetFileSize(FilePath::FromWStringHack(file_path), file_size); | 387 return GetFileSize(FilePath::FromWStringHack(file_path), file_size); |
| 392 } | 388 } |
| 393 bool GetTempDir(std::wstring* path_str) { | 389 bool GetTempDir(std::wstring* path_str) { |
| 394 FilePath path; | 390 FilePath path; |
| 395 if (!GetTempDir(&path)) | 391 if (!GetTempDir(&path)) |
| 396 return false; | 392 return false; |
| 397 *path_str = path.ToWStringHack(); | 393 *path_str = path.ToWStringHack(); |
| 398 return true; | 394 return true; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 FilePath directory = path.DirName(); | 429 FilePath directory = path.DirName(); |
| 434 // If there is no separator, we will get back kCurrentDirectory. | 430 // If there is no separator, we will get back kCurrentDirectory. |
| 435 // In this case, clear dir. | 431 // In this case, clear dir. |
| 436 if (directory == path || directory.value() == FilePath::kCurrentDirectory) | 432 if (directory == path || directory.value() == FilePath::kCurrentDirectory) |
| 437 dir->clear(); | 433 dir->clear(); |
| 438 else | 434 else |
| 439 *dir = directory.ToWStringHack(); | 435 *dir = directory.ToWStringHack(); |
| 440 } | 436 } |
| 441 } // namespace | 437 } // namespace |
| 442 | 438 |
| OLD | NEW |