• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef GESTURES_FILE_UTIL_H_
6 #define GESTURES_FILE_UTIL_H_
7 
8 #include <string>
9 
10 namespace gestures {
11 
12 // Reads the file at |path| into |contents| and returns true on success.
13 // |contents| may be NULL, in which case this function is useful for its
14 // side effect of priming the disk cache (could be used for unit tests).
15 // The function returns false and the string pointed to by |contents| is
16 // cleared when |path| does not exist or if it contains path traversal
17 // components ('..').
18 bool ReadFileToString(const char* path, std::string* contents);
19 
20 // Writes the given buffer into the file, overwriting any data that was
21 // previously there.  Returns the number of bytes written, or -1 on error.
22 int WriteFile(const char* filename, const char* data, int size);
23 
24 }  // namespace gestures
25 
26 #endif  // GESTURES_UTIL_H_
27