• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "mojo/public/cpp/base/file_path_mojom_traits.h"
6 
7 namespace mojo {
8 
9 // static
Read(mojo_base::mojom::FilePathDataView data,base::FilePath * out)10 bool StructTraits<mojo_base::mojom::FilePathDataView, base::FilePath>::Read(
11     mojo_base::mojom::FilePathDataView data,
12     base::FilePath* out) {
13   base::FilePath::StringPieceType path_view;
14 #if defined(OS_WIN)
15   ArrayDataView<uint16_t> view;
16   data.GetPathDataView(&view);
17   path_view.set(reinterpret_cast<const base::char16*>(view.data()),
18                 view.size());
19 #else
20   if (!data.ReadPath(&path_view)) {
21     return false;
22   }
23 #endif
24   *out = base::FilePath(path_view);
25   return true;
26 }
27 
28 }  // namespace mojo
29