• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Marshall A. Greenblatt. Portions copyright (c) 2012
2 // Google Inc. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //    * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //    * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //    * Neither the name of Google Inc. nor the name Chromium Embedded
15 // Framework nor the names of its contributors may be used to endorse
16 // or promote products derived from this software without specific prior
17 // written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 //
31 // ---------------------------------------------------------------------------
32 //
33 // The contents of this file must follow a specific format in order to
34 // support the CEF translator tool. See the translator.README.txt file in the
35 // tools directory for more information.
36 //
37 
38 #ifndef CEF_INCLUDE_CEF_FILE_UTIL_H_
39 #define CEF_INCLUDE_CEF_FILE_UTIL_H_
40 #pragma once
41 
42 #include "include/cef_base.h"
43 
44 ///
45 // Creates a directory and all parent directories if they don't already exist.
46 // Returns true on successful creation or if the directory already exists. The
47 // directory is only readable by the current user. Calling this function on the
48 // browser process UI or IO threads is not allowed.
49 ///
50 /*--cef()--*/
51 bool CefCreateDirectory(const CefString& full_path);
52 
53 ///
54 // Get the temporary directory provided by the system.
55 //
56 // WARNING: In general, you should use the temp directory variants below instead
57 // of this function. Those variants will ensure that the proper permissions are
58 // set so that other users on the system can't edit them while they're open
59 // (which could lead to security issues).
60 ///
61 /*--cef()--*/
62 bool CefGetTempDirectory(CefString& temp_dir);
63 
64 ///
65 // Creates a new directory. On Windows if |prefix| is provided the new directory
66 // name is in the format of "prefixyyyy". Returns true on success and sets
67 // |new_temp_path| to the full path of the directory that was created. The
68 // directory is only readable by the current user. Calling this function on the
69 // browser process UI or IO threads is not allowed.
70 ///
71 /*--cef(optional_param=prefix)--*/
72 bool CefCreateNewTempDirectory(const CefString& prefix,
73                                CefString& new_temp_path);
74 
75 ///
76 // Creates a directory within another directory. Extra characters will be
77 // appended to |prefix| to ensure that the new directory does not have the same
78 // name as an existing directory. Returns true on success and sets |new_dir| to
79 // the full path of the directory that was created. The directory is only
80 // readable by the current user. Calling this function on the browser process
81 // UI or IO threads is not allowed.
82 ///
83 /*--cef(optional_param=prefix)--*/
84 bool CefCreateTempDirectoryInDirectory(const CefString& base_dir,
85                                        const CefString& prefix,
86                                        CefString& new_dir);
87 
88 ///
89 // Returns true if the given path exists and is a directory. Calling this
90 // function on the browser process UI or IO threads is not allowed.
91 ///
92 /*--cef()--*/
93 bool CefDirectoryExists(const CefString& path);
94 
95 ///
96 // Deletes the given path whether it's a file or a directory. If |path| is a
97 // directory all contents will be deleted.  If |recursive| is true any sub-
98 // directories and their contents will also be deleted (equivalent to executing
99 // "rm -rf", so use with caution). On POSIX environments if |path| is a symbolic
100 // link then only the symlink will be deleted. Returns true on successful
101 // deletion or if |path| does not exist. Calling this function on the browser
102 // process UI or IO threads is not allowed.
103 ///
104 /*--cef()--*/
105 bool CefDeleteFile(const CefString& path, bool recursive);
106 
107 ///
108 // Writes the contents of |src_dir| into a zip archive at |dest_file|. If
109 // |include_hidden_files| is true files starting with "." will be included.
110 // Returns true on success.  Calling this function on the browser process UI or
111 // IO threads is not allowed.
112 ///
113 /*--cef()--*/
114 bool CefZipDirectory(const CefString& src_dir,
115                      const CefString& dest_file,
116                      bool include_hidden_files);
117 
118 ///
119 // Loads the existing "Certificate Revocation Lists" file that is managed by
120 // Google Chrome. This file can generally be found in Chrome's User Data
121 // directory (e.g. "C:\Users\[User]\AppData\Local\Google\Chrome\User Data\" on
122 // Windows) and is updated periodically by Chrome's component updater service.
123 // Must be called in the browser process after the context has been initialized.
124 // See https://dev.chromium.org/Home/chromium-security/crlsets for background.
125 ///
126 /*--cef()--*/
127 void CefLoadCRLSetsFile(const CefString& path);
128 
129 #endif  // CEF_INCLUDE_CEF_FILE_UTIL_H_
130