• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #include "tests/cefclient/browser/main_context_impl.h"
6 
7 #include <direct.h>
8 #include <shlobj.h>
9 
10 namespace client {
11 
GetDownloadPath(const std::string & file_name)12 std::string MainContextImpl::GetDownloadPath(const std::string& file_name) {
13   TCHAR szFolderPath[MAX_PATH];
14   std::string path;
15 
16   // Save the file in the user's "My Documents" folder.
17   if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PERSONAL | CSIDL_FLAG_CREATE,
18                                 nullptr, 0, szFolderPath))) {
19     path = CefString(szFolderPath);
20     path += "\\" + file_name;
21   }
22 
23   return path;
24 }
25 
GetAppWorkingDirectory()26 std::string MainContextImpl::GetAppWorkingDirectory() {
27   char szWorkingDir[MAX_PATH + 1];
28   if (_getcwd(szWorkingDir, MAX_PATH) == nullptr) {
29     szWorkingDir[0] = 0;
30   } else {
31     // Add trailing path separator.
32     size_t len = strlen(szWorkingDir);
33     szWorkingDir[len] = '\\';
34     szWorkingDir[len + 1] = 0;
35   }
36   return szWorkingDir;
37 }
38 
39 }  // namespace client
40