 Chromium Code Reviews
 Chromium Code Reviews Issue 6111003:
  Use FilePath::DirName instead of the deprecated file_util::GetDirectoryFromPath.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 6111003:
  Use FilePath::DirName instead of the deprecated file_util::GetDirectoryFromPath.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/installer/util/lzma_util.h" | 5 #include "chrome/installer/util/lzma_util.h" | 
| 6 | 6 | 
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" | 
| 8 #include "base/logging.h" | 8 #include "base/logging.h" | 
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" | 
| 10 | 10 | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 CFileItem *f = db.Database.Files + i; | 152 CFileItem *f = db.Database.Files + i; | 
| 153 | 153 | 
| 154 if ((ret = SzExtract(&archiveStream.InStream, &db, i, &blockIndex, | 154 if ((ret = SzExtract(&archiveStream.InStream, &db, i, &blockIndex, | 
| 155 &outBuffer, &outBufferSize, &offset, &outSizeProcessed, | 155 &outBuffer, &outBufferSize, &offset, &outSizeProcessed, | 
| 156 &allocImp, &allocTempImp)) != SZ_OK) { | 156 &allocImp, &allocTempImp)) != SZ_OK) { | 
| 157 LOG(ERROR) << L"Error returned by SzExtract: " << ret; | 157 LOG(ERROR) << L"Error returned by SzExtract: " << ret; | 
| 158 break; | 158 break; | 
| 159 } | 159 } | 
| 160 | 160 | 
| 161 // Append location to the file path in archive, to get full path. | 161 // Append location to the file path in archive, to get full path. | 
| 162 std::wstring wfileName(location); | 162 std::wstring file_name(location); | 
| 
Evan Martin
2011/01/06 23:39:49
Maybe better to make this a FilePath?  Then we cou
 
tfarina
2011/01/06 23:52:48
Done. PTAL!
 | |
| 163 file_util::AppendToPath(&wfileName, UTF8ToWide(f->Name)); | 163 file_util::AppendToPath(&file_name, UTF8ToWide(f->Name)); | 
| 164 if (output_file) | 164 if (output_file) | 
| 165 *output_file = wfileName; | 165 *output_file = file_name; | 
| 166 | 166 | 
| 167 // If archive entry is directory create it and move on to the next entry. | 167 // If archive entry is directory create it and move on to the next entry. | 
| 168 if (f->IsDirectory) { | 168 if (f->IsDirectory) { | 
| 169 file_util::CreateDirectory(FilePath(wfileName)); | 169 file_util::CreateDirectory(FilePath(file_name)); | 
| 170 continue; | 170 continue; | 
| 171 } | 171 } | 
| 172 | 172 | 
| 173 HANDLE hFile; | 173 HANDLE hFile; | 
| 174 std::wstring directory = file_util::GetDirectoryFromPath(wfileName); | 174 file_util::CreateDirectory(FilePath(file_name).DirName()); | 
| 175 file_util::CreateDirectory(FilePath(directory)); | |
| 176 | 175 | 
| 177 hFile = CreateFile(wfileName.c_str(), GENERIC_WRITE, 0, NULL, | 176 hFile = CreateFile(file_name.c_str(), GENERIC_WRITE, 0, NULL, | 
| 178 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | 177 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | 
| 179 if (hFile == INVALID_HANDLE_VALUE) { | 178 if (hFile == INVALID_HANDLE_VALUE) { | 
| 180 ret = GetLastError(); | 179 ret = GetLastError(); | 
| 181 LOG(ERROR) << L"Error returned by CreateFile: " << ret; | 180 LOG(ERROR) << L"Error returned by CreateFile: " << ret; | 
| 182 break; | 181 break; | 
| 183 } | 182 } | 
| 184 | 183 | 
| 185 if ((!WriteFile(hFile, outBuffer + offset, (DWORD) outSizeProcessed, | 184 if ((!WriteFile(hFile, outBuffer + offset, (DWORD) outSizeProcessed, | 
| 186 &written, NULL)) || | 185 &written, NULL)) || | 
| 187 (written != outSizeProcessed)) { | 186 (written != outSizeProcessed)) { | 
| (...skipping 23 matching lines...) Expand all Loading... | |
| 211 SzArDbExFree(&db, allocImp.Free); | 210 SzArDbExFree(&db, allocImp.Free); | 
| 212 return ret; | 211 return ret; | 
| 213 } | 212 } | 
| 214 | 213 | 
| 215 void LzmaUtil::CloseArchive() { | 214 void LzmaUtil::CloseArchive() { | 
| 216 if (archive_handle_) { | 215 if (archive_handle_) { | 
| 217 CloseHandle(archive_handle_); | 216 CloseHandle(archive_handle_); | 
| 218 archive_handle_ = NULL; | 217 archive_handle_ = NULL; | 
| 219 } | 218 } | 
| 220 } | 219 } | 
| OLD | NEW |