| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BIN_FILE_H_ | 5 #ifndef BIN_FILE_H_ |
| 6 #define BIN_FILE_H_ | 6 #define BIN_FILE_H_ |
| 7 | 7 |
| 8 #if defined(_WIN32) | 8 #if defined(_WIN32) |
| 9 typedef signed __int64 int64_t; | 9 typedef signed __int64 int64_t; |
| 10 typedef unsigned __int8 uint8_t; | 10 typedef unsigned __int8 uint8_t; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return WriteFully(&byte, 1); | 39 return WriteFully(&byte, 1); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Get the length of the file. Returns a negative value if the length cannot | 42 // Get the length of the file. Returns a negative value if the length cannot |
| 43 // be determined (e.g. not seekable device). | 43 // be determined (e.g. not seekable device). |
| 44 off_t Length(); | 44 off_t Length(); |
| 45 | 45 |
| 46 // Get the current position in the file. | 46 // Get the current position in the file. |
| 47 // Returns a negative value if position cannot be determined. | 47 // Returns a negative value if position cannot be determined. |
| 48 off_t Position(); | 48 off_t Position(); |
| 49 off_t SetPosition(int64_t position); | 49 |
| 50 // Set the byte position in the file. |
| 51 bool SetPosition(int64_t position); |
| 52 |
| 53 // Truncate (or extend) the file to the given length in bytes. |
| 54 bool Truncate(int64_t length); |
| 50 | 55 |
| 51 // Flush contents of file. | 56 // Flush contents of file. |
| 52 void Flush(); | 57 void Flush(); |
| 53 | 58 |
| 54 const char* name() const { return name_; } | 59 const char* name() const { return name_; } |
| 55 | 60 |
| 56 static File* Open(const char* name, bool writable); | 61 static File* Open(const char* name, bool writable); |
| 57 static bool Exists(const char* name); | 62 static bool Exists(const char* name); |
| 58 static bool Create(const char* name); | 63 static bool Create(const char* name); |
| 59 static bool Delete(const char* name); | 64 static bool Delete(const char* name); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 72 const char* name_; | 77 const char* name_; |
| 73 // FileHandle is an OS specific class which stores data about the file. | 78 // FileHandle is an OS specific class which stores data about the file. |
| 74 FileHandle* handle_; // OS specific handle for the file. | 79 FileHandle* handle_; // OS specific handle for the file. |
| 75 | 80 |
| 76 // DISALLOW_COPY_AND_ASSIGN(File). | 81 // DISALLOW_COPY_AND_ASSIGN(File). |
| 77 File(const File&); | 82 File(const File&); |
| 78 void operator=(const File&); | 83 void operator=(const File&); |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 #endif // BIN_FILE_H_ | 86 #endif // BIN_FILE_H_ |
| OLD | NEW |