OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 TemporaryFile::TemporaryFile() { | 50 TemporaryFile::TemporaryFile() { |
51 // file_path_ is initialized to be empty. | 51 // file_path_ is initialized to be empty. |
52 } | 52 } |
53 | 53 |
54 TemporaryFile::TemporaryFile(const FilePath& file_to_manage) | 54 TemporaryFile::TemporaryFile(const FilePath& file_to_manage) |
55 : file_path_(file_to_manage) { | 55 : file_path_(file_to_manage) { |
56 } | 56 } |
57 | 57 |
58 bool TemporaryFile::Create(TemporaryFile* temporary_file) { | 58 bool TemporaryFile::Create(TemporaryFile* temporary_file) { |
59 FilePath temporary_path; | 59 FilePath temporary_path; |
60 if (file_util::CreateTemporaryFileName(&temporary_path)) { | 60 if (file_util::CreateTemporaryFile(&temporary_path)) { |
61 temporary_file->Reset(temporary_path); | 61 temporary_file->Reset(temporary_path); |
62 } else { | 62 } else { |
63 return false; | 63 return false; |
64 } | 64 } |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 TemporaryFile::~TemporaryFile() { | 68 TemporaryFile::~TemporaryFile() { |
69 DeletePath(file_path_); | 69 DeletePath(file_path_); |
70 } | 70 } |
71 | 71 |
72 FilePath TemporaryFile::Release() { | 72 FilePath TemporaryFile::Release() { |
73 FilePath old_path = file_path_; | 73 FilePath old_path = file_path_; |
74 file_path_ = FilePath(); | 74 file_path_ = FilePath(); |
75 return old_path; | 75 return old_path; |
76 } | 76 } |
77 | 77 |
78 void TemporaryFile::Reset(const FilePath& file_path) { | 78 void TemporaryFile::Reset(const FilePath& file_path) { |
79 DeletePath(file_path_); | 79 DeletePath(file_path_); |
80 file_path_ = file_path; | 80 file_path_ = file_path; |
81 } | 81 } |
82 | 82 |
83 } // end namespace o3d | 83 } // end namespace o3d |
OLD | NEW |