Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: goopdate/offline_utils.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « goopdate/offline_utils.h ('k') | goopdate/offline_utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #include "omaha/goopdate/offline_utils.h"
17 #include <atlpath.h>
18 #include "omaha/base/debug.h"
19 #include "omaha/base/file.h"
20 #include "omaha/base/logging.h"
21 #include "omaha/base/path.h"
22
23 namespace omaha {
24
25 namespace offline_utils {
26
27 CString GetV2OfflineManifest(const CString& app_id,
28 const CString& offline_dir) {
29 CPath manifest_filename(app_id);
30 VERIFY1(manifest_filename.AddExtension(_T(".gup")));
31 return ConcatenatePath(offline_dir, manifest_filename);
32 }
33
34 HRESULT FindV2OfflinePackagePath(const CString& offline_app_dir,
35 CString* package_path) {
36 ASSERT1(!offline_app_dir.IsEmpty());
37 ASSERT1(package_path);
38 package_path->Empty();
39
40 CORE_LOG(L3, (_T("[FindV2OfflinePackagePath][%s]"), offline_app_dir));
41
42 CString pattern(_T("*"));
43 std::vector<CString> files;
44 HRESULT hr = FindFiles(offline_app_dir, pattern, &files);
45 if (FAILED(hr)) {
46 return hr;
47 }
48
49 if (files.size() != 3) {
50 CORE_LOG(LE, (_T("[Cannot guess filename with multiple files]")));
51 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
52 }
53
54 CString local_package_path;
55 // Skip over "." and "..".
56 size_t i = 0;
57 for (; i < files.size(); ++i) {
58 local_package_path = ConcatenatePath(offline_app_dir, files[i]);
59 if (!File::IsDirectory(local_package_path)) {
60 break;
61 }
62 }
63 if (i == files.size()) {
64 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
65 }
66
67 CORE_LOG(L3, (_T("[Non-standard/legacy package][%s]"), local_package_path));
68 *package_path = local_package_path;
69 return S_OK;
70 }
71
72 HRESULT ParseOfflineManifest(const CString& app_id,
73 const CString& offline_dir,
74 xml::UpdateResponse* update_response) {
75 CORE_LOG(L3, (_T("[ParseOfflineManifest][%s][%s]"), app_id, offline_dir));
76 ASSERT1(update_response);
77
78 CString manifest_path(ConcatenatePath(offline_dir, kOfflineManifestFileName));
79 if (!File::Exists(manifest_path)) {
80 manifest_path = GetV2OfflineManifest(app_id, offline_dir);
81 }
82
83 HRESULT hr = update_response->DeserializeFromFile(manifest_path);
84 if (FAILED(hr)) {
85 CORE_LOG(LE, (_T("[DeserializeFromFile failed][%s][0x%x]"),
86 manifest_path, hr));
87 return hr;
88 }
89
90 return S_OK;
91 }
92
93 } // namespace offline_utils
94
95 } // namespace omaha
OLDNEW
« no previous file with comments | « goopdate/offline_utils.h ('k') | goopdate/offline_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698