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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <io.h> | 8 #include <io.h> |
9 #endif | 9 #endif |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 457 } |
458 FILE* OpenFile(const std::wstring& filename, const char* mode) { | 458 FILE* OpenFile(const std::wstring& filename, const char* mode) { |
459 return OpenFile(FilePath::FromWStringHack(filename), mode); | 459 return OpenFile(FilePath::FromWStringHack(filename), mode); |
460 } | 460 } |
461 bool PathExists(const std::wstring& path) { | 461 bool PathExists(const std::wstring& path) { |
462 return PathExists(FilePath::FromWStringHack(path)); | 462 return PathExists(FilePath::FromWStringHack(path)); |
463 } | 463 } |
464 bool PathIsWritable(const std::wstring& path) { | 464 bool PathIsWritable(const std::wstring& path) { |
465 return PathIsWritable(FilePath::FromWStringHack(path)); | 465 return PathIsWritable(FilePath::FromWStringHack(path)); |
466 } | 466 } |
| 467 int ReadFile(const std::wstring& filename, char* data, int size) { |
| 468 return ReadFile(FilePath::FromWStringHack(filename), data, size); |
| 469 } |
467 bool SetCurrentDirectory(const std::wstring& directory) { | 470 bool SetCurrentDirectory(const std::wstring& directory) { |
468 return SetCurrentDirectory(FilePath::FromWStringHack(directory)); | 471 return SetCurrentDirectory(FilePath::FromWStringHack(directory)); |
469 } | 472 } |
470 void TrimFilename(std::wstring* path) { | 473 void TrimFilename(std::wstring* path) { |
471 if (EndsWithSeparator(path)) { | 474 if (EndsWithSeparator(path)) { |
472 TrimTrailingSeparator(path); | 475 TrimTrailingSeparator(path); |
473 } else { | 476 } else { |
474 *path = FilePath::FromWStringHack(*path).DirName().ToWStringHack(); | 477 *path = FilePath::FromWStringHack(*path).DirName().ToWStringHack(); |
475 } | 478 } |
476 } | 479 } |
477 void UpOneDirectory(std::wstring* dir) { | 480 void UpOneDirectory(std::wstring* dir) { |
478 FilePath path = FilePath::FromWStringHack(*dir); | 481 FilePath path = FilePath::FromWStringHack(*dir); |
479 FilePath directory = path.DirName(); | 482 FilePath directory = path.DirName(); |
480 // If there is no separator, we will get back kCurrentDirectory. | 483 // If there is no separator, we will get back kCurrentDirectory. |
481 // In this case don't change |dir|. | 484 // In this case don't change |dir|. |
482 if (directory.value() != FilePath::kCurrentDirectory) | 485 if (directory.value() != FilePath::kCurrentDirectory) |
483 *dir = directory.ToWStringHack(); | 486 *dir = directory.ToWStringHack(); |
484 } | 487 } |
485 void UpOneDirectoryOrEmpty(std::wstring* dir) { | 488 void UpOneDirectoryOrEmpty(std::wstring* dir) { |
486 FilePath path = FilePath::FromWStringHack(*dir); | 489 FilePath path = FilePath::FromWStringHack(*dir); |
487 FilePath directory = path.DirName(); | 490 FilePath directory = path.DirName(); |
488 // If there is no separator, we will get back kCurrentDirectory. | 491 // If there is no separator, we will get back kCurrentDirectory. |
489 // In this case, clear dir. | 492 // In this case, clear dir. |
490 if (directory == path || directory.value() == FilePath::kCurrentDirectory) | 493 if (directory == path || directory.value() == FilePath::kCurrentDirectory) |
491 dir->clear(); | 494 dir->clear(); |
492 else | 495 else |
493 *dir = directory.ToWStringHack(); | 496 *dir = directory.ToWStringHack(); |
494 } | 497 } |
| 498 int WriteFile(const std::wstring& filename, const char* data, int size) { |
| 499 return WriteFile(FilePath::FromWStringHack(filename), data, size); |
| 500 } |
495 } // namespace | 501 } // namespace |
496 | 502 |
OLD | NEW |