mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-12 09:37:37 +01:00
17fc2b3e3b
- Convert scoped_ptr to std::unique_ptr from <memory> - Convert arraysize to base::size from include/base/cef_cxx17_backports.h - Convert NULL to nullptr - Include include/base/cef_callback.h instead of include/base/cef_bind.h - Implicit conversion of CefRefPtr<T> or scoped_refptr<T> to T* is gone; use .get() instead See the issue for additional details.
46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
// Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
|
|
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
|
|
// governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef CEF_TESTS_SHARED_BROWSER_FILE_UTIL_H_
|
|
#define CEF_TESTS_SHARED_BROWSER_FILE_UTIL_H_
|
|
#pragma once
|
|
|
|
#include <limits>
|
|
#include <string>
|
|
|
|
namespace client {
|
|
namespace file_util {
|
|
|
|
// Platform-specific path separator.
|
|
extern const char kPathSep;
|
|
|
|
// Reads the file at |path| into |contents| and returns true on success and
|
|
// false on error. In case of I/O error, |contents| holds the data that could
|
|
// be read from the file before the error occurred. When the file size exceeds
|
|
// max_size|, the function returns false with |contents| holding the file
|
|
// truncated to |max_size|. |contents| may be nullptr, in which case this
|
|
// function is useful for its side effect of priming the disk cache (could be
|
|
// used for unit tests). Calling this function on the browser process UI or IO
|
|
// threads is not allowed.
|
|
bool ReadFileToString(const std::string& path,
|
|
std::string* contents,
|
|
size_t max_size = std::numeric_limits<size_t>::max());
|
|
|
|
// Writes the given buffer into the file, overwriting any data that was
|
|
// previously there. Returns the number of bytes written, or -1 on error.
|
|
// Calling this function on the browser process UI or IO threads is not allowed.
|
|
int WriteFile(const std::string& path, const char* data, int size);
|
|
|
|
// Combines |path1| and |path2| with the correct platform-specific path
|
|
// separator.
|
|
std::string JoinPath(const std::string& path1, const std::string& path2);
|
|
|
|
// Extracts the file extension from |path|.
|
|
std::string GetFileExtension(const std::string& path);
|
|
|
|
} // namespace file_util
|
|
} // namespace client
|
|
|
|
#endif // CEF_TESTS_SHARED_BROWSER_FILE_UTIL_H_
|