Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: webrtc/base/file.h

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/fakesslidentity.h ('k') | webrtc/base/file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_FILE_H_ 11 #ifndef WEBRTC_BASE_FILE_H_
12 #define WEBRTC_BASE_FILE_H_ 12 #define WEBRTC_BASE_FILE_H_
13 13
14 #include <stdint.h>
15 14
16 #include <string> 15 // This header is deprecated and is just left here temporarily during
17 16 // refactoring. See https://bugs.webrtc.org/7634 for more details.
18 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/rtc_base/file.h"
19 #include "webrtc/base/pathutils.h"
20 #include "webrtc/base/platform_file.h"
21
22 namespace rtc {
23
24 // This class wraps the platform specific APIs for simple file interactions.
25 //
26 // The various read and write methods are best effort, i.e. if an underlying
27 // call does not manage to read/write all the data more calls will be performed,
28 // until an error is detected or all data is read/written.
29 class File {
30 public:
31 // Wraps the given PlatformFile. This class is then responsible for closing
32 // the file, which will be done in the destructor if Close is never called.
33 explicit File(PlatformFile);
34 // The default constructor produces a closed file.
35 File();
36 ~File();
37
38 File(File&& other);
39 File& operator=(File&& other);
40
41 // Open and Create give files with both reading and writing enabled.
42 static File Open(const std::string& path);
43 static File Open(Pathname&& path);
44 static File Open(const Pathname& path);
45 // If the file already exists it will be overwritten.
46 static File Create(const std::string& path);
47 static File Create(Pathname&& path);
48 static File Create(const Pathname& path);
49
50 // Remove a file in the file system.
51 static bool Remove(const std::string& path);
52 static bool Remove(Pathname&& path);
53 static bool Remove(const Pathname& path);
54
55 size_t Write(const uint8_t* data, size_t length);
56 size_t Read(uint8_t* buffer, size_t length);
57
58 // The current position in the file after a call to these methods is platform
59 // dependent (MSVC gives position offset+length, most other
60 // compilers/platforms do not alter the position), i.e. do not depend on it,
61 // do a Seek before any subsequent Read/Write.
62 size_t WriteAt(const uint8_t* data, size_t length, size_t offset);
63 size_t ReadAt(uint8_t* buffer, size_t length, size_t offset);
64
65 // Attempt to position the file at the given offset from the start.
66 // Returns true if successful, false otherwise.
67 bool Seek(size_t offset);
68
69 // Attempt to close the file. Returns true if successful, false otherwise,
70 // most notably when the file is already closed.
71 bool Close();
72
73 bool IsOpen();
74
75 private:
76 PlatformFile file_;
77 RTC_DISALLOW_COPY_AND_ASSIGN(File);
78 };
79
80 } // namespace rtc
81 18
82 #endif // WEBRTC_BASE_FILE_H_ 19 #endif // WEBRTC_BASE_FILE_H_
OLDNEW
« no previous file with comments | « webrtc/base/fakesslidentity.h ('k') | webrtc/base/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698